/** * Generate the module */ protected function compile() { global $objPage; $arrJumpTo = array(); $arrNewsletter = array(); $strRequest = ampersand(\Environment::get('request'), true); $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels); if ($objNewsletter !== null) { while ($objNewsletter->next()) { if (($objTarget = $objNewsletter->getRelated('pid')) === null) { continue; } $jumpTo = intval($objTarget->jumpTo); // A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module if ($jumpTo < 1) { throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list"); } $strUrl = $strRequest; if (!isset($arrJumpTo[$objTarget->jumpTo])) { $objJumpTo = $objTarget->getRelated('jumpTo')->loadDetails(); if ($objJumpTo !== null) { $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s'); } else { $arrJumpTo[$objTarget->jumpTo] = $strUrl; } } $strUrl = $arrJumpTo[$objTarget->jumpTo]; $strAlias = $objNewsletter->alias != '' && !\Config::get('disableAlias') ? $objNewsletter->alias : $objNewsletter->id; $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => \Date::parse($objPage->dateFormat, $objNewsletter->date), 'datim' => \Date::parse($objPage->datimFormat, $objNewsletter->date), 'time' => \Date::parse($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel); } } $this->Template->newsletters = $arrNewsletter; }
/** * Generate the module */ protected function compile() { global $objPage; $arrJumpTo = array(); $arrNewsletter = array(); $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels); if ($objNewsletter !== null) { while ($objNewsletter->next()) { if (($objTarget = $objNewsletter->getRelated('pid')) === null || !$objTarget->jumpTo) { continue; } if (!isset($arrJumpTo[$objTarget->jumpTo])) { $objJumpTo = \PageModel::findPublishedById($objTarget->jumpTo); if ($objJumpTo !== null) { $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s'); } else { $arrJumpTo[$objTarget->jumpTo] = null; } } $strUrl = $arrJumpTo[$objTarget->jumpTo]; if ($strUrl === null) { continue; } $strAlias = $objNewsletter->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objNewsletter->alias : $objNewsletter->id; $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => $this->parseDate($objPage->dateFormat, $objNewsletter->date), 'datim' => $this->parseDate($objPage->datimFormat, $objNewsletter->date), 'time' => $this->parseDate($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel); } } $this->Template->newsletters = $arrNewsletter; }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->products = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $this->Template->relateds_headline = $GLOBALS['TL_LANG']['MSC']['relateds_headline']; $objProduct = \ProductModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->catalogs); if (null === $objProduct) { /** @var \PageError404 $objHandler */ $objHandler = new $GLOBALS['TL_PTY']['error_404'](); $objHandler->generate($objPage->id); } // Overwrite the page title if ($objProduct->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objProduct->title)); } // Overwrite the page description if ($objProduct->description != '') { $objPage->description = $this->prepareMetaDescription($objProduct->description); } $arrProduct = $this->parseProduct($objProduct); $this->Template->product = $arrProduct; $objProduct->related = deserialize($objProduct->related); if (!empty($objProduct->related)) { $objProducts = \ProductModel::findPublishedByIds($objProduct->related); $this->Template->relateds = $this->parseRelateds($objProducts); } }
protected function compile() { global $objPage; $this->Controller = new MemberPlus($this->objModel); $this->Template->members = ''; // Get the member item $objMember = MemberPlusMemberModel::findActiveByParentAndIdOrAlias(\Input::get('items'), $this->mlGroups); if ($objMember === null) { // Do not index or cache the page $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); $this->Template->members = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>'; return; } $strMember = $this->Controller->parseMember($objMember); $this->Template->members = $strMember; $strCombinedTitle = $this->Controller->getCombinedTitle($objMember); // Overwrite the page title (see #2853 and #4955) if ($strCombinedTitle != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($strCombinedTitle)); } // Overwrite the page description // if ($objArticle->teaser != '') // { // $objPage->description = $this->prepareMetaDescription($objArticle->teaser); // } }
/** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; $this->Template->content = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels); if (null === $objNewsletter) { throw new PageNotFoundException('Page not found'); } // Overwrite the page title (see #2853 and #4955) if ($objNewsletter->subject != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject)); } // Add enclosure if ($objNewsletter->addFile) { $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files'); } // Support plain text newsletters (thanks to Hagen Klemp) if ($objNewsletter->sendText) { $strContent = nl2br_html5($objNewsletter->text); } else { $strContent = str_ireplace(' align="center"', '', $objNewsletter->content); } // Parse simple tokens and insert tags $strContent = $this->replaceInsertTags($strContent); $strContent = \StringUtil::parseSimpleTokens($strContent, array()); // Encode e-mail addresses $strContent = \StringUtil::encodeEmail($strContent); $this->Template->content = $strContent; $this->Template->subject = $objNewsletter->subject; }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->content = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; if (TL_MODE == 'FE' && BE_USER_LOGGED_IN) { $objNewsletter = \NewsletterModel::findByIdOrAlias(\Input::get('items')); } else { $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels); } if ($objNewsletter === null) { // Do not index or cache the page $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); $this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>'; return; } // Overwrite the page title (see #2853 and #4955) if ($objNewsletter->subject != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject)); } // Add enclosure if ($objNewsletter->addFile) { $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files'); } if (!$objNewsletter->sendText) { $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5'; $strContent = ''; $objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter'); if ($objContentElements !== null) { if (!defined('NEWSLETTER_CONTENT_PREVIEW')) { define('NEWSLETTER_CONTENT_PREVIEW', true); } foreach ($objContentElements as $objContentElement) { $strContent .= $this->getContentElement($objContentElement->id); } } // Parse simple tokens and insert tags $strContent = $this->replaceInsertTags($strContent); $strContent = \String::parseSimpleTokens($strContent, array()); // Encode e-mail addresses $strContent = \String::encodeEmail($strContent); $this->Template->content = $strContent; } else { $strContent = str_ireplace(' align="center"', '', $objNewsletter->content); } // Convert relative URLs $strContent = $this->convertRelativeUrls($strContent); // Parse simple tokens and insert tags $strContent = $this->replaceInsertTags($strContent); $strContent = \String::parseSimpleTokens($strContent, array()); // Encode e-mail addresses $strContent = \String::encodeEmail($strContent); $this->Template->content = $strContent; $this->Template->subject = $objNewsletter->subject; }
/** * Generate the module */ protected function compile() { // Get all active pages $objPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages); // Return if there are no pages if ($objPages === null) { return; } $arrPages = array(); // Sort the array keys according to the given order if ($this->orderPages != '') { $tmp = deserialize($this->orderPages); if (!empty($tmp) && is_array($tmp)) { $arrPages = array_map(function () { }, array_flip($tmp)); } } // Add the items to the pre-sorted array while ($objPages->next()) { /** @var PageModel $objModel */ $objModel = $objPages->current(); $arrPages[$objPages->id] = $objModel->loadDetails()->row(); // see #3765 } $items = array(); foreach ($arrPages as $arrPage) { $arrPage['title'] = strip_insert_tags($arrPage['title']); $arrPage['pageTitle'] = strip_insert_tags($arrPage['pageTitle']); // Get href switch ($arrPage['type']) { case 'redirect': $href = $arrPage['url']; break; case 'forward': if (($objNext = \PageModel::findPublishedById($arrPage['jumpTo'])) !== null) { $strForceLang = null; $objNext->loadDetails(); // Check the target page language (see #4706) if (\Config::get('addLanguageToUrl')) { $strForceLang = $objNext->language; } $href = $this->generateFrontendUrl($objNext->row(), null, $strForceLang, true); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $this->generateFrontendUrl($arrPage, null, $arrPage['rootLanguage'], true); break; } $items[] = array('href' => $href, 'title' => specialchars($arrPage['pageTitle'] ?: $arrPage['title']), 'link' => $arrPage['title']); } $this->Template->items = $items; $this->Template->formId = 'tl_quicklink_' . $this->id; $this->Template->request = ampersand(\Environment::get('request'), true); $this->Template->title = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['quicklink']; $this->Template->button = specialchars($GLOBALS['TL_LANG']['MSC']['go']); }
public function saveCookieName($strString, $ObjDataContainer) { $arrSearch = array('/[^a-zA-Z0-9 _-]+/', '/ +/', '/\\-+/'); $arrReplace = array('', '-', '-'); $strString = html_entity_decode($strString, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); $strString = strip_insert_tags($strString); $strString = utf8_romanize($strString); $strString = preg_replace($arrSearch, $arrReplace, $strString); return trim($strString, '-'); }
/** * Run the test * * @param array $data * @param string $table * * @throws ErrorException * @throws WarningException */ private function check($value) { $value = strip_tags(strip_insert_tags($value)); // The description does not exist if (!$value) { throw new ErrorException($GLOBALS['TL_LANG']['SST']['test.description']['empty']); } // The description is too long if (utf8_strlen($value) > self::MAX_LENGTH) { throw new WarningException(sprintf($GLOBALS['TL_LANG']['SST']['test.description']['length'], self::MAX_LENGTH)); } }
/** * Slugify a value. * * @param string $value Given value. * @param string $separator Separator string. * * @return string */ private function slugify($value, $separator) { $arrSearch = array('/[^a-zA-Z0-9 \\.\\&\\/_-]+/', '/[ \\.\\&\\/-]+/'); $arrReplace = array('', $separator); $value = html_entity_decode($value, ENT_QUOTES, $this->charset); $value = strip_insert_tags($value); $value = utf8_romanize($value); $value = preg_replace($arrSearch, $arrReplace, $value); if (!$this->preserveUppercase) { $value = strtolower($value); } return trim($value, $separator); }
/** * Generate the module */ protected function compile() { // Get all active pages $objPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages); // Return if there are no pages if ($objPages === null) { return; } $arrPages = array(); // Sort the array keys according to the given order if ($this->orderPages != '') { $tmp = deserialize($this->orderPages); if (!empty($tmp) && is_array($tmp)) { $arrPages = array_map(function () { }, array_flip($tmp)); } } $arrPages = array_values(array_filter($arrPages)); // Add the items to the pre-sorted array while ($objPages->next()) { $arrPages[$objPages->id] = $objPages->current(); } $items = array(); /** @var \PageModel[] $arrPages */ foreach ($arrPages as $objPage) { $objPage->title = strip_insert_tags($objPage->title); $objPage->pageTitle = strip_insert_tags($objPage->pageTitle); // Get href switch ($objPage->type) { case 'redirect': $href = $objPage->url; break; case 'forward': if (($objNext = $objPage->getRelated('jumpTo')) !== null) { /** @var \PageModel $objNext */ $href = $objNext->getFrontendUrl(); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $objPage->getFrontendUrl(); break; } $items[] = array('href' => $href, 'title' => specialchars($objPage->pageTitle ?: $objPage->title), 'link' => $objPage->title); } $this->Template->items = $items; $this->Template->request = ampersand(\Environment::get('request'), true); $this->Template->title = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['quicklink']; $this->Template->button = specialchars($GLOBALS['TL_LANG']['MSC']['go']); }
/** * Standardize a parameter (strip special characters and convert spaces) * * @param string $strString * @param boolean $blnPreserveUppercase * * @return string */ function standardize($strString, $blnPreserveUppercase = false) { $arrSearch = array('/[^a-zA-Z0-9 \\.\\&\\/_-]+/', '/[ \\.\\&\\/-]+/'); $arrReplace = array('', '-'); $strString = html_entity_decode($strString, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); $strString = strip_insert_tags($strString); $strString = utf8_romanize($strString); $strString = preg_replace($arrSearch, $arrReplace, $strString); if (is_numeric(substr($strString, 0, 1))) { $strString = 'id-' . $strString; } if (!$blnPreserveUppercase) { $strString = strtolower($strString); } return trim($strString, '-'); }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->carpets = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $objCarpet = \CarpetModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->carpet_categories); // Overwrite the page title if ($objCarpet->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objCarpet->title)); } // Overwrite the page description if ($objCarpet->description != '') { $objPage->description = $this->prepareMetaDescription($objCarpet->description); } $arrCarpet = $this->parseCarpet($objCarpet); $this->Template->carpets = $arrCarpet; }
/** * Generate the module */ protected function compile() { // Get all active pages $arrPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages)->getData(); if (empty($arrPages)) { return; } $items = array(); foreach ($arrPages as $arrPage) { $arrPage['title'] = strip_insert_tags($arrPage['title']); $arrPage['pageTitle'] = strip_insert_tags($arrPage['pageTitle']); $items[] = array('href' => $this->generateFrontendUrl($arrPage), 'title' => specialchars($arrPage['pageTitle'] ?: $arrPage['title']), 'link' => $arrPage['title']); } $this->Template->items = $items; $this->Template->request = ampersand(\Environment::get('request'), true); $this->Template->title = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['quicklink']; $this->Template->button = specialchars($GLOBALS['TL_LANG']['MSC']['go']); }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->employee = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $objEmployee = \StaffEmployeeModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->staff_categories); // Overwrite the page title if ($objEmployee->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objEmployee->firstname . ' ' . $objEmployee->lastname)); } // Overwrite the page description if ($objEmployee->description != '') { $objPage->description = $this->prepareMetaDescription($objEmployee->description); } $arrEmployee = $this->parseEmployee($objEmployee); $this->Template->employee = $arrEmployee; }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->albums = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $objAlbum = \PhotogalleryAlbumModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->photogalleries); // Overwrite the page title if ($objAlbum->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objAlbum->title)); } // Overwrite the page description if ($objProduct->description != '') { $objPage->description = $this->prepareMetaDescription($objAlbum->description); } $arrAlbum = $this->parseAlbumFull($objAlbum); $this->Template->albums = $arrAlbum; }
/** * Generate the content element */ protected function compile() { $objProduct = IsotopeFrontend::getProductByAlias($this->iso_product, IsotopeFrontend::getReaderPageId()); if (!$objProduct) { $this->Template = new FrontendTemplate('mod_message'); $this->Template->type = 'empty'; $this->Template->message = $GLOBALS['TL_LANG']['MSC']['invalidProductInformation']; return; } $this->Template->product = $objProduct->generate(strlen($this->iso_product_template) ? $this->iso_product_template : $objProduct->reader_template, $this); $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; if ($this->iso_overwrite_page_meta) { global $objPage; $objPage->pageTitle = strip_insert_tags($objProduct->name); $objPage->description = $this->prepareMetaDescription($objProduct->description_meta); } $GLOBALS['TL_KEYWORDS'] .= (strlen($GLOBALS['TL_KEYWORDS']) ? ', ' : '') . $objProduct->keywords_meta; }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->product = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $this->Template->txt_types = $GLOBALS['TL_LANG']['MSC']['txt_types']; $this->Template->txt_pieces = $GLOBALS['TL_LANG']['MSC']['txt_pieces']; $this->Template->txt_relateds = $GLOBALS['TL_LANG']['MSC']['txt_relateds']; // Generate products $objKitchenwareProduct = \KitchenwareProductModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->kitchenware_categories); $arrKitchenwareProduct = $this->parseProduct($objKitchenwareProduct); $objPage->pageTitle = strip_tags(strip_insert_tags($objKitchenwareProduct->title)); $objPage->description = strip_tags(strip_insert_tags($objKitchenwareProduct->meta_description)); $this->Template->product = $arrKitchenwareProduct; // Generate pieces if ($this->kitchenware_piece_show) { $objKitchenwarePieces = \KitchenwarePieceModel::findPublishedByPid($objKitchenwareProduct->id); if ($objKitchenwarePieces !== null) { $this->Template->pieces = $this->parsePieces($objKitchenwarePieces); } } // Generate types if ($this->kitchenware_type_show) { $objKitchenwareTypes = \KitchenwareTypeModel::findPublishedByPid($objKitchenwareProduct->id); if ($objKitchenwareTypes !== null) { $this->Template->types = $this->parseTypes($objKitchenwareTypes); } } // Generate relateds if ($this->kitchenware_related_show and $objKitchenwareProduct->related) { $this->relateds = deserialize($objKitchenwareProduct->related); $objKitchenwareRelateds = \KitchenwareProductModel::findPublishedByIds($this->relateds); if ($objKitchenwareRelateds !== null) { $this->Template->relateds = $this->parseRelateds($objKitchenwareRelateds); } } }
/** * Generate the module */ protected function compile() { /** @var \PageModel $objPage */ global $objPage; $this->Template->articles = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; // Get the news item $objArticle = \NewsModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->news_archives); if (null === $objArticle) { /** @var \PageError404 $objHandler */ $objHandler = new $GLOBALS['TL_PTY']['error_404'](); $objHandler->generate($objPage->id); } $arrArticle = $this->parseArticle($objArticle); $this->Template->articles = $arrArticle; // Overwrite the page title (see #2853 and #4955) if ($objArticle->headline != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objArticle->headline)); } // Overwrite the page description if ($objArticle->teaser != '') { $objPage->description = $this->prepareMetaDescription($objArticle->teaser); } // HOOK: comments extension required if ($objArticle->noComments || !in_array('comments', \ModuleLoader::getActive())) { $this->Template->allowComments = false; return; } /** @var \NewsArchiveModel $objArchive */ $objArchive = $objArticle->getRelated('pid'); $this->Template->allowComments = $objArchive->allowComments; // Comments are not allowed if (!$objArchive->allowComments) { return; } // Adjust the comments headline level $intHl = min(intval(str_replace('h', '', $this->hl)), 5); $this->Template->hlc = 'h' . ($intHl + 1); $this->import('Comments'); $arrNotifies = array(); // Notify the system administrator if ($objArchive->notify != 'notify_author') { $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL']; } // Notify the author if ($objArchive->notify != 'notify_admin') { /** @var \UserModel $objAuthor */ if (($objAuthor = $objArticle->getRelated('author')) !== null && $objAuthor->email != '') { $arrNotifies[] = $objAuthor->email; } } $objConfig = new \stdClass(); $objConfig->perPage = $objArchive->perPage; $objConfig->order = $objArchive->sortOrder; $objConfig->template = $this->com_template; $objConfig->requireLogin = $objArchive->requireLogin; $objConfig->disableCaptcha = $objArchive->disableCaptcha; $objConfig->bbcode = $objArchive->bbcode; $objConfig->moderate = $objArchive->moderate; $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_news', $objArticle->id, $arrNotifies); }
/** * Recursively get all quicknav pages and return them as array * * @param integer $pid * @param integer $level * @param string $host * @param string $language * * @return array */ protected function getQuicknavPages($pid, $level = 1, $host = null, $language = null) { /** @var \PageModel $objPage */ global $objPage; $groups = array(); $arrPages = array(); // Get all groups of the current front end user if (FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); $groups = $this->User->groups; } // Get all active subpages $objSubpages = \PageModel::findPublishedRegularWithoutGuestsByPid($pid); if ($objSubpages === null) { return array(); } ++$level; while ($objSubpages->next()) { $_groups = deserialize($objSubpages->groups); // Override the domain (see #3765) if ($host !== null) { $objSubpages->domain = $host; } // Do not show protected pages unless a back end or front end user is logged in if (!$objSubpages->protected || !is_array($_groups) && FE_USER_LOGGED_IN || BE_USER_LOGGED_IN || is_array($_groups) && array_intersect($_groups, $groups) || $this->showProtected) { // Do not skip the current page here! (see #4523) // Check hidden pages if (!$objSubpages->hide || $this->showHidden) { if ($objSubpages->domain != '' && $objSubpages->domain != \Environment::get('host')) { /** @var \PageModel $objModel */ $objModel = $objSubpages->current(); $objModel->loadDetails(); } $href = $this->generateFrontendUrl($objSubpages->row(), null, $language, true); $arrPages[] = array('level' => $level - 2, 'title' => specialchars(strip_insert_tags($objSubpages->pageTitle ?: $objSubpages->title)), 'href' => $href, 'link' => strip_insert_tags($objSubpages->title)); // Subpages if (!$this->showLevel || $this->showLevel >= $level || !$this->hardLimit && ($objPage->id == $objSubpages->id || in_array($objPage->id, $this->Database->getChildRecords($objSubpages->id, 'tl_page')))) { $subpages = $this->getQuicknavPages($objSubpages->id, $level); if (is_array($subpages)) { $arrPages = array_merge($arrPages, $subpages); } } } } } return $arrPages; }
/** * Generate module */ protected function compile() { global $objPage; $this->Template->articles = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $time = time(); // Get news item $objArticle = $this->Database->prepare("SELECT *, author AS authorId, (SELECT title FROM tl_news_archive WHERE tl_news_archive.id=tl_news.pid) AS archive, (SELECT jumpTo FROM tl_news_archive WHERE tl_news_archive.id=tl_news.pid) AS parentJumpTo, (SELECT name FROM tl_user WHERE id=author) AS author FROM tl_news WHERE pid IN(" . implode(',', array_map('intval', $this->news_archives)) . ") AND (id=? OR alias=?)" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<?) AND (stop='' OR stop>?) AND published=1" : ""))->limit(1)->execute(is_numeric($this->Input->get('items')) ? $this->Input->get('items') : 0, $this->Input->get('items'), $time, $time); if ($objArticle->numRows < 1) { $this->Template->articles = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $this->Input->get('items')) . '</p>'; // Do not index the page $objPage->noSearch = 1; $objPage->cache = 0; // Send 404 header header('HTTP/1.1 404 Not Found'); return; } $arrArticle = $this->parseArticles($objArticle); $this->Template->articles = $arrArticle[0]; // Overwrite the page title if ($objArticle->headline != '') { $objPage->pageTitle = strip_insert_tags($objArticle->headline); } // Overwrite the page description if ($objArticle->teaser != '') { $objPage->description = $this->prepareMetaDescription($objArticle->teaser); } // HOOK: comments extension required if ($objArticle->noComments || !in_array('comments', $this->Config->getActiveModules())) { $this->Template->allowComments = false; return; } // Check whether comments are allowed $objArchive = $this->Database->prepare("SELECT * FROM tl_news_archive WHERE id=?")->limit(1)->execute($objArticle->pid); if ($objArchive->numRows < 1 || !$objArchive->allowComments) { $this->Template->allowComments = false; return; } $this->Template->allowComments = true; // Adjust the comments headline level $intHl = min(intval(str_replace('h', '', $this->hl)), 5); $this->Template->hlc = 'h' . ($intHl + 1); $this->import('Comments'); $arrNotifies = array(); // Notify system administrator if ($objArchive->notify != 'notify_author') { $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL']; } // Notify author if ($objArchive->notify != 'notify_admin') { $objAuthor = $this->Database->prepare("SELECT email FROM tl_user WHERE id=?")->limit(1)->execute($objArticle->authorId); if ($objAuthor->numRows) { $arrNotifies[] = $objAuthor->email; } } $objConfig = new stdClass(); $objConfig->perPage = $objArchive->perPage; $objConfig->order = $objArchive->sortOrder; $objConfig->template = $this->com_template; $objConfig->requireLogin = $objArchive->requireLogin; $objConfig->disableCaptcha = $objArchive->disableCaptcha; $objConfig->bbcode = $objArchive->bbcode; $objConfig->moderate = $objArchive->moderate; $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_news', $objArticle->id, $arrNotifies); }
/** * Generate a regular page * * @param \PageModel $objPage * @param boolean $blnCheckRequest */ public function generate($objPage, $blnCheckRequest = false) { $GLOBALS['TL_KEYWORDS'] = ''; $GLOBALS['TL_LANGUAGE'] = $objPage->language; \System::loadLanguageFile('default'); // Static URLs $this->setStaticUrls(); // Get the page layout $objLayout = $this->getPageLayout($objPage); // HOOK: modify the page or layout object (see #4736) if (isset($GLOBALS['TL_HOOKS']['getPageLayout']) && is_array($GLOBALS['TL_HOOKS']['getPageLayout'])) { foreach ($GLOBALS['TL_HOOKS']['getPageLayout'] as $callback) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($objPage, $objLayout, $this); } } /** @var \ThemeModel $objTheme */ $objTheme = $objLayout->getRelated('pid'); // Set the layout template and template group $objPage->template = $objLayout->template ?: 'fe_page'; $objPage->templateGroup = $objTheme->templates; // Store the output format list($strFormat, $strVariant) = explode('_', $objLayout->doctype); $objPage->outputFormat = $strFormat; $objPage->outputVariant = $strVariant; // Initialize the template $this->createTemplate($objPage, $objLayout); // Initialize modules and sections $arrCustomSections = array(); $arrSections = array('header', 'left', 'right', 'main', 'footer'); $arrModules = deserialize($objLayout->modules); $arrModuleIds = array(); // Filter the disabled modules foreach ($arrModules as $module) { if ($module['enable']) { $arrModuleIds[] = $module['mod']; } } // Get all modules in a single DB query $objModules = \ModuleModel::findMultipleByIds($arrModuleIds); if ($objModules !== null || $arrModules[0]['mod'] == 0) { $arrMapper = array(); // Create a mapper array in case a module is included more than once (see #4849) if ($objModules !== null) { while ($objModules->next()) { $arrMapper[$objModules->id] = $objModules->current(); } } foreach ($arrModules as $arrModule) { // Disabled module if (!$arrModule['enable']) { continue; } // Replace the module ID with the module model if ($arrModule['mod'] > 0 && isset($arrMapper[$arrModule['mod']])) { $arrModule['mod'] = $arrMapper[$arrModule['mod']]; } // Generate the modules if (in_array($arrModule['col'], $arrSections)) { // Filter active sections (see #3273) if ($arrModule['col'] == 'header' && $objLayout->rows != '2rwh' && $objLayout->rows != '3rw') { continue; } if ($arrModule['col'] == 'left' && $objLayout->cols != '2cll' && $objLayout->cols != '3cl') { continue; } if ($arrModule['col'] == 'right' && $objLayout->cols != '2clr' && $objLayout->cols != '3cl') { continue; } if ($arrModule['col'] == 'footer' && $objLayout->rows != '2rwf' && $objLayout->rows != '3rw') { continue; } $this->Template->{$arrModule['col']} .= $this->getFrontendModule($arrModule['mod'], $arrModule['col']); } else { $arrCustomSections[$arrModule['col']] .= $this->getFrontendModule($arrModule['mod'], $arrModule['col']); } } } $this->Template->sections = $arrCustomSections; // Mark RTL languages (see #7171) if ($GLOBALS['TL_LANG']['MSC']['textDirection'] == 'rtl') { $this->Template->isRTL = true; } // HOOK: modify the page or layout object if (isset($GLOBALS['TL_HOOKS']['generatePage']) && is_array($GLOBALS['TL_HOOKS']['generatePage'])) { foreach ($GLOBALS['TL_HOOKS']['generatePage'] as $callback) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($objPage, $objLayout, $this); } } // Set the page title and description AFTER the modules have been generated $this->Template->mainTitle = $objPage->rootPageTitle; $this->Template->pageTitle = $objPage->pageTitle ?: $objPage->title; // Meta robots tag $this->Template->robots = $objPage->robots ?: 'index,follow'; // Remove shy-entities (see #2709) $this->Template->mainTitle = str_replace('[-]', '', $this->Template->mainTitle); $this->Template->pageTitle = str_replace('[-]', '', $this->Template->pageTitle); // Fall back to the default title tag if ($objLayout->titleTag == '') { $objLayout->titleTag = '{{page::pageTitle}} - {{page::rootPageTitle}}'; } // Assign the title and description $this->Template->title = strip_insert_tags($this->replaceInsertTags($objLayout->titleTag)); // see #7097 $this->Template->description = str_replace(array("\n", "\r", '"'), array(' ', '', ''), $objPage->description); // Body onload and body classes $this->Template->onload = trim($objLayout->onload); $this->Template->class = trim($objLayout->cssClass . ' ' . $objPage->cssClass); // Execute AFTER the modules have been generated and create footer scripts first $this->createFooterScripts($objLayout); $this->createHeaderScripts($objPage, $objLayout); // Print the template to the screen $this->Template->output($blnCheckRequest); }
/** * Generate the module */ protected function compile() { global $objPage; $objNewsletter = $this->Database->execute("SELECT *, (SELECT title FROM tl_newsletter_channel WHERE tl_newsletter_channel.id=tl_newsletter.pid) AS channel, (SELECT jumpTo FROM tl_newsletter_channel WHERE tl_newsletter_channel.id=tl_newsletter.pid) AS jumpTo FROM tl_newsletter WHERE pid IN(" . implode(',', array_map('intval', $this->nl_channels)) . ")" . (!BE_USER_LOGGED_IN ? " AND sent=1" : "") . " ORDER BY date DESC"); $arrJumpTo = array(); $arrNewsletter = array(); $time = time(); while ($objNewsletter->next()) { if ($objNewsletter->jumpTo < 1) { continue; } if (!isset($arrJumpTo[$objNewsletter->jumpTo])) { $objJumpTo = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND published=1" : ""))->limit(1)->execute($objNewsletter->jumpTo); if ($objJumpTo->numRows) { $arrJumpTo[$objNewsletter->jumpTo] = $this->generateFrontendUrl($objJumpTo->fetchAssoc(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s'); } else { $arrJumpTo[$objNewsletter->jumpTo] = null; } } $strUrl = $arrJumpTo[$objNewsletter->jumpTo]; if ($strUrl === null) { continue; } $strAlias = $objNewsletter->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objNewsletter->alias : $objNewsletter->id; $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => $this->parseDate($objPage->dateFormat, $objNewsletter->date), 'datim' => $this->parseDate($objPage->datimFormat, $objNewsletter->date), 'time' => $this->parseDate($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel); } $this->Template->newsletters = $arrNewsletter; }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $this->Template->referer = 'javascript:history.go(-1)'; $objFaq = $this->Database->prepare("SELECT *, author AS authorId, (SELECT title FROM tl_faq_category WHERE tl_faq_category.id=tl_faq.pid) AS category, (SELECT name FROM tl_user WHERE tl_user.id=tl_faq.author) AS author FROM tl_faq WHERE pid IN(" . implode(',', array_map('intval', $this->faq_categories)) . ") AND (id=? OR alias=?)" . (!BE_USER_LOGGED_IN ? " AND published=1" : ""))->limit(1)->execute(is_numeric($this->Input->get('items')) ? $this->Input->get('items') : 0, $this->Input->get('items')); if ($objFaq->numRows < 1) { // Do not index or cache the page $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); $this->Template->error = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $this->Input->get('items')) . '</p>'; return; } // Overwrite the page title and description if ($objFaq->question != '') { $objPage->pageTitle = strip_insert_tags($objFaq->question); $objPage->description = $this->prepareMetaDescription($objFaq->question); } $this->import('String'); $this->Template->question = $objFaq->question; $this->Template->answer = $objFaq->answer; // Clean RTE output if ($objPage->outputFormat == 'xhtml') { $this->Template->answer = $this->String->toXhtml($this->Template->answer); } else { $this->Template->answer = $this->String->toHtml5($this->Template->answer); } $this->Template->answer = $this->String->encodeEmail($this->Template->answer); $this->Template->addImage = false; // Add image if ($objFaq->addImage && is_file(TL_ROOT . '/' . $objFaq->singleSRC)) { $this->addImageToTemplate($this->Template, $objFaq->row()); } $this->Template->enclosure = array(); // Add enclosure if ($objFaq->addEnclosure) { $this->addEnclosuresToTemplate($this->Template, $objFaq->row()); } $this->Template->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->author); // HOOK: comments extension required if ($objFaq->noComments || !in_array('comments', $this->Config->getActiveModules())) { $this->Template->allowComments = false; return; } // Check whether comments are allowed $objCategory = $this->Database->prepare("SELECT * FROM tl_faq_category WHERE id=?")->limit(1)->execute($objFaq->pid); if ($objCategory->numRows < 1 || !$objCategory->allowComments) { $this->Template->allowComments = false; return; } $this->Template->allowComments = true; // Adjust the comments headline level $intHl = min(intval(str_replace('h', '', $this->hl)), 5); $this->Template->hlc = 'h' . ($intHl + 1); $this->import('Comments'); $arrNotifies = array(); // Notify system administrator if ($objCategory->notify != 'notify_author') { $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL']; } // Notify author if ($objCategory->notify != 'notify_admin') { $objAuthor = $this->Database->prepare("SELECT email FROM tl_user WHERE id=?")->limit(1)->execute($objFaq->authorId); if ($objAuthor->numRows) { $arrNotifies[] = $objAuthor->email; } } $objConfig = new stdClass(); $objConfig->perPage = $objCategory->perPage; $objConfig->order = $objCategory->sortOrder; $objConfig->template = $this->com_template; $objConfig->requireLogin = $objCategory->requireLogin; $objConfig->disableCaptcha = $objCategory->disableCaptcha; $objConfig->bbcode = $objCategory->bbcode; $objConfig->moderate = $objCategory->moderate; $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_faq', $objFaq->id, $arrNotifies); }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $this->Template->referer = 'javascript:history.go(-1)'; $objFaq = \FaqModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->faq_categories); if ($objFaq === null) { // Do not index or cache the page $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); $this->Template->error = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>'; return; } // Overwrite the page title and description if ($objFaq->question != '') { $objPage->pageTitle = strip_insert_tags($objFaq->question); $objPage->description = $this->prepareMetaDescription($objFaq->question); } $this->Template->question = $objFaq->question; // Clean RTE output if ($objPage->outputFormat == 'xhtml') { $objFaq->answer = \String::toXhtml($objFaq->answer); } else { $objFaq->answer = \String::toHtml5($objFaq->answer); } $this->Template->answer = \String::encodeEmail($objFaq->answer); $this->Template->addImage = false; // Add image if ($objFaq->addImage && $objFaq->singleSRC != '') { if (!is_numeric($objFaq->singleSRC)) { $this->Template->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } else { $objModel = \FilesModel::findByPk($objFaq->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { $objFaq->singleSRC = $objModel->path; $this->addImageToTemplate($this->Template, $objFaq->row()); } } } $this->Template->enclosure = array(); // Add enclosure if ($objFaq->addEnclosure) { $this->addEnclosuresToTemplate($this->Template, $objFaq->row()); } $this->Template->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->getRelated('author')->name); // HOOK: comments extension required if ($objFaq->noComments || !in_array('comments', $this->Config->getActiveModules())) { $this->Template->allowComments = false; return; } $objCategory = $objFaq->getRelated('pid'); // Check whether comments are allowed if (!$objCategory->allowComments) { $this->Template->allowComments = false; return; } $this->Template->allowComments = true; // Adjust the comments headline level $intHl = min(intval(str_replace('h', '', $this->hl)), 5); $this->Template->hlc = 'h' . ($intHl + 1); $this->import('Comments'); $arrNotifies = array(); // Notify the system administrator if ($objCategory->notify != 'notify_author') { $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL']; } // Notify the author if ($objCategory->notify != 'notify_admin') { if (($objAuthor = $objFaq->getRelated('author')) !== null && $objAuthor->email != '') { $arrNotifies[] = $objAuthor->email; } } $objConfig = new \stdClass(); $objConfig->perPage = $objCategory->perPage; $objConfig->order = $objCategory->sortOrder; $objConfig->template = $this->com_template; $objConfig->requireLogin = $objCategory->requireLogin; $objConfig->disableCaptcha = $objCategory->disableCaptcha; $objConfig->bbcode = $objCategory->bbcode; $objConfig->moderate = $objCategory->moderate; $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_faq', $objFaq->id, $arrNotifies); }
/** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; $this->Template->event = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; // Get the current event $objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar); if (null === $objEvent) { throw new PageNotFoundException('Page not found'); } // Overwrite the page title (see #2853 and #4955) if ($objEvent->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objEvent->title)); } // Overwrite the page description if ($objEvent->teaser != '') { $objPage->description = $this->prepareMetaDescription($objEvent->teaser); } $intStartTime = $objEvent->startTime; $intEndTime = $objEvent->endTime; $span = \Calendar::calculateSpan($intStartTime, $intEndTime); // Do not show dates in the past if the event is recurring (see #923) if ($objEvent->recurring) { $arrRange = deserialize($objEvent->repeatEach); while ($intStartTime < time() && $intEndTime < $objEvent->repeatEnd) { $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime); $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime); } } $strDate = \Date::parse($objPage->dateFormat, $intStartTime); if ($span > 0) { $strDate = \Date::parse($objPage->dateFormat, $intStartTime) . ' – ' . \Date::parse($objPage->dateFormat, $intEndTime); } $strTime = ''; if ($objEvent->addTime) { if ($span > 0) { $strDate = \Date::parse($objPage->datimFormat, $intStartTime) . ' – ' . \Date::parse($objPage->datimFormat, $intEndTime); } elseif ($intStartTime == $intEndTime) { $strTime = \Date::parse($objPage->timeFormat, $intStartTime); } else { $strTime = \Date::parse($objPage->timeFormat, $intStartTime) . ' – ' . \Date::parse($objPage->timeFormat, $intEndTime); } } $until = ''; $recurring = ''; // Recurring event if ($objEvent->recurring) { $arrRange = deserialize($objEvent->repeatEach); $strKey = 'cal_' . $arrRange['unit']; $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']); if ($objEvent->recurrences > 0) { $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); } } /** @var FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($this->cal_template); $objTemplate->setData($objEvent->row()); $objTemplate->date = $strDate; $objTemplate->time = $strTime; $objTemplate->datetime = $objEvent->addTime ? date('Y-m-d\\TH:i:sP', $intStartTime) : date('Y-m-d', $intStartTime); $objTemplate->begin = $intStartTime; $objTemplate->end = $intEndTime; $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : ''; $objTemplate->recurring = $recurring; $objTemplate->until = $until; $objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location']; $objTemplate->details = ''; $objTemplate->hasDetails = false; $objTemplate->hasTeaser = false; // Clean the RTE output if ($objEvent->teaser != '') { $objTemplate->hasTeaser = true; $objTemplate->teaser = \StringUtil::toHtml5($objEvent->teaser); $objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser); } // Display the "read more" button for external/article links if ($objEvent->source != 'default') { $objTemplate->details = true; $objTemplate->hasDetails = true; } else { $id = $objEvent->id; $objTemplate->details = function () use($id) { $strDetails = ''; $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events'); if ($objElement !== null) { while ($objElement->next()) { $strDetails .= $this->getContentElement($objElement->current()); } } return $strDetails; }; $objTemplate->hasDetails = \ContentModel::countPublishedByPidAndTable($id, 'tl_calendar_events') > 0; } $objTemplate->addImage = false; // Add an image if ($objEvent->addImage && $objEvent->singleSRC != '') { $objModel = \FilesModel::findByUuid($objEvent->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { // Do not override the field now that we have a model registry (see #6303) $arrEvent = $objEvent->row(); // Override the default image size if ($this->imgSize != '') { $size = deserialize($this->imgSize); if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) { $arrEvent['size'] = $this->imgSize; } } $arrEvent['singleSRC'] = $objModel->path; $this->addImageToTemplate($objTemplate, $arrEvent); } } $objTemplate->enclosure = array(); // Add enclosures if ($objEvent->addEnclosure) { $this->addEnclosuresToTemplate($objTemplate, $objEvent->row()); } $this->Template->event = $objTemplate->parse(); $bundles = \System::getContainer()->getParameter('kernel.bundles'); // HOOK: comments extension required if ($objEvent->noComments || !isset($bundles['ContaoCommentsBundle'])) { $this->Template->allowComments = false; return; } /** @var CalendarModel $objCalendar */ $objCalendar = $objEvent->getRelated('pid'); $this->Template->allowComments = $objCalendar->allowComments; // Comments are not allowed if (!$objCalendar->allowComments) { return; } // Adjust the comments headline level $intHl = min(intval(str_replace('h', '', $this->hl)), 5); $this->Template->hlc = 'h' . ($intHl + 1); $this->import('Comments'); $arrNotifies = array(); // Notify the system administrator if ($objCalendar->notify != 'notify_author') { $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL']; } // Notify the author if ($objCalendar->notify != 'notify_admin') { /** @var UserModel $objAuthor */ if (($objAuthor = $objEvent->getRelated('author')) !== null && $objAuthor->email != '') { $arrNotifies[] = $objAuthor->email; } } $objConfig = new \stdClass(); $objConfig->perPage = $objCalendar->perPage; $objConfig->order = $objCalendar->sortOrder; $objConfig->template = $this->com_template; $objConfig->requireLogin = $objCalendar->requireLogin; $objConfig->disableCaptcha = $objCalendar->disableCaptcha; $objConfig->bbcode = $objCalendar->bbcode; $objConfig->moderate = $objCalendar->moderate; $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_calendar_events', $objEvent->id, $arrNotifies); }
/** * Generate the module */ protected function compile() { global $objPage; $this->import('String'); if ($this->blnNoMarkup) { $this->Template = new FrontendTemplate('mod_article_plain'); $this->Template->setData($this->arrData); } $alias = $this->alias != '' ? $this->alias : $this->title; if (in_array($alias, array('header', 'container', 'left', 'main', 'right', 'footer'))) { $alias .= '-' . $this->id; } $alias = standardize($alias); // Generate the cssID if it is not set if (!strlen($this->cssID[0])) { $this->cssID = array($alias, $this->cssID[1]); } $this->Template->column = $this->inColumn; // Add modification date $this->Template->timestamp = $this->tstamp; $this->Template->date = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $this->tstamp); $this->Template->author = $this->author; // Clean the RTE output if ($objPage->outputFormat == 'xhtml') { $this->teaser = $this->String->toXhtml($this->teaser); } else { $this->teaser = $this->String->toHtml5($this->teaser); } // Show teaser only if ($this->multiMode && $this->showTeaser) { $this->Template = new FrontendTemplate('mod_article_teaser'); $this->Template->setData($this->arrData); // Override CSS ID and class $arrCss = deserialize($this->teaserCssID); if (is_array($arrCss) && count($arrCss) == 2) { if ($arrCss[0] == '') { $arrCss[0] = $alias; } $this->cssID = $arrCss; } $article = !$GLOBALS['TL_CONFIG']['disableAlias'] && strlen($this->alias) ? $this->alias : $this->id; $href = 'articles=' . ($this->inColumn != 'main' ? $this->inColumn . ':' : '') . $article; $this->Template->headline = $this->headline; $this->Template->href = $this->addToUrl($href); $this->Template->teaser = $this->teaser; $this->Template->readMore = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $this->headline), true); $this->Template->more = $GLOBALS['TL_LANG']['MSC']['more']; return; } // Get section and article alias list($strSection, $strArticle) = explode(':', $this->Input->get('articles')); if (is_null($strArticle)) { $strArticle = $strSection; } // Overwrite the page title if (!$this->blnNoMarkup && $strArticle != '' && ($strArticle == $this->id || $strArticle == $this->alias) && $this->title != '') { $objPage->pageTitle = strip_insert_tags($this->title); } $this->Template->printable = false; $this->Template->backlink = false; // Back link if (!$this->multiMode && $strArticle != '' && ($strArticle == $this->id || $strArticle == $this->alias)) { $this->Template->back = specialchars($GLOBALS['TL_LANG']['MSC']['goBack']); // Remove the "/articles/…" part from the URL if ($GLOBALS['TL_CONFIG']['disableAlias']) { $this->Template->backlink = preg_replace('@&(amp;)?articles=[^&]+@', '', $this->Environment->request); } else { $this->Template->backlink = preg_replace('@/articles/[^/]+@', '', $this->Environment->request) . $GLOBALS['TL_CONFIG']['urlSuffix']; } } $contentElements = ''; // Get all visible content elements $objCte = $this->Database->prepare("SELECT id FROM tl_content WHERE pid=?" . (!BE_USER_LOGGED_IN ? " AND invisible=''" : "") . " ORDER BY sorting")->execute($this->id); while ($objCte->next()) { $contentElements .= $this->getContentElement($objCte->id); } $this->Template->teaser = $this->teaser; $this->Template->contentElements = $contentElements; if ($this->keywords != '') { $GLOBALS['TL_KEYWORDS'] .= (strlen($GLOBALS['TL_KEYWORDS']) ? ', ' : '') . $this->keywords; } // Backwards compatibility if ($this->printable == 1) { $this->Template->printable = true; $this->Template->pdfButton = true; } elseif ($this->printable != '') { $options = deserialize($this->printable); if (is_array($options) && count($options) > 0) { $this->Template->printable = true; $this->Template->printButton = in_array('print', $options); $this->Template->pdfButton = in_array('pdf', $options); $this->Template->facebookButton = in_array('facebook', $options); $this->Template->twitterButton = in_array('twitter', $options); } } // Add syndication variables if ($this->Template->printable) { $request = $this->getIndexFreeRequest(true); $this->Template->print = '#'; $this->Template->encUrl = rawurlencode($this->Environment->base . $this->Environment->request); $this->Template->encTitle = rawurlencode($objPage->pageTitle); $this->Template->href = $request . (strpos($request, '?') !== false ? '&' : '?') . 'pdf=' . $this->id; $this->Template->printTitle = specialchars($GLOBALS['TL_LANG']['MSC']['printPage']); $this->Template->pdfTitle = specialchars($GLOBALS['TL_LANG']['MSC']['printAsPdf']); $this->Template->facebookTitle = specialchars($GLOBALS['TL_LANG']['MSC']['facebookShare']); $this->Template->twitterTitle = specialchars($GLOBALS['TL_LANG']['MSC']['twitterShare']); } }
protected function compile() { global $objPage; $this->Template->event = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; if ($this->objEvent === null) { // Do not index or cache the page $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); $this->Template->event = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '</p>'; // remove page from search index if ($this->cal_showInModal) { \HeimrichHannot\SearchPlus\Search::removePageFromIndex(\Environment::get('request')); } return; } // Overwrite the page title (see #2853 and #4955) if ($this->objEvent->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($this->objEvent->title)); } // Overwrite the page description if ($this->objEvent->teaser != '') { $objPage->description = $this->prepareMetaDescription($this->objEvent->teaser); } $strUrl = ''; $objCalendar = \CalendarModel::findByPk($this->objEvent->pid); // Get the current "jumpTo" page if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) { $strUrl = $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s'); } $intStartTime = $this->objEvent->startTime; $intEndTime = $this->objEvent->endTime; $span = \Calendar::calculateSpan($intStartTime, $intEndTime); // Do not show dates in the past if the event is recurring (see #923) if ($this->objEvent->recurring) { $arrRange = deserialize($this->objEvent->repeatEach); while ($intStartTime < time() && $intEndTime < $this->objEvent->repeatEnd) { $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime); $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime); } } $objEvent = (object) $this->getEventDetails($this->objEvent, $intStartTime, $intEndTime, $strUrl, $intStartTime, $this->objEvent->pid); $arrSubEvents = array(); if (!$this->cal_ungroupSubevents) { $objChildEvents = CalendarPlusEventsModel::findPublishedSubEvents($objEvent->id); if ($objChildEvents !== null) { while ($objChildEvents->next()) { $arrSubEvents[$objChildEvents->id] = $this->addSingleEvent($objChildEvents, $intStartTime); } } } if ($objPage->outputFormat == 'xhtml') { $strTimeStart = ''; $strTimeEnd = ''; $strTimeClose = ''; } else { $strTimeStart = '<time datetime="' . date('Y-m-d\\TH:i:sP', $intStartTime) . '">'; $strTimeEnd = '<time datetime="' . date('Y-m-d\\TH:i:sP', $intEndTime) . '">'; $strTimeClose = '</time>'; } // Get date if ($span > 0) { $date = $strTimeStart . \Date::parse($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intEndTime) . $strTimeClose; } elseif ($intStartTime == $intEndTime) { $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($objEvent->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . ')' : '') . $strTimeClose; } else { $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($objEvent->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($objPage->timeFormat, $intEndTime) . ')' : '') . $strTimeClose; } $until = ''; $recurring = ''; // Recurring event if ($objEvent->recurring) { $arrRange = deserialize($objEvent->repeatEach); $strKey = 'cal_' . $arrRange['unit']; $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']); if ($objEvent->recurrences > 0) { $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); } } // Override the default image size if ($this->imgSize != '') { $size = deserialize($this->imgSize); if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) { $objEvent->size = $this->imgSize; } } $imgSize = false; // Override the default image size if ($this->imgSize != '') { $size = deserialize($this->imgSize); if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) { $imgSize = $this->imgSize; } } $objTemplate = new \FrontendTemplate($this->cal_template); $objTemplate->setData((array) $objEvent); $objTemplate->nav = $this->generateArrowNavigation($objEvent, $strUrl); if ($this->registration !== null) { $objTemplate->registration = $this->registration; $objTemplate->module = $this; // falback } if (is_array($arrSubEvents) && !empty($arrSubEvents)) { $strSubEvents = ''; foreach ($arrSubEvents as $subID => $arrSubEvent) { $objSubEventTemplate = new \FrontendTemplate($this->cal_templateSubevent); $objSubEventTemplate->setData($arrSubEvent); $this->addEventDetailsToTemplate($objSubEventTemplate, $arrSubEvent, '', '', $imgSize); $strSubEvents .= $objSubEventTemplate->parse() . "\n"; } $objTemplate->subEvents = $strSubEvents; } if ($this->addShare && in_array('share', $this->Config->getActiveModules())) { $objShare = new \HeimrichHannot\Share\Share($this->objModel, $objEvent); $objTemplate->share = $objShare->generate(); } $objTemplate->addImage = false; // Add an image if ($objEvent->addImage && $objEvent->singleSRC != '') { $objModel = \FilesModel::findByUuid($objEvent->singleSRC); if ($objModel === null) { if (!\Validator::isUuid($objEvent->singleSRC)) { $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } } elseif (is_file(TL_ROOT . '/' . $objModel->path)) { // Do not override the field now that we have a model registry (see #6303) $arrEvent = $objEvent->row(); $arrEvent['singleSRC'] = $objModel->path; $this->addImageToTemplate($objTemplate, $arrEvent); } } $objTemplate->enclosure = array(); // Add enclosures if ($objEvent->addEnclosure) { $this->addEnclosuresToTemplate($objTemplate, $this->objEvent->row()); } $this->Template->event = $objTemplate->parse(); // HOOK: comments extension required if ($objEvent->noComments || !in_array('comments', \ModuleLoader::getActive())) { $this->Template->allowComments = false; return; } $this->Template->allowComments = $objCalendar->allowComments; // Comments are not allowed if (!$objCalendar->allowComments) { return; } // Adjust the comments headline level $intHl = min(intval(str_replace('h', '', $this->hl)), 5); $this->Template->hlc = 'h' . ($intHl + 1); $this->import('Comments'); $arrNotifies = array(); // Notify the system administrator if ($objCalendar->notify != 'notify_author') { $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL']; } // Notify the author if ($objCalendar->notify != 'notify_admin') { if (($objAuthor = $objEvent->getRelated('author')) !== null && $objAuthor->email != '') { $arrNotifies[] = $objAuthor->email; } } $objConfig = new \stdClass(); $objConfig->perPage = $objCalendar->perPage; $objConfig->order = $objCalendar->sortOrder; $objConfig->template = $this->com_template; $objConfig->requireLogin = $objCalendar->requireLogin; $objConfig->disableCaptcha = $objCalendar->disableCaptcha; $objConfig->bbcode = $objCalendar->bbcode; $objConfig->moderate = $objCalendar->moderate; $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_calendar_events', $objEvent->id, $arrNotifies); }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->project = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; // Get the Project item $objProject = \PortfolioProjectModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->portfolio_project_categories); if ($objProject === null) { // Do not index or cache the page $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); $this->Template->projects = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>'; return; } $arrProject = $this->parseProject($objProject); $this->Template->project = $arrProject; // Get the Client items $objClient = \PortfolioClientModel::findPublishedByParentAndIdOrAlias($objProject->clientID, $this->portfolio_project_categories); $this->Template->client = ''; if ($objClient !== null) { $this->Template->client = $this->parseClient($objClient); } // Overwrite the page title (see #2853 and #4955) if ($objProject->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objProject->title)); } }
/** * Return customer email address for the collection * @return string */ public function getEmailRecipient() { $strName = ''; $strEmail = ''; $objBillingAddress = $this->getBillingAddress(); $objShippingAddress = $this->getShippingAddress(); if ($objBillingAddress->email != '') { $strName = $objBillingAddress->firstname . ' ' . $objBillingAddress->lastname; $strEmail = $objBillingAddress->email; } elseif ($objShippingAddress->email != '') { $strName = $objShippingAddress->firstname . ' ' . $objShippingAddress->lastname; $strEmail = $objShippingAddress->email; } elseif ($this->member > 0 && ($objMember = \MemberModel::findByPk($this->member)) !== null && $objMember->email != '') { $strName = $objMember->firstname . ' ' . $objMember->lastname; $strEmail = $objMember->email; } if (trim($strName) != '') { // Romanize friendly name to prevent email issues $strName = html_entity_decode($strName, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); $strName = strip_insert_tags($strName); $strName = utf8_romanize($strName); $strName = preg_replace('/[^A-Za-z0-9\\.!#$%&\'*+-\\/=?^_ `{\\|}~]+/i', '_', $strName); $strEmail = sprintf('"%s" <%s>', $strName, $strEmail); } // !HOOK: determine email recipient for collection if (isset($GLOBALS['ISO_HOOKS']['emailRecipientForCollection']) && is_array($GLOBALS['ISO_HOOKS']['emailRecipientForCollection'])) { foreach ($GLOBALS['ISO_HOOKS']['emailRecipientForCollection'] as $callback) { $objCallback = \System::importStatic($callback[0]); $strEmail = $objCallback->{$callback}[1]($strEmail, $this); } } return $strEmail; }