예제 #1
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * @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;
 }
 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
0
 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];
     }
 }
 /**
  * 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;
 }
 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());
 }
 /**
  * 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);
 }
 /**
  * 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());
 }
 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;
 }
 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
0
 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;
 }
 /**
  * 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
0
 /**
  * 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'];
 }
 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));
 }
 public function generateEditActions(WatchlistItemModel $objItem, Watchlist $objWatchlist)
 {
     $objPage = \PageModel::findByPk($objItem->pageID);
     if ($objPage === null) {
         return;
     }
     $objT = new \FrontendTemplate('watchlist_edit_actions');
     $objT->delHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_DELETE . '&id=' . \String::binToUuid($objItem->uuid) . '&title=' . urlencode($objItem->title));
     $objT->delTitle = $GLOBALS['TL_LANG']['WATCHLIST']['delTitle'];
     $objT->delLink = $GLOBALS['TL_LANG']['WATCHLIST']['delLink'];
     $objT->id = \String::binToUuid($objItem->uuid);
     return $objT->parse();
 }
예제 #17
0
 public function testBindModelDefaultValues()
 {
     $objInstance = new Form('someid', 'POST', function () {
         return false;
     });
     $objModel = \PageModel::findByPk(13);
     $objInstance->bindModel($objModel);
     $objInstance->addFormField('id', array('inputType' => 'text'))->addFormField('pageTitle', array('inputType' => 'text'))->addFormField('jumpTo', array('inputType' => 'text'));
     $objInstance->createWidgets();
     $this->assertEquals(13, $objInstance->getWidget('id')->value);
     $this->assertEquals('My page', $objInstance->getWidget('pageTitle')->value);
     $this->assertEquals(11, $objInstance->getWidget('jumpTo')->value);
 }
예제 #18
0
 /**
  * Save the MultiDns entries comma delimited in the database
  *
  * @param string         $varValue The entries MCW formatted as serialized string
  * @param \DataContainer $dc
  *
  * @return string
  */
 public function saveMultiDns($varValue, $dc)
 {
     $varValue = deserialize($varValue, true);
     $varValue = implode(',', array_map(function ($entry) {
         return $entry['dns'];
     }, $varValue));
     /** @type \Model $objModel */
     $objModel = \PageModel::findByPk($dc->id);
     $objModel->dns = $varValue;
     $objModel->save();
     // Return empty string as we don't want to save native
     return '';
 }
예제 #19
0
 /**
  * Generate module
  */
 protected function compile()
 {
     $GLOBALS['TL_JAVASCRIPT']['googleapis-maps'] = 'https://maps.googleapis.com/maps/api/js?sensor=false&amp;language=' . $GLOBALS['TL_LANGUAGE'];
     $GLOBALS['TL_JAVASCRIPT']['markerclusterer'] = 'system/modules/anyStores/assets/js/markerclusterer.js';
     // get published stores from categories
     $objStores = AnyStoresModel::findPublishedByCategory(deserialize($this->anystores_categories));
     // return if no stores found
     if (!$objStores) {
         return;
     }
     // generate entries
     while ($objStores->next()) {
         // generate jump to
         //@todo copy do AnyStoresModule and extends from it
         if ($this->jumpTo) {
             if (($objLocation = \PageModel::findByPk($this->jumpTo)) !== null) {
                 //@todo language parameter
                 $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
                 $strStoreValue = $objStores->alias;
                 $objStores->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
             }
         }
         // unset logo because json_encode drops error:
         // Malformed UTF-8 characters, possibly incorrectly encoded
         //@todo maybe ->loadDetails() fix it
         $objStores->logo = null;
         // encode email
         $objStores->email = \String::encodeEmail($objStores->email);
     }
     // get all stores
     $arrStores = $objStores->fetchAll();
     $this->Template->entries = $arrStores;
     if (!($strJson = json_encode($arrStores))) {
         $this->log(json_last_error_msg(), __METHOD__, TL_ERROR);
         //@todo stop display the broken module
         return;
     }
     // Temporär
     $this->Template->json = $strJson;
     //@todo cleanup
     $path = 'system/modules/anyStores/html/' . $this->id . '-locations.json';
     $this->Template->path = $path;
     //JSON schreiben
     //@todo: Muss noch in tl_storelocator_map zum save_callback verschoben werden!!!
     #$file   =   new \File($path);
     #$file->write($strJson);
     //@todo language
     #$this->log('Neue JSON-Datei erstellt', __METHOD__, TL_FILES);
 }
예제 #20
0
 /**
  * Test if page id or alias is in path.
  *
  * Function: i18nPageInPath(..)
  *
  * @param mixed $pageIdOrAlias Page id or alias.
  *
  * @return bool
  */
 public static function i18nPageInPath($pageIdOrAlias)
 {
     $page = static::getCurrentPage();
     $pageId = static::getTranslatedPage($pageIdOrAlias)->id;
     while (true) {
         if ($pageId == $page->id) {
             return true;
         }
         if ($page->pid < 1) {
             return false;
         }
         $page = \PageModel::findByPk($page->pid);
     }
     return false;
 }
예제 #21
0
 /**
  * {@inheritdoc}
  */
 protected function compile()
 {
     $repository = EntityHelper::getRepository('Avisota\\Contao:Message');
     $queryBuilder = $repository->createQueryBuilder('m');
     $expr = $queryBuilder->expr();
     $queryBuilder->innerJoin('m.category', 'c')->where($expr->in('c.id', ':categories'))->andWhere($expr->gt('m.sendOn', 0))->orderBy('m.sendOn', 'DESC')->setParameter('categories', deserialize($this->avisota_message_categories, true));
     $query = $queryBuilder->getQuery();
     $messages = $query->getResult();
     $jumpTo = \PageModel::findByPk($this->jumpTo);
     if (!$jumpTo) {
         $jumpTo = $GLOBALS['objPage'];
     }
     $this->Template->messages = $messages;
     $this->Template->jumpTo = $jumpTo->row();
 }
예제 #22
0
 /**
  * Parse an item and return it as string
  * @param object
  * @param string
  * @param integer
  * @return string
  */
 protected function parseRecipe($objRecipe, $strClass = '', $intCount = 0)
 {
     global $objPage;
     $objTemplate = new \FrontendTemplate($this->item_template);
     $objTemplate->setData($objRecipe->row());
     $objTemplate->class = ($objRecipe->cssClass != '' ? ' ' . $objRecipe->cssClass : '') . $strClass;
     // $objTemplate->distance = $this->getCurrentOpenStatus($objRecipe);
     //Detail-Url
     if ($this->jumpTo) {
         $objDetailPage = \PageModel::findByPk($this->jumpTo);
         $objTemplate->detailUrl = ampersand($this->generateFrontendUrl($objDetailPage->row(), '/' . $objRecipe->alias));
         $objTemplate->teaser = \String::substr($objRecipe->preparation, 100);
     }
     return $objTemplate->parse();
 }
 public function createItem(CreateItemEvent $event)
 {
     $item = $event->getItem();
     if ($item->getType() == 'article') {
         $article = \ArticleModel::findByPk($item->getName());
         if ($article) {
             $page = \PageModel::findByPk($article->pid);
             if ($page) {
                 $cssID = deserialize($article->cssID, true);
                 $item->setUri(\Frontend::generateFrontendUrl($page->row()) . '#' . (empty($cssID[0]) ? $article->alias : $cssID[0]));
                 $item->setLabel($article->title);
                 $item->setExtras($article->row());
             }
         }
     }
 }
 /**
  * Get the target page
  *
  * @return \PageModel|null
  */
 public function getTargetPage()
 {
     $pageId = $this->jumpTo;
     // Inherit the page from parent if there is none set
     if (!$pageId) {
         $pid = $this->pid;
         do {
             $parent = static::findByPk($pid);
             if ($parent !== null) {
                 $pid = $parent->pid;
                 $pageId = $parent->jumpTo;
             }
         } while ($pid && !$pageId);
     }
     return \PageModel::findByPk($pageId);
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->emptyAirQuality = $GLOBALS['TL_LANG']['MSC']['emptyAirQuality'];
     // 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');
         }
     }
     $parameters = deserialize($this->airquality_parameters);
     $objAirQualityCity = \AirQualityCityModel::findById($this->airquality_city);
     $this->Template->city = $objAirQualityCity->title;
     $this->Template->source = $objAirQualityCity->source;
     $this->Template->date = \Date::parse('l j F');
     $this->Template->link = strlen($strLink) ? sprintf($strLink, $objAirQualityCity->alias) : '';
     $objAirQualityStaions = \AirQualityStationModel::findByPid($this->airquality_city);
     // No stations found
     if ($objAirQualityStaions === null) {
         retuen;
     }
     $arrAirQuality = array();
     $arrCityMaxAQI = array(parameter => '', value => 0, color => '', level => '');
     foreach ($objAirQualityStaions as $objStation) {
         $objAirQualityData = \AirQualityDataModel::findByPidAndToday($objStation->id);
         if ($objAirQualityData !== null) {
             $aqis = deserialize($objAirQualityData->AQI_ALL);
             $maxaqi = deserialize($objAirQualityData->AQI_MAX);
             $arrAirQuality = array('station' => $objStation->title, 'date' => \Date::parse('l j F', $objAirQualityData->date), 'aqi' => $aqis, 'maxaqi' => $maxaqi);
             $objTemplate = new \FrontendTemplate($this->chartTemplate);
             $size = deserialize($this->chartSize);
             $objTemplate->width = $size[0];
             $objTemplate->height = $size[1];
             $objTemplate->title = $objStation->title;
             $objTemplate->alias = $objStation->alias;
             $objTemplate->id = uniqid('chart_');
             $objTemplate->labels = '"PM2.5","PM10","CO","NO2","SO2","O3"';
             $objTemplate->data = $arrAirQuality;
             $arrAirQualityCharts[] = $objTemplate->parse();
             if ($arrCityMaxAQI[value] < $maxaqi[value]) {
                 $arrCityMaxAQI = $maxaqi;
             }
         }
         $this->Template->citymaxaqi = $arrCityMaxAQI;
         $this->Template->airqualitycharts = $arrAirQualityCharts;
     }
 }
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ISOTOPE ECOMMERCE: CART LINK ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->objTarget = \PageModel::findByPk($this->jumpTo);
     if ($this->objTarget === null) {
         return '';
     }
     return parent::generate();
 }
예제 #27
0
 /**
  * Prepare URL from ID and keep query string from current string
  * @param   mixed
  * @return  string
  */
 protected static function prepareUrl($varUrl)
 {
     if ($varUrl === null) {
         $varUrl = \Environment::get('request');
     } elseif (is_numeric($varUrl)) {
         if (($objJump = \PageModel::findByPk($varUrl)) === null) {
             throw new \InvalidArgumentException('Given page id does not exist.');
         }
         $varUrl = \Controller::generateFrontendUrl($objJump->row());
         list(, $strQueryString) = explode('?', \Environment::get('request'), 2);
         if ($strQueryString != '') {
             $varUrl .= '?' . $strQueryString;
         }
     }
     $varUrl = ampersand($varUrl, false);
     return $varUrl;
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     // unique form id
     $strFormId = 'anystores_search_' . $this->id;
     // localize url parameter keys
     $strSearchKey = $GLOBALS['TL_LANG']['anystores']['url_params']['search'] ?: 'search';
     $strSearchValue = \Input::post($strSearchKey);
     $strCountryKey = $GLOBALS['TL_LANG']['anystores']['url_params']['country'] ?: 'country';
     $strCountryValue = \Input::post($strCountryKey);
     // redirect if form was send
     if (\Input::post('FORM_SUBMIT') == $strFormId && ($this->anystores_allowEmptySearch || !empty($strSearchValue))) {
         $intPageId = $this->jumpTo ?: $GLOBALS['objPage']->id;
         $objPage = \PageModel::findByPk($intPageId);
         if ($objPage) {
             /**
              * Build url
              * @example /search/_term_/country/_de_
              */
             $strPageUrl = $this->generateFrontendUrl($objPage->row(), "/{$strSearchKey}/" . $this->encodeSearchValue($strSearchValue) . "/{$strCountryKey}/" . $strCountryValue);
             $this->redirect($strPageUrl, 302);
         }
         $this->log("Can't find redirect page in module ID {$this->id}", __METHOD__, TL_ERROR);
     }
     // render countries for the dropdown
     if (($objCountries = AnyStoresModel::findAllPublished()) !== null) {
         $arrCountries = array_unique($objCountries->fetchEach('country'));
         $arrCountryNames = \System::getCountries();
         foreach ($arrCountries as $country) {
             $arrCountryOptions[$country] = $arrCountryNames[$country];
         }
         asort($arrCountryOptions);
         $this->Template->countryOptions = $arrCountryOptions;
     }
     $this->Template->formId = $strFormId;
     $this->Template->formAction = \Environment::get('indexFreeRequest');
     $this->Template->searchName = $strSearchKey;
     $this->Template->searchId = 'ctrl_search_' . $this->id;
     $this->Template->searchValue = \Input::get($strSearchKey);
     $this->Template->countryName = $strCountryKey;
     $this->Template->countryId = 'ctrl_country_' . $this->id;
     $this->Template->countryValue = \Input::get($strCountryKey) ?: $GLOBALS['TL_LANGUAGE'];
 }
예제 #29
0
 /**
  * @param Database_Result $objPage
  * @param Database_Result $objLayout
  * @param PageRegular $objPageRegular
  */
 public function login($objPage, $objLayout, $objPageRegular)
 {
     $time = time();
     $objMember = \Database::getInstance()->prepare("SELECT * FROM tl_member WHERE loginLink = ? AND (loginLinkExpire > ? OR loginLinkExpire = '')")->execute($this->authKey, $time);
     $objMemberModel = \MemberModel::findById($objMember->id);
     if ($objMember->numRows != 1 || $objMember->loginLink != $this->authKey) {
         return;
     }
     if (!FE_USER_LOGGED_IN) {
         // Generate the cookie hash
         $this->strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH');
         // Clean up old sessions
         \Database::getInstance()->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $this->strHash);
         // Save the session in the database
         \Database::getInstance()->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objMember->id, $time, 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $this->strHash);
         // Set the authentication cookie
         \System::setCookie('FE_USER_AUTH', $this->strHash, $time + \Config::get('sessionTimeout'), null, null, false, true);
         // Set the login status (backwards compatibility)
         $_SESSION['TL_USER_LOGGED_IN'] = true;
         // Save the login status
         $_SESSION['TL_USER_LOGGED_IN'] = true;
         \System::log('User "' . $objMember->username . '" logged in by authKey', 'LoginLink()', TL_ACCESS);
         \Controller::reload();
     }
     if ($objMember->jumpTo) {
         $objPage = \PageModel::findByPk($objMember->jumpTo);
     }
     $strUrl = \Controller::generateFrontendUrl($objPage->row());
     $strParam = '';
     foreach ($_GET as $index => $value) {
         if ($index == 'key') {
             continue;
         }
         if (!$strParam) {
             $strParam .= '?' . $index . '=' . \Input::get($index);
         } else {
             $strParam .= '&' . $index . '=' . \Input::get($index);
         }
     }
     \Controller::redirect($strUrl . $strParam);
 }
예제 #30
0
 public static function getPageIdFromUrlHook($arrFragments)
 {
     $objParticipation = ParticipationModel::findPublishedByAlias(\Environment::get('request'));
     if ($objParticipation !== null) {
         $blnAddParticipation = true;
         // only one participation per alias is supported yet
         if ($objParticipation instanceof \Model\Collection) {
             $objParticipation = $objParticipation->current();
         }
         $objArchive = $objParticipation->getRelated('pid');
         if ($objArchive === null) {
             $blnAddParticipation = false;
         }
         // check if current page is in defined root
         if ($objArchive->defineRoot && $objArchive->rootPage > 0) {
             $objCurrentRootPage = \Frontend::getRootPageFromUrl();
             $objRootPage = \PageModel::findByPk($objArchive->rootPage);
             if ($objRootPage !== null && $objCurrentRootPage !== null) {
                 if ($objRootPage->domain != $objCurrentRootPage->domain) {
                     $blnAddParticipation = false;
                     ParticipationController::removeActiveParticipation();
                 }
             }
         }
         if ($blnAddParticipation) {
             ParticipationController::setActiveParticipation($objParticipation);
             if ($objArchive->addInfoMessage && $objArchive->infoMessageWith !== '') {
                 ParticipationMessage::addInfo(\String::parseSimpleTokens($objArchive->infoMessageWith, array('participation' => ParticipationController::getParticipationLabel($objParticipation, '', true))), PARTICIPATION_MESSAGEKEY_ACTIVE);
             }
         }
         if (($objConfig = ParticipationController::findParticipationDataConfigClass($objParticipation)) !== null) {
             global $objPage;
             $objJumpTo = $objConfig->getJumpToPage();
             // redirect first, otherwise participation process will run twice
             if ($objJumpTo !== null && $objPage->id != $objJumpTo->id) {
                 \Controller::redirect(\Controller::generateFrontendUrl($objJumpTo->row()));
             }
         }
     }
     return $arrFragments;
 }