本文整理汇总了PHP中PageModel::findByPk方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::findByPk方法的具体用法?PHP PageModel::findByPk怎么用?PHP PageModel::findByPk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::findByPk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate the module
*/
protected function compile()
{
$this->Template->text_title = $GLOBALS['TL_LANG']['MSC']['price_title'];
$this->Template->text_model = $GLOBALS['TL_LANG']['MSC']['price_model'];
$this->Template->text_SKU = $GLOBALS['TL_LANG']['MSC']['price_SKU'];
$this->Template->text_description = $GLOBALS['TL_LANG']['MSC']['price_description'];
$this->Template->text_amount = $GLOBALS['TL_LANG']['MSC']['price_amount'];
$this->Template->text_unit = $GLOBALS['TL_LANG']['MSC']['price_unit'];
$this->Template->text_price = $GLOBALS['TL_LANG']['MSC']['price_price'];
$this->strTemplate = $this->pricelist_template;
$intList = $this->pricelist;
$objPricelist = $this->Database->prepare("SELECT * FROM tl_pricelist WHERE id=?")->execute($intList);
$objItems = $this->Database->prepare("SELECT * FROM tl_pricelist_item WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList);
// Return if no Products were found
if (!$objItems->numRows) {
$this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyPriceList'];
return;
}
$this->Template->description = $objPricelist->description;
$objJump = \PageModel::findByPk($objPricelist->jumpTo);
$strLink = $this->generateFrontendUrl($objJump->row());
$arrItems = array();
$i = 0;
// Generate Products
while ($objItems->next()) {
$i = $i + 1;
$arrItems[] = array('no' => $i, 'title' => $objItems->title, 'sku' => $objItems->sku, 'model' => $objItems->model, 'price' => $objItems->price ? $objItems->price . ' ' . $objPricelist->currency : '<a href=' . $strLink . '>تماس بگیرید</a>', 'date' => $objItems->tstamp, 'unit' => $objItems->unit, 'amount' => $objItems->amount, 'sale' => $objItems->sale, 'stock' => $objItems->stock, 'url' => $objItems->url, 'description' => $objItems->description);
}
$this->Template->items = $arrItems;
}
示例2: loadModalContent
/**
* load modal content
*/
public function loadModalContent()
{
global $objPage;
$id = \Input::get('modal');
if ($id == '') {
return;
}
$page = \Input::get('page');
// load layout because we need to initiate bootstrap
/** @var \PageModel $objPage */
$objPage = \PageModel::findByPk($page);
$objPage->loadDetails();
if ($objPage === null) {
$this->log(sprintf('Page ID %s not found', $page), 'Netzmacht\\Bootstrap\\Ajax::loadModalContent', TL_ERROR);
exit;
}
$objLayout = $this->getPageLayout($objPage);
// Set the layout template and template group
$objPage->template = $objLayout->template ?: 'fe_page';
$objPage->templateGroup = $objLayout->getRelated('pid')->templates;
// trigger getPageLayout hook so
if (isset($GLOBALS['TL_HOOKS']['getPageLayout']) && is_array($GLOBALS['TL_HOOKS']['getPageLayout'])) {
foreach ($GLOBALS['TL_HOOKS']['getPageLayout'] as $hook) {
$this->import($hook[0]);
$this->{$hook[0]}->{$hook[1]}($objPage, $objLayout, $this);
}
}
$model = \ModuleModel::findOneBy('type="bootstrap_modal" AND tl_module.id', $id);
if ($model === null) {
exit;
}
$model->isAjax = true;
$this->output($this->getFrontendModule($model));
}
示例3: loadStoreDetails
/**
* @deprecated
*/
public static function loadStoreDetails(array $arrStore, $jumpTo = null)
{
//load country names
//@todo load only once. not every time.
$arrCountryNames = \System::getCountries();
//full localized country name
//@todo rename country to countrycode in database
$arrStore['countrycode'] = $arrStore['country'];
$arrStore['country'] = $arrCountryNames[$arrStore['countrycode']];
// generate jump to
if ($jumpTo) {
if (($objLocation = \PageModel::findByPk($jumpTo)) !== null) {
//@todo language parameter
$strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
$strStoreValue = $arrStore['alias'];
$arrStore['href'] = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
}
}
// opening times
$arrStore['opening_times'] = deserialize($arrStore['opening_times']);
// store logo
//@todo change size and properties in module
if ($arrStore['logo']) {
if (($objLogo = \FilesModel::findByUuid($arrStore['logo'])) !== null) {
$arrLogo = $objLogo->row();
$arrMeta = deserialize($arrLogo['meta']);
$arrLogo['meta'] = $arrMeta[$GLOBALS['TL_LANGUAGE']];
$arrStore['logo'] = $arrLogo;
} else {
$arrStore['logo'] = null;
}
}
return $arrStore;
}
示例4: checkPermissionForProtectedHomeDirs
public static function checkPermissionForProtectedHomeDirs($strFile)
{
$strUuid = \Config::get('protectedHomeDirRoot');
if (!$strFile) {
return;
}
if ($strUuid && ($strProtectedHomeDirRootPath = \HeimrichHannot\HastePlus\Files::getPathFromUuid($strUuid)) !== null) {
// check only if path inside the protected root dir
if (StringUtil::startsWith($strFile, $strProtectedHomeDirRootPath)) {
if (FE_USER_LOGGED_IN) {
if (($objFrontendUser = \FrontendUser::getInstance()) !== null) {
if (\Config::get('allowAccessByMemberId') && $objFrontendUser->assignProtectedDir && $objFrontendUser->protectedHomeDir) {
$strProtectedHomeDirMemberRootPath = Files::getPathFromUuid($objFrontendUser->protectedHomeDir);
// fe user id = dir owner member id
if (StringUtil::startsWith($strFile, $strProtectedHomeDirMemberRootPath)) {
return;
}
}
if (\Config::get('allowAccessByMemberGroups')) {
$arrAllowedGroups = deserialize(\Config::get('allowedMemberGroups'), true);
if (array_intersect(deserialize($objFrontendUser->groups, true), $arrAllowedGroups)) {
return;
}
}
}
}
$intNoAccessPage = \Config::get('jumpToNoAccess');
if ($intNoAccessPage && ($objPageJumpTo = \PageModel::findByPk($intNoAccessPage)) !== null) {
\Controller::redirect(\Controller::generateFrontendUrl($objPageJumpTo->row()));
} else {
die($GLOBALS['TL_LANG']['MSC']['noAccessDownload']);
}
}
}
}
示例5: compile
protected function compile()
{
if ($this->defineRoot) {
$objPage = \PageModel::findByPk($this->rootPage);
} else {
global $objPage;
}
if (null === $objPage) {
return;
}
$intOffset = (int) $this->levelOffset;
// Random image
if ($this->randomPageImage) {
$intOffset = -1;
}
$arrImage = PageImage::getOne($objPage, $intOffset, (bool) $this->inheritPageImage);
if (null === $arrImage) {
return;
}
$arrSize = deserialize($this->imgSize);
$arrImage['src'] = $this->getImage($arrImage['path'], $arrSize[0], $arrSize[1], $arrSize[2]);
$this->Template->setData($arrImage);
if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($arrImage['src']))) !== false) {
$this->Template->size = ' ' . $imgSize[3];
}
}
示例6: compile
/**
* Generate the module
*/
protected function compile()
{
$intList = $this->athletes_group;
$objMembers = $this->Database->prepare("SELECT * FROM tl_athlete WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList);
//$objMembers = \MembersModel;
// Return if no Members were found
if (!$objMembers->numRows) {
return;
}
$strLink = '';
// Generate a jumpTo link
if ($this->jumpTo > 0) {
$objJump = \PageModel::findByPk($this->jumpTo);
if ($objJump !== null) {
$strLink = $this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s');
}
}
$arrMembers = array();
// Generate Members
while ($objMembers->next()) {
$strPhoto = '';
$objPhoto = \FilesModel::findByPk($objMembers->photo);
// Add photo image
if ($objPhoto !== null) {
$strPhoto = \Image::getHtml(\Image::get($objPhoto->path, '140', '187', 'center_center'));
}
$arrMembers[] = array('name' => $objMembers->name, 'family' => $objMembers->family, 'post' => $objMembers->post, 'joined' => $objMembers->joined, 'photo' => $strPhoto, 'link' => strlen($strLink) ? sprintf($strLink, $objMembers->alias) : '');
}
$this->Template->members = $arrMembers;
}
示例7: parseCredit
public static function parseCredit(FileCreditModel $objModel, array $arrPids = array(), $objModule)
{
global $objPage;
$objTemplate = new \FrontendTemplate(!$objModule->creditsGroupBy ? 'filecredit_default' : 'filecredit_grouped');
// skip if no files model exists
if (($objFilesModel = $objModel->getRelated('uuid')) === null) {
return null;
}
// cleanup: remove credits where copyright was deleted
if ($objFilesModel->copyright == '') {
FileCreditPageModel::deleteByPid($objModel->id);
$objModel->delete();
return null;
}
// skip if credit occurs on no page
if (($objCreditPages = FileCreditPageModel::findPublishedByPids(array($objModel->id))) === null) {
return null;
}
while ($objCreditPages->next()) {
$arrCredit = $objCreditPages->row();
// not a child of current root page
if (!empty($arrPids) && !in_array($arrCredit['page'], $arrPids)) {
continue;
}
if ($arrCredit['url'] == '' && ($objTarget = \PageModel::findByPk($arrCredit['page'])) !== null) {
$arrCredit['url'] = \Controller::generateFrontendUrl($objTarget->row());
}
$arrPages[] = $arrCredit;
}
if ($arrPages === null) {
return null;
}
$objTemplate->setData($objModel->row());
$objTemplate->fileData = $objFilesModel->row();
static::addCopyrightToTemplate($objTemplate, $objFilesModel, $objModule);
$objTemplate->link = $GLOBALS['TL_LANG']['MSC']['creditLinkText'];
$objTemplate->pagesLabel = $GLOBALS['TL_LANG']['MSC']['creditPagesLabel'];
$objTemplate->path = $objFilesModel->path;
$objTemplate->pages = $arrPages;
$objTemplate->pageCount = count($arrPages);
// colorbox support
if ($objPage->outputFormat == 'xhtml') {
$strLightboxId = 'lightbox';
} else {
$strLightboxId = 'lightbox[' . substr(md5($objTemplate->getName() . '_' . $objFilesModel->id), 0, 6) . ']';
}
$objTemplate->attribute = $strLightboxId ? ($objPage->outputFormat == 'html5' ? ' data-gallery="#gallery-' . $objModule->id . '" data-lightbox="' : ' rel="') . $strLightboxId . '"' : '';
$objTemplate->addImage = false;
// Add an image
if (!is_file(TL_ROOT . '/' . $objModel->path)) {
$arrData = array('singleSRC' => $objFilesModel->path, 'doNotIndex' => true);
$size = deserialize($objModule->imgSize);
if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
$arrData['size'] = $objModule->imgSize;
}
\Controller::addImageToTemplate($objTemplate, $arrData);
}
return array('pages' => $arrPages, 'order' => static::getSortValue($objModule->creditsSortBy, $objTemplate), 'group' => static::getGroupValue($objModule->creditsGroupBy, $objTemplate), 'output' => $objTemplate->parse());
}
示例8: getCurrentRootPage
/**
* Get the current root page and return it
* @return object
*/
protected function getCurrentRootPage()
{
global $objPage;
$strKey = 'COOKIEBAR_ROOT_' . $objPage->rootId;
if (!\Cache::has($strKey)) {
\Cache::set($strKey, \PageModel::findByPk($objPage->rootId));
}
return \Cache::get($strKey);
}
示例9: compile
/**
* Generate the module
*/
protected function compile()
{
$this->import('FrontendUser', 'User');
$session = $this->Session->get('bnfilter') ?: array();
if (strlen($session['geo_lat']) > 0 && strlen($session['geo_lon']) > 0) {
$geodata = array('lat' => $session['geo_lat'], 'lon' => $session['geo_lon']);
} else {
$geodata = $this->getGeoDataFromCurrentPosition();
}
// Get the total number of items
$intTotal = \BnLibrariesModel::countLibEntries($geodata, $session['distance']);
// Filter anwenden um die Gesamtanzahl zuermitteln
if ($intTotal > 0) {
$libsObj = \BnLibrariesModel::findLibs($intTotal, 0, $geodata, $session['distance']);
$counter = 0;
$libs = array();
while ($libsObj->next()) {
// aktuell offen
if ($session['only_open'] && $this->getCurrentOpenStatus($libsObj) != 'open') {
continue;
}
// bietet eine bestimmte Leistung an
if (strlen($session['leistungen']) > 0 && !$this->hasLeistung($libsObj)) {
continue;
}
// bietet eine bestimmte Medienart an
if (strlen($session['medien']) > 0 && !$this->hasMedia($libsObj)) {
continue;
}
//Detail-Url
if ($this->jumpTo) {
$objDetailPage = \PageModel::findByPk($this->jumpTo);
}
//wenn alle Filter stimmen -> Werte setzen
$libs[] = array('lat' => $libsObj->lat, 'lon' => $libsObj->lon, 'name' => $libsObj->bibliotheksname, 'plz' => $libsObj->plz, 'ort' => $libsObj->ort, 'strasse' => $libsObj->strasse, 'hnr' => $libsObj->hausnummer, 'detailUrl' => ampersand($this->generateFrontendUrl($objDetailPage->row(), '/lib/' . $libsObj->id)), 'openstatus' => $this->getCurrentOpenStatus($libsObj));
$counter++;
}
}
if ((int) $intTotal > $counter) {
$intTotal = $counter;
}
// //set fallback (Hannover)
if ($geodata['lat'] == '') {
$geodata['lat'] = 52.4544218;
}
if ($geodata['lon'] == '') {
$geodata['lon'] = 9.918507699999999;
}
$GLOBALS['TL_JAVASCRIPT'][] = '.' . BN_PATH . '/assets/js/bn_fe.js';
$this->Template->libs = $libs;
$this->Template->filterActive = \Input::get('s') ? true : false;
$this->Template->geodata = $geodata;
$this->Template->zoomlevel = count($session) == 0 ? 7 : 9;
$this->Template->totalItems = $intTotal;
// $this->Template->showAllUrl = $this->generateFrontendUrl($objPage->row());
}
示例10: addSubscriptions
public static function addSubscriptions(Order $objOrder, $arrTokens)
{
$strEmail = $objOrder->getBillingAddress()->email;
$objAddress = $objOrder->getShippingAddress() ?: $objOrder->getBillingAddress();
$arrItems = $objOrder->getItems();
$objSession = \Session::getInstance();
if (!($intModule = $objSession->get('isotopeCheckoutModuleIdSubscriptions'))) {
return true;
}
$objSession->remove('isotopeCheckoutModuleIdSubscriptions');
$objModule = \ModuleModel::findByPk($intModule);
foreach ($arrItems as $item) {
switch ($objModule->iso_direct_checkout_product_mode) {
case 'product_type':
$objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product_type', Standard::findAvailableByIdOrAlias($item->product_id)->type);
break;
default:
$objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product', $item->product_id);
break;
}
if ($objFieldpalette !== null && $objFieldpalette->iso_addSubscription) {
if ($objFieldpalette->iso_subscriptionArchive && (!$objFieldpalette->iso_addSubscriptionCheckbox || \Input::post('subscribeToProduct_' . $item->product_id))) {
$objSubscription = Subscription::findOneBy(array('email=?', 'pid=?', 'activation!=?', 'disable=?'), array($strEmail, $objFieldpalette->iso_subscriptionArchive, '', 1));
if (!$objSubscription) {
$objSubscription = new Subscription();
}
if ($objFieldpalette->iso_addActivation) {
$strToken = md5(uniqid(mt_rand(), true));
$objSubscription->disable = true;
$objSubscription->activation = $strToken;
if (($objNotification = Notification::findByPk($objFieldpalette->iso_activationNotification)) !== null) {
if ($objFieldpalette->iso_activationJumpTo && ($objPageRedirect = \PageModel::findByPk($objFieldpalette->iso_activationJumpTo)) !== null) {
$arrTokens['link'] = \Environment::get('url') . '/' . \Controller::generateFrontendUrl($objPageRedirect->row()) . '?token=' . $strToken;
}
$objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
}
}
$arrAddressFields = \Config::get('iso_addressFields');
if ($arrAddressFields === null) {
$arrAddressFields = serialize(array_keys(static::getIsotopeAddressFields()));
}
foreach (deserialize($arrAddressFields, true) as $strName) {
$objSubscription->{$strName} = $objAddress->{$strName};
}
$objSubscription->email = $strEmail;
$objSubscription->pid = $objFieldpalette->iso_subscriptionArchive;
$objSubscription->tstamp = $objSubscription->dateAdded = time();
$objSubscription->quantity = \Input::post('quantity');
$objSubscription->order_id = $objOrder->id;
$objSubscription->save();
}
}
}
return true;
}
示例11: addRecipient
private function addRecipient($email, $arrChannels, $strMailText, $intJumpTo)
{
$varInput = \Idna::encodeEmail($email);
// Get the existing active subscriptions
$arrSubscriptions = array();
if (($objSubscription = \NewsletterRecipientsModel::findBy(array("email=? AND active=1"), $varInput)) !== null) {
$arrSubscriptions = $objSubscription->fetchEach('pid');
}
$arrNew = array_diff($arrChannels, $arrSubscriptions);
// Return if there are no new subscriptions
if (!is_array($arrNew) || empty($arrNew)) {
return;
}
// Remove old subscriptions that have not been activated yet
if (($objOld = \NewsletterRecipientsModel::findBy(array("email=? AND active=''"), $varInput)) !== null) {
while ($objOld->next()) {
$objOld->delete();
}
}
$time = time();
$strToken = md5(uniqid(mt_rand(), true));
// Add the new subscriptions
foreach ($arrNew as $id) {
$objRecipient = new \NewsletterRecipientsModel();
$objRecipient->pid = $id;
$objRecipient->tstamp = $time;
$objRecipient->email = $varInput;
$objRecipient->active = '';
$objRecipient->addedOn = $time;
$objRecipient->ip = $this->anonymizeIp(\Environment::get('ip'));
$objRecipient->token = $strToken;
$objRecipient->confirmed = '';
$objRecipient->save();
}
// Get the channels
$objChannel = \NewsletterChannelModel::findByIds($arrChannels);
// Prepare the e-mail text
$strText = str_replace('##token##', $strToken, $strMailText);
$strText = str_replace('##domain##', \Environment::get('host'), $strText);
//$strText = str_replace('##link##', \Environment::get('base') . \Environment::get('request') . (($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false) ? '&' : '?') . 'token=' . $strToken, $strText);
$objPageConfirm = \PageModel::findByPk($intJumpTo);
if ($objPageConfirm === null) {
$this->log('Newsletter confirmation page not found, id: ' . $intJumpTo, __CLASS__ . ":" . __METHOD__, TL_NEWSLETTER);
}
$strText = str_replace('##link##', rtrim(\Environment::get('base'), '/') . '/' . $this->generateFrontendUrl($objPageConfirm->row()) . '?token=' . $strToken, $strText);
$strText = str_replace(array('##channel##', '##channels##'), implode("\n", $objChannel->fetchEach('title')), $strText);
// Activation e-mail
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['nl_subject'], \Environment::get('host'));
$objEmail->text = $strText;
$objEmail->sendTo($varInput);
}
示例12: isProtected
public function isProtected($pageModel)
{
if ($pageModel->protected === true) {
return true;
}
if ($pageModel->pid > 0) {
$objParentPage = \PageModel::findByPk($pageModel->pid);
return $this->isProtected($objParentPage);
}
return false;
}
示例13: getParameterName
/**
* Get the parameter name
*
* @param int $rootId
*
* @return string
*/
public static function getParameterName($rootId = null)
{
if (!$rootId) {
$rootId = $GLOBALS['objPage']->rootId;
}
$rootPage = \PageModel::findByPk($rootId);
if ($rootPage === null) {
return '';
}
return $rootPage->newsCategories_param ?: 'category';
}
示例14: compile
/**
* Generate module
*/
protected function compile()
{
// hide list when details shown
//@todo make optinonal in module
if (strlen(\Input::get('auto_item')) || strlen(\Input::get('store'))) {
return;
}
// localized url parameter
//@todo use $GLOBALS['TL_URL_PARAMS']...
$this->strSearchKey = $GLOBALS['TL_LANG']['anystores']['url_params']['search'];
$this->strSearchValue = \Input::get($this->strSearchKey);
$this->strCountryKey = $GLOBALS['TL_LANG']['anystores']['url_params']['country'];
$this->strCountryValue = \Input::get($this->strCountryKey) ?: $this->anystores_defaultCountry;
// if no empty search is allowed
if (!$this->anystores_allowEmptySearch && !$this->strSearchValue && $this->strCountryValue) {
$this->Template->error = $GLOBALS['TL_LANG']['anystores']['noResults'];
return;
}
if (!$this->strSearchValue) {
// order
$arrOptions = array();
if (strlen($this->anystores_sortingOrder)) {
$arrOptions['order'] = $this->anystores_sortingOrder;
}
$objStore = AnyStoresModel::findPublishedByCategoryAndCountry(deserialize($this->anystores_categories), $this->strCountryValue, $arrOptions);
} else {
$objStore = AnyStoresModel::findPublishedByAdressAndCountryAndCategory($this->strSearchValue, $this->strCountryValue, deserialize($this->anystores_categories), $this->anystores_listLimit, $this->anystores_limitDistance ? $this->anystores_maxDistance : null);
}
if (!$objStore) {
$this->Template->error = $GLOBALS['TL_LANG']['anystores']['noResults'];
return;
}
while ($objStore->next()) {
$objTemplate = new \Contao\FrontendTemplate($this->anystores_detailTpl);
// generate jump to
if ($this->jumpTo) {
if (($objLocation = \PageModel::findByPk($this->jumpTo)) !== null) {
//@todo language parameter
$strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
$strStoreValue = $objStore->alias;
$objStore->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
}
}
$arrStore = $objStore->current()->loadDetails()->row();
$objTemplate->setData($arrStore);
$arrStores[] = $objTemplate->parse();
$arrRawStores[] = $arrStore;
}
$this->Template->stores = $arrStores;
$this->Template->rawstores = $arrRawStores;
// set licence hint
$this->Template->licence = $GLOBALS['ANYSTORES_GEODATA_LICENCE_HINT'];
}
示例15: compile
protected function compile()
{
$this->Template->formId = $this->strFormId;
$arrFieldDcas = array('email' => array('label' => &$GLOBALS['TL_LANG']['tl_module']['email'], 'inputType' => 'text', 'eval' => array('rgxp' => 'email', 'mandatory' => true)), 'submit' => array('inputType' => 'submit', 'label' => &$GLOBALS['TL_LANG']['MSC']['cancel']));
$arrWidgets = array();
foreach ($arrFieldDcas as $strName => $arrData) {
if ($strClass = $GLOBALS['TL_FFL'][$arrData['inputType']]) {
$arrWidgets[] = new $strClass(\Widget::getAttributesFromDca($arrData, $strName));
}
}
if (\Input::post('FORM_SUBMIT') == $this->strFormId) {
// validate
foreach ($arrWidgets as $objWidget) {
$objWidget->validate();
if ($objWidget->hasErrors()) {
$this->blnDoNotSubmit = true;
}
}
if (!$this->blnDoNotSubmit) {
// cancel subscription
$strEmail = \Input::post('email');
$arrArchives = deserialize($this->iso_cancellationArchives, true);
$blnNoSuccess = false;
foreach ($arrArchives as $intArchive) {
if (($objSubscription = Subscription::findBy(array('email=?', 'pid=?'), array($strEmail, $intArchive))) === null) {
if (count($arrArchives) == 1) {
$this->Template->error = sprintf($GLOBALS['TL_LANG']['MSC']['iso_subscriptionDoesNotExist'], $strEmail, SubscriptionArchive::findByPk($intArchive)->title);
$blnNoSuccess = true;
}
break;
}
$objSubscription->delete();
}
if (!$blnNoSuccess) {
// success message
if (count($arrArchives) > 1) {
$this->Template->success = $GLOBALS['TL_LANG']['MSC']['iso_subscriptionsCancelledSuccessfully'];
} else {
$this->Template->success = sprintf($GLOBALS['TL_LANG']['MSC']['iso_subscriptionCancelledSuccessfully'], $strEmail, SubscriptionArchive::findByPk($arrArchives[0])->title);
}
// redirect
if ($this->jumpTo && ($objPageRedirect = \PageModel::findByPk($this->jumpTo)) !== null) {
\Controller::redirect(\Controller::generateFrontendUrl($objPageRedirect->row()));
}
}
}
}
// parse (validated) widgets
$this->Template->fields = implode('', array_map(function ($objWidget) {
return $objWidget->parse();
}, $arrWidgets));
}