/** * Generate an error 403 page * @param integer * @param object */ public function generate($pageId, $objRootPage = null) { // Add a log entry $this->log('Access to page ID "' . $pageId . '" denied', 'PageError403 generate()', TL_ERROR); // Use the given root page object if available (thanks to Andreas Schempp) if ($objRootPage === null) { $objRootPage = $this->getRootPageFromUrl(); } else { $objRootPage = \PageModel::findPublishedById(is_integer($objRootPage) ? $objRootPage : $objRootPage->id); } // Look for an error_403 page $obj403 = \PageModel::find403ByPid($objRootPage->id); // Die if there is no page at all if ($obj403 === null) { header('HTTP/1.1 403 Forbidden'); die('Forbidden'); } // Generate the error page if (!$obj403->autoforward || !$obj403->jumpTo) { global $objPage; $objPage = $this->getPageDetails($obj403); $objHandler = new $GLOBALS['TL_PTY']['regular'](); header('HTTP/1.1 403 Forbidden'); $objHandler->generate($objPage); exit; } // Forward to another page $objNextPage = \PageModel::findPublishedById($obj403->jumpTo); if ($objNextPage === null) { header('HTTP/1.1 403 Forbidden'); $this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', 'PageError403 generate()', TL_ERROR); die('Forward page not found'); } $this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj403->redirect == 'temporary' ? 302 : 301); }
/** * Redirect to an internal page * @param object */ public function generate($objPage) { // Forward to the jumpTo or first published page if ($objPage->jumpTo) { $objNextPage = \PageModel::findPublishedById($objPage->jumpTo); } else { $objNextPage = \PageModel::findFirstPublishedRegularByPid($objPage->id); } // Forward page does not exist if ($objNextPage === null) { header('HTTP/1.1 404 Not Found'); $this->log('Forward page ID "' . $objPage->jumpTo . '" does not exist', 'PageForward generate()', TL_ERROR); die('Forward page not found'); } $strGet = ''; // Add $_GET parameters if (is_array($_GET) && !empty($_GET)) { foreach (array_keys($_GET) as $key) { if ($GLOBALS['TL_CONFIG']['disableAlias'] && $key == 'id') { continue; } if ($GLOBALS['TL_CONFIG']['addLanguageToUrl'] && $key == 'language') { continue; } $strGet .= '/' . $key . '/' . \Input::get($key); } } $this->redirect($this->generateFrontendUrl($objNextPage->row(), $strGet), $objPage->redirect == 'temporary' ? 302 : 301); }
/** * 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 an error 404 page * * @param integer $pageId * @param string $strDomain * @param string $strHost * @param boolean $blnUnusedGet */ public function generate($pageId, $strDomain = null, $strHost = null, $blnUnusedGet = false) { // Add a log entry if ($blnUnusedGet) { $this->log('The request for page ID "' . $pageId . '" contained unused GET parameters: "' . implode('", "', \Input::getUnusedGet()) . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR); } elseif ($strDomain !== null || $strHost !== null) { $this->log('Page ID "' . $pageId . '" was requested via "' . $strHost . '" but can only be accessed via "' . $strDomain . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR); } elseif ($pageId != 'favicon.ico' && $pageId != 'robots.txt') { $this->log('No active page for page ID "' . $pageId . '", host "' . \Environment::get('host') . '" and languages "' . implode(', ', \Environment::get('httpAcceptLanguage')) . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR); } // Check the search index (see #3761) \Search::removeEntry(\Environment::get('request')); // Find the matching root page $objRootPage = $this->getRootPageFromUrl(); // Forward if the language should be but is not set (see #4028) if (\Config::get('addLanguageToUrl')) { // Get the request string without the index.php fragment if (\Environment::get('request') == 'index.php') { $strRequest = ''; } else { $strRequest = str_replace('index.php/', '', \Environment::get('request')); } // Only redirect if there is no language fragment (see #4669) if ($strRequest != '' && !preg_match('@^[a-z]{2}(-[A-Z]{2})?/@', $strRequest)) { // Handle language fragments without trailing slash (see #7666) if (preg_match('@^[a-z]{2}(-[A-Z]{2})?$@', $strRequest)) { $this->redirect(($GLOBALS['TL_CONFIG']['rewriteURL'] ? '' : 'index.php/') . $strRequest . '/', 301); } else { $this->redirect(($GLOBALS['TL_CONFIG']['rewriteURL'] ? '' : 'index.php/') . $objRootPage->language . '/' . $strRequest, 301); } } } // Look for a 404 page $obj404 = \PageModel::find404ByPid($objRootPage->id); // Die if there is no page at all if (null === $obj404) { header('HTTP/1.1 404 Not Found'); die_nicely('be_no_page', 'Page not found'); } // Generate the error page if (!$obj404->autoforward || !$obj404->jumpTo) { /** @var \PageModel $objPage */ global $objPage; $objPage = $obj404->loadDetails(); /** @var \PageRegular $objHandler */ $objHandler = new $GLOBALS['TL_PTY']['regular'](); header('HTTP/1.1 404 Not Found'); $objHandler->generate($objPage); exit; } // Forward to another page $objNextPage = \PageModel::findPublishedById($obj404->jumpTo); if (null === $objNextPage) { header('HTTP/1.1 404 Not Found'); $this->log('Forward page ID "' . $obj404->jumpTo . '" does not exist', __METHOD__, TL_ERROR); die_nicely('be_no_forward', 'Forward page not found'); } $this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj404->redirect == 'temporary' ? 302 : 301); }
/** * Generate an error 404 page * @param integer * @param string * @param string */ public function generate($pageId, $strDomain = null, $strHost = null) { // Add a log entry if ($strDomain !== null || $strHost !== null) { $this->log('Page ID "' . $pageId . '" can only be accessed via domain "' . $strDomain . '" (current request via "' . $strHost . '")', 'PageError404 generate()', TL_ERROR); } elseif ($pageId != 'favicon.ico' && $pageId != 'robots.txt') { $this->log('No active page for page ID "' . $pageId . '", host "' . \Environment::get('host') . '" and languages "' . implode(', ', \Environment::get('httpAcceptLanguage')) . '" (' . \Environment::get('base') . \Environment::get('request') . ')', 'PageError404 generate()', TL_ERROR); } // Check the search index (see #3761) \Search::removeEntry(\Environment::get('request')); // Find the matching root page $objRootPage = $this->getRootPageFromUrl(); // Forward if the language should be but is not set (see #4028) if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) { // Get the request string without the index.php fragment if (\Environment::get('request') == 'index.php') { $strRequest = ''; } else { $strRequest = str_replace('index.php/', '', \Environment::get('request')); } // Only redirect if there is no language fragment (see #4669) if ($strRequest != '' && !preg_match('@^[a-z]{2}/@', $strRequest)) { $this->redirect($objRootPage->language . '/' . \Environment::get('request'), 301); } } // Look for an 404 page $obj404 = \PageModel::find404ByPid($objRootPage->id); // Die if there is no page at all if ($obj404 === null) { header('HTTP/1.1 404 Not Found'); die('Page not found'); } // Generate the error page if (!$obj404->autoforward || !$obj404->jumpTo) { global $objPage; $objPage = $this->getPageDetails($obj404); $objHandler = new $GLOBALS['TL_PTY']['regular'](); header('HTTP/1.1 404 Not Found'); $objHandler->generate($objPage); exit; } // Forward to another page $objNextPage = \PageModel::findPublishedById($obj404->jumpTo); if ($objNextPage === null) { header('HTTP/1.1 404 Not Found'); $this->log('Forward page ID "' . $obj404->jumpTo . '" does not exist', 'PageError404 generate()', TL_ERROR); die('Forward page not found'); } $this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj404->redirect == 'temporary' ? 302 : 301); }
/** * Check whether the target page and the article are published * * @return string */ public function generate() { $objArticle = \ArticleModel::findPublishedById($this->article); if ($objArticle === null) { return ''; } // Use findPublished() instead of getRelated() $objParent = \PageModel::findPublishedById($objArticle->pid); if ($objParent === null) { return ''; } $this->objArticle = $objArticle; $this->objParent = $objParent; return parent::generate(); }
/** * {@inheritdoc} */ public function handle403($pageId, \PageModel $rootPage) { if ($rootPage->browser_auth_basic_realm && !FE_USER_LOGGED_IN) { $authenticate = <<<EOF WWW-Authenticate: Basic realm="{$rootPage->browser_auth_basic_realm}" EOF; header('HTTP/1.1 401 Unauthorized'); header($authenticate); // Look for an error_403 page $obj403 = \PageModel::find403ByPid($rootPage->id); // Die if there is no page at all if ($obj403 === null) { echo '403 Forbidden'; exit; } // Generate the error page if (!$obj403->autoforward || !$obj403->jumpTo) { global $objPage; $objPage = $obj403->loadDetails(); $objHandler = new $GLOBALS['TL_PTY']['regular'](); $objHandler->generate($objPage); exit; } // Forward to another page $nextPage = \PageModel::findPublishedById($obj403->jumpTo); if ($nextPage === null) { $this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', 'PageError403 generate()', TL_ERROR); die('Forward page not found'); } $url = \Environment::get('base') . \Controller::generateFrontendUrl($nextPage->row(), null, $rootPage->language); echo <<<EOF <!DOCTYPE html> <html lang="de"> <head> <meta http-equiv="refresh" content="5; URL={$url}"> </head> <body> Redirecting to <a href="{$url}">{$url}</a> </body> </html> EOF; exit; } }
/** * Generate an error 403 page * * @param integer $pageId * @param \PageModel $objRootPage */ public function generate($pageId, $objRootPage = null) { // Add a log entry $this->log('Access to page ID "' . $pageId . '" denied', __METHOD__, TL_ERROR); // Use the given root page object if available (thanks to Andreas Schempp) if ($objRootPage === null) { $objRootPage = $this->getRootPageFromUrl(); } else { $objRootPage = \PageModel::findPublishedById(is_integer($objRootPage) ? $objRootPage : $objRootPage->id); } // Look for a 403 page $obj403 = \PageModel::find403ByPid($objRootPage->id); // Die if there is no page at all if (null === $obj403) { header('HTTP/1.1 403 Forbidden'); die_nicely('be_forbidden', 'Forbidden'); } // Generate the error page if (!$obj403->autoforward || !$obj403->jumpTo) { /** @var \PageModel $objPage */ global $objPage; // Die nicely if the page is a 403 page already (see #8060) if ($objPage && $objPage->type == 'error_403') { header('HTTP/1.1 403 Forbidden'); die_nicely('be_forbidden', 'Forbidden'); } $objPage = $obj403->loadDetails(); /** @var \PageRegular $objHandler */ $objHandler = new $GLOBALS['TL_PTY']['regular'](); header('HTTP/1.1 403 Forbidden'); $objHandler->generate($objPage); exit; } // Forward to another page $objNextPage = \PageModel::findPublishedById($obj403->jumpTo); if (null === $objNextPage) { header('HTTP/1.1 403 Forbidden'); $this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', __METHOD__, TL_ERROR); die_nicely('be_no_forward', 'Forward page not found'); } $this->redirect($this->generateFrontendUrl($objNextPage->loadDetails()->row(), null, $objRootPage->language, true), $obj403->redirect == 'temporary' ? 302 : 301); }
public function parseArticlesHook(&$objTemplate, $arrArticle, $objModule) { if (!($objModule->useModal && $arrArticle['source'] == 'default')) { return false; } $objJumpTo = \PageModel::findPublishedById($objTemplate->archive->jumpTo); if ($objJumpTo === null || !$objJumpTo->linkModal) { return false; } $objModal = ModalModel::findPublishedByIdOrAlias($objJumpTo->modal); if ($objModal === null) { return false; } $objJumpTo = \PageModel::findWithDetails($objJumpTo->id); $arrConfig = ModalController::getModalConfig($objModal->current(), $objJumpTo->layout); $blnAjax = true; $blnRedirect = true; $objTemplate->link = ModalController::generateModalUrl($arrArticle, $objTemplate->archive->jumpTo, $blnAjax, $blnRedirect); $objTemplate->linkHeadline = ModalController::convertLinkToModalLink($objTemplate->linkHeadline, $objTemplate->link, $arrConfig, $blnRedirect); $objTemplate->more = ModalController::convertLinkToModalLink($objTemplate->more, $objTemplate->link, $arrConfig, $blnRedirect); }
public function generate($pageId, $rootPage = null) { // Use the given root page object if available (thanks to Andreas Schempp) if ($rootPage === null) { $rootPage = $this->getRootPageFromUrl(); } else { $rootPage = \PageModel::findPublishedById(is_integer($rootPage) ? $rootPage : $rootPage->id); } if ($rootPage && $rootPage->browser_auth_enabled) { if (array_key_exists($rootPage->browser_auth_module, $GLOBALS['BROWSER_AUTH_MODULES'])) { $this->log('Access to page ID "' . $pageId . '" denied', 'PageAuth generate()', TL_ERROR); $authModuleClass = $GLOBALS['BROWSER_AUTH_MODULES'][$rootPage->browser_auth_module]; $authModule = new $authModuleClass(); $authModule->handle403($pageId, $rootPage); } else { $this->log('Root page ID "' . $rootPage->id . '" does not have a suitable auth module!', 'PageAuth generate()', TL_ERROR); header('HTTP/1.1 501 Not Implemented'); echo '501 Not Implemented'; exit; } } $page = new static::$page403Class(); $page->generate($pageId, $rootPage); }
/** * Handle articles * @return bool return true, or false if the articles does not exist */ protected function handleArticle() { if (($objArticle = \ArticleModel::findPublishedById($this->articleId, array('eager' => true))) === null) { return false; } if (($objTarget = \PageModel::findPublishedById($objArticle->pid)) === null) { return false; } $objTarget = $objTarget->loadDetails(); if ($objTarget->domain != '' && $objTarget->domain != \Environment::get('host')) { $this->target = true; } $strParams = '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id); $this->setHref(ampersand(\Controller::generateFrontendUrl($objTarget->row(), $strParams, null, $this->target))); $this->setTitle(sprintf($GLOBALS['TL_LANG']['MSC']['linkteaser']['articleTitle'], $objArticle->title)); $this->setLink(sprintf($this->getLink(), $objArticle->title)); return true; }
/** * Redirect to a jumpTo page or reload the current page * * @param integer|array $intId * @param string $strParams * @param string $strForceLang */ protected function jumpToOrReload($intId, $strParams = null, $strForceLang = null) { /** @var \PageModel $objPage */ global $objPage; // Always redirect if there are additional arguments (see #5734) $blnForceRedirect = $strParams !== null || $strForceLang !== null; if (is_array($intId)) { if ($intId['id'] != '') { if ($intId['id'] != $objPage->id || $blnForceRedirect) { $this->redirect($this->generateFrontendUrl($intId, $strParams, $strForceLang)); } } } elseif ($intId > 0) { if ($intId != $objPage->id || $blnForceRedirect) { if (($objNextPage = \PageModel::findPublishedById($intId)) !== null) { $this->redirect($this->generateFrontendUrl($objNextPage->row(), $strParams, $strForceLang)); } } } $this->reload(); }
/** * Check if the checkout can be executed * * @return bool */ protected function canCheckout() { // Redirect to login page if not logged in if ($this->iso_checkout_method == 'member' && FE_USER_LOGGED_IN !== true) { /** @type \PageModel $objJump */ $objJump = \PageModel::findPublishedById($this->iso_login_jumpTo); if (null === $objJump) { $this->Template = new \Isotope\Template('mod_message'); $this->Template->type = 'error'; $this->Template->message = $GLOBALS['TL_LANG']['ERR']['isoLoginRequired']; return false; } $objJump->loadDetails(); \Controller::redirect($objJump->getFrontendUrl(null, $objJump->language)); } elseif ($this->iso_checkout_method == 'guest' && FE_USER_LOGGED_IN === true) { $this->Template = new \Isotope\Template('mod_message'); $this->Template->type = 'error'; $this->Template->message = $GLOBALS['TL_LANG']['ERR']['checkoutNotAllowed']; return false; } // Return error message if cart is empty if (Isotope::getCart()->isEmpty()) { $this->Template = new \Isotope\Template('mod_message'); $this->Template->type = 'empty'; $this->Template->message = $GLOBALS['TL_LANG']['MSC']['noItemsInCart']; return false; } // Insufficient cart subtotal if (Isotope::getCart()->hasErrors()) { if ($this->iso_cart_jumpTo > 0) { /** @type \PageModel $objJump */ $objJump = \PageModel::findPublishedById($this->iso_cart_jumpTo); if (null !== $objJump) { $objJump->loadDetails(); \Controller::redirect($objJump->getFrontendUrl(null, $objJump->language)); } } $this->Template = new \Isotope\Template('mod_message'); $this->Template->type = 'error'; $this->Template->message = implode("</p>\n<p class=\"error message\">", Isotope::getCart()->getErrors()); return false; } return true; }
/** * activateOrDelete */ protected function activateOrDelete() { $dbChange = false; $objComments = \CommentsModel::findByActivation_token(\Input::get('activation_token')); if ($objComments === NULL) { die(utf8_decode($GLOBALS['TL_LANG']['MOD']['member_rating']['invalidToken'])); } // delete or publish comment via url, received from a notification email if (\Input::get('del') == 'true') { $dbChange = true; $this->log('DELETE FROM tl_comments WHERE id=' . $objComments->id, __METHOD__, TL_GENERAL); $objComments->delete(); $msg = $GLOBALS['TL_LANG']['MOD']['member_rating']['itemHasBeenActivated']; if (($objNextPage = \PageModel::findPublishedById($this->emailNotifyPage_DeleteComment)) !== NULL) { $this->redirect($this->generateFrontendUrl($objNextPage->row())); } } elseif (\Input::get('publish') == 'true') { $dbChange = true; $objComments->published = 1; $objComments->activation_token = ''; $objComments->save(); $this->log('A new version of tl_comments ID ' . $objComments->id . ' has been created', __METHOD__, TL_GENERAL); $msg = $GLOBALS['TL_LANG']['MOD']['member_rating']['itemHasBeenActivated']; if (($objNextPage = \PageModel::findPublishedById($this->emailNotifyPage_ActivateComment)) !== NULL) { $this->redirect($this->generateFrontendUrl($objNextPage->row())); } } else { // } if ($dbChange === true) { die($msg); } exit; }
/** * @category ISO_HOOKS: preCheckout * * @param ProductCollection\Order $order * @param Checkout $checkout * * @return bool */ public function checkBeforeCheckout(ProductCollection\Order $order, Checkout $checkout) { foreach ($order->getItems() as $item) { /** @var Product|\Model $product */ $product = $item->getProduct(); $productType = $product->getRelated('type'); $stock = Stock::getStockForProduct($product->id); if ($productType->stockmanagement_active && false !== $stock && $item->quantity > $stock) { Message::addError($GLOBALS['TL_LANG']['MSC']['simpleStockmanagement']['productQuantityUnavailable']); if ($checkout->iso_cart_jumpTo > 0) { /** @type \PageModel $jumpTo */ $jumpTo = \PageModel::findPublishedById($checkout->iso_cart_jumpTo); if (null !== $jumpTo) { $jumpTo->loadDetails(); \Controller::redirect($jumpTo->getFrontendUrl(null, $jumpTo->language)); } } return false; } } return true; }
public function findRelatedByCredit($objCredit, $arrPids) { $this->result = $objCredit; $objFile = \FilesModel::findByPk($objCredit->id); if ($objFile === null) { return null; } $this->file = $objFile; switch ($objCredit->ptable) { case 'tl_article': $objArticle = \ArticleModel::findPublishedById($objCredit->parent); if ($objArticle === null) { return null; } $this->parent = $objArticle; $objJumpTo = $objArticle->getRelated('pid'); if ($objJumpTo == null) { return null; } if (!in_array($objJumpTo->id, $arrPids)) { return null; } $this->page = $objJumpTo; break; case 'tl_news': $objNews = \NewsModel::findByPk($objCredit->parent); if ($objNews === null) { return null; } $this->parent = $objNews->current(); $objNewsArchive = \NewsArchiveModel::findByPk($objNews->pid); $objJumpTo = \PageModel::findPublishedById($objNewsArchive->jumpTo); if ($objJumpTo == null) { return null; } if (!in_array($objJumpTo->id, $arrPids)) { return null; } $this->page = $objJumpTo; break; default: $this->parent = null; $this->page = null; // TODO refactor if (isset($GLOBALS['TL_FILECREDIT_MODELS'][$objCredit->ptable])) { $strClass = $GLOBALS['TL_MODELS'][$objCredit->ptable]; if (!$this->classFileExists($strClass)) { return null; } $this->loadDataContainer($objCredit->ptable); $archiveTable = $GLOBALS['TL_DCA'][$objCredit->ptable]['config']['ptable']; if (!$archiveTable || !isset($GLOBALS['TL_MODELS'][$archiveTable])) { return null; } $strArchiveClass = $GLOBALS['TL_MODELS'][$archiveTable]; if (!$this->classFileExists($strArchiveClass)) { return null; } $objItem = $strClass::findByPk($objCredit->parent); if ($objItem === null) { return null; } $this->parent = $objItem->current(); $objItemArchive = $strArchiveClass::findByPk($objItem->pid); $objJumpTo = \PageModel::findPublishedById($objItemArchive->jumpTo); if ($objJumpTo == null) { return null; } if (!in_array($objJumpTo->id, $arrPids)) { return null; } $this->page = $objJumpTo; } } return $this; }
/** * Recursively compile the navigation menu and return it as HTML string * @param integer * @param integer * @return string */ protected function renderNavigation($pid, $level = 1) { // Get all active subpages $objSubpages = \PageModel::findPublishedSubpagesWithoutGuestsByPid($pid, $this->showHidden, $this instanceof \ModuleSitemap); if ($objSubpages === null) { return ''; } $items = array(); $groups = array(); // Get all groups of the current front end user if (FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); $groups = $this->User->groups; } // Layout template fallback if ($this->navigationTpl == '') { $this->navigationTpl = 'nav_default'; } $objTemplate = new \FrontendTemplate($this->navigationTpl); $objTemplate->type = get_class($this); $objTemplate->level = 'level_' . $level++; // Get page object global $objPage; // Browse subpages while ($objSubpages->next()) { // Skip hidden sitemap pages if ($this instanceof \ModuleSitemap && $objSubpages->sitemap == 'map_never') { continue; } $subitems = ''; $_groups = deserialize($objSubpages->groups); // Do not show protected pages unless a back end or front end user is logged in if (!$objSubpages->protected || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($_groups, $groups)) || $this->showProtected || $this instanceof \ModuleSitemap && $objSubpages->sitemap == 'map_always') { // Check whether there will be subpages if ($objSubpages->subpages > 0 && (!$this->showLevel || $this->showLevel >= $level || !$this->hardLimit && ($objPage->id == $objSubpages->id || in_array($objPage->id, $this->getChildRecords($objSubpages->id, 'tl_page'))))) { $subitems = $this->renderNavigation($objSubpages->id, $level); } // Get href switch ($objSubpages->type) { case 'redirect': $href = $objSubpages->url; if (strncasecmp($href, 'mailto:', 7) === 0) { $href = \String::encodeEmail($href); } break; case 'forward': if ($objSubpages->jumpTo) { $objNext = \PageModel::findPublishedById($objSubpages->jumpTo); } else { $objNext = \PageModel::findFirstPublishedRegularByPid($objSubpages->id); } if ($objNext !== null) { $href = $this->generateFrontendUrl($objNext->row()); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $this->generateFrontendUrl($objSubpages->row()); break; } // Active page if (($objPage->id == $objSubpages->id || $objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo) && !$this instanceof \ModuleSitemap && !\Input::get('articles')) { $strClass = ($subitems != '' ? 'submenu' : '') . ($objSubpages->protected ? ' protected' : '') . ($objSubpages->cssClass != '' ? ' ' . $objSubpages->cssClass : ''); $row = $objSubpages->row(); $row['isActive'] = true; $row['subitems'] = $subitems; $row['class'] = trim($strClass); $row['title'] = specialchars($objSubpages->title, true); $row['pageTitle'] = specialchars($objSubpages->pageTitle, true); $row['link'] = $objSubpages->title; $row['href'] = $href; $row['nofollow'] = strncmp($objSubpages->robots, 'noindex', 7) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $objSubpages->description); // Override the link target if ($objSubpages->type == 'redirect' && $objSubpages->target) { $row['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; } $items[] = $row; } else { $strClass = ($subitems != '' ? 'submenu' : '') . ($objSubpages->protected ? ' protected' : '') . ($objSubpages->cssClass != '' ? ' ' . $objSubpages->cssClass : '') . (in_array($objSubpages->id, $objPage->trail) ? ' trail' : ''); // Mark pages on the same level (see #2419) if ($objSubpages->pid == $objPage->pid) { $strClass .= ' sibling'; } $row = $objSubpages->row(); $row['isActive'] = false; $row['subitems'] = $subitems; $row['class'] = trim($strClass); $row['title'] = specialchars($objSubpages->title, true); $row['pageTitle'] = specialchars($objSubpages->pageTitle, true); $row['link'] = $objSubpages->title; $row['href'] = $href; $row['nofollow'] = strncmp($objSubpages->robots, 'noindex', 7) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $objSubpages->description); // Override the link target if ($objSubpages->type == 'redirect' && $objSubpages->target) { $row['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; } $items[] = $row; } } } // Add classes first and last if (!empty($items)) { $last = count($items) - 1; $items[0]['class'] = trim($items[0]['class'] . ' first'); $items[$last]['class'] = trim($items[$last]['class'] . ' last'); } $objTemplate->items = $items; return !empty($items) ? $objTemplate->parse() : ''; }
/** * 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()) { $arrPages[$objPages->id] = $objPages->current()->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->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; $type = null; $pageId = $objPage->id; $pages = array($objPage->row()); $items = array(); // Get all pages up to the root page $objPages = \PageModel::findParentsById($objPage->pid); if ($objPages !== null) { while ($objPages->next() && $pageId > 0 && $type != 'root') { $type = $objPages->type; $pageId = $objPages->pid; $pages[] = $objPages->row(); } } // Get the first active regular page and display it instead of the root page if ($type == 'root') { $objFirstPage = \PageModel::findFirstPublishedByPid($objPages->id); $items[] = array('isRoot' => true, 'isActive' => false, 'href' => $objFirstPage !== null ? $this->generateFrontendUrl($objFirstPage->row()) : \Environment::get('base'), 'title' => specialchars($objPages->pageTitle ?: $objPages->title, true), 'link' => $objPages->title, 'data' => $objFirstPage->row(), 'class' => ''); array_pop($pages); } // Build the breadcrumb menu for ($i = count($pages) - 1; $i > 0; $i--) { if ($pages[$i]['hide'] && !$this->showHidden || !$pages[$i]['published'] && !BE_USER_LOGGED_IN) { continue; } // Get href switch ($pages[$i]['type']) { case 'redirect': $href = $pages[$i]['url']; if (strncasecmp($href, 'mailto:', 7) === 0) { $href = \String::encodeEmail($href); } break; case 'forward': $objNext = \PageModel::findPublishedById($pages[$i]['jumpTo']); if ($objNext !== null) { $href = $this->generateFrontendUrl($objNext->row()); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $this->generateFrontendUrl($pages[$i]); break; } $items[] = array('isRoot' => false, 'isActive' => false, 'href' => $href, 'title' => specialchars($pages[$i]['pageTitle'] ?: $pages[$i]['title'], true), 'link' => $pages[$i]['title'], 'data' => $pages[$i], 'class' => ''); } // Active article if (isset($_GET['articles'])) { $items[] = array('isRoot' => false, 'isActive' => false, 'href' => $this->generateFrontendUrl($pages[0]), 'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title'], true), 'link' => $pages[0]['title'], 'data' => $pages[0], 'class' => ''); list($strSection, $strArticle) = explode(':', \Input::get('articles')); if ($strArticle === null) { $strArticle = $strSection; } // Get the article title $objArticle = \ArticleModel::findByIdOrAlias($strArticle); if ($objArticle !== null) { $items[] = array('isRoot' => false, 'isActive' => true, 'title' => specialchars($objArticle->title, true), 'link' => $objArticle->title, 'data' => $objArticle->row(), 'class' => ''); } } else { $items[] = array('isRoot' => false, 'isActive' => true, 'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title']), 'link' => $pages[0]['title'], 'data' => $pages[0], 'class' => ''); } // Mark the first element (see #4833) $items[0]['class'] = 'first'; // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['generateBreadcrumb']) && is_array($GLOBALS['TL_HOOKS']['generateBreadcrumb'])) { foreach ($GLOBALS['TL_HOOKS']['generateBreadcrumb'] as $callback) { $this->import($callback[0]); $items = $this->{$callback}[0]->{$callback}[1]($items, $this); } } $this->Template->items = $items; }
/** * Redirect to a jumpTo page or reload the current page * * @param integer|array $intId * @param string $strParams * @param string $strForceLang */ protected function jumpToOrReload($intId, $strParams = null, $strForceLang = null) { if ($strForceLang !== null) { @trigger_error('Using Frontend::jumpToOrReload() with $strForceLang has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED); } /** @var \PageModel $objPage */ global $objPage; // Always redirect if there are additional arguments (see #5734) $blnForceRedirect = $strParams !== null || $strForceLang !== null; if (is_array($intId)) { if ($intId['id'] != '') { if ($intId['id'] != $objPage->id || $blnForceRedirect) { $this->redirect($this->generateFrontendUrl($intId, $strParams, $strForceLang, true)); } } } elseif ($intId > 0) { if ($intId != $objPage->id || $blnForceRedirect) { if (($objNextPage = \PageModel::findPublishedById($intId)) !== null) { $this->redirect($objNextPage->getFrontendUrl($strParams, $strForceLang)); } } } $this->reload(); }
protected function getTeaserDetail($explode) { $retArr = array(); $thumb = ""; $title = ""; $type = ""; $article_type = ""; $tstamp = 0; $query = "SELECT * FROM `{$explode[0]}` WHERE `id` = '" . $explode[1] . "' "; $articleRes = \Database::getInstance()->query($query)->fetchAssoc(); switch ($explode[0]) { case 'tl_article': $pageTitle = \PageModel::findPublishedById($articleRes['pid']); if ($pageTitle->thumb) { $thumb = $this->getFilePath($pageTitle->thumb); } $title = strip_tags($articleRes['teaser']); $type = "post"; $article_type = "post"; $result = \ContentModel::findPublishedByPidAndTable($explode[1], $explode[0]); if ($result) { foreach ($result as $key => $value) { $tstamp = $value->tstamp > $retArr['tstamp'] ? $value->tstamp : $retArr['tstamp']; } } break; case 'tl_news': $title = $articleRes['headline']; if ($articleRes['singleSRC']) { $thumb = $this->getFilePath($articleRes['singleSRC']); } $type = "post"; $article_type = "news"; $tstamp = $articleRes['tstamp']; break; case 'tl_calendar_events': $title = strip_tags($articleRes['title']); if ($articleRes['singleSRC']) { $thumb = $this->getFilePath($articleRes['singleSRC']); } $type = "event"; $article_type = "event"; $tstamp = $articleRes['tstamp']; break; } $retArr['thumb'] = $thumb; $retArr['pid'] = $explode[1]; $retArr['title'] = $title; $retArr['type'] = $type; $retArr['article_type'] = $article_type; $retArr['tstamp'] = $tstamp; return $retArr; }
/** * Inherit article from parent page. * * @param \PageModel $page * @param int $maxLevel * @param int $currentLevel */ protected function inheritArticle($page, $maxLevel = 0, $currentLevel = 0) { $parentPage = \PageModel::findPublishedById($page->pid); if ($parentPage === null) { return ''; } $html = $this->getPageFrontendModule($parentPage, 0, $this->strColumn, true); if ($maxLevel == 0 || $maxLevel < ++$currentLevel) { $html .= $this->inheritArticle($parentPage, $maxLevel, $currentLevel); } return $html; }
/** * Generate the module */ protected function compile() { /** @var \PageModel $objPage */ global $objPage; $items = array(); $groups = 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 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 $objPages */ $objModel = $objPages->current(); $arrPages[$objPages->id] = $objModel->loadDetails()->row(); // see #3765 } // Set default template if ($this->navigationTpl == '') { $this->navigationTpl = 'nav_default'; } /** @var \FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($this->navigationTpl); $objTemplate->type = get_class($this); $objTemplate->cssID = $this->cssID; // see #4897 and 6129 $objTemplate->level = 'level_1'; foreach ($arrPages as $arrPage) { // Skip hidden pages (see #5832) if (!is_array($arrPage)) { continue; } $_groups = deserialize($arrPage['groups']); // Do not show protected pages unless a back end or front end user is logged in if (!$arrPage['protected'] || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($_groups, $groups)) || $this->showProtected) { // 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; } $trail = in_array($arrPage['id'], $objPage->trail); // Active page if ($objPage->id == $arrPage['id'] && $href == \Environment::get('request')) { $strClass = trim($arrPage['cssClass']); $row = $arrPage; $row['isActive'] = true; $row['isTrail'] = false; $row['class'] = trim('active ' . $strClass); $row['title'] = specialchars($arrPage['title'], true); $row['pageTitle'] = specialchars($arrPage['pageTitle'], true); $row['link'] = $arrPage['title']; $row['href'] = $href; $row['nofollow'] = strncmp($arrPage['robots'], 'noindex', 7) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $arrPage['description']); // Override the link target if ($arrPage['type'] == 'redirect' && $arrPage['target']) { $row['target'] = ' target="_blank"'; } $items[] = $row; } else { $strClass = trim($arrPage['cssClass'] . ($trail ? ' trail' : '')); $row = $arrPage; $row['isActive'] = false; $row['isTrail'] = $trail; $row['class'] = $strClass; $row['title'] = specialchars($arrPage['title'], true); $row['pageTitle'] = specialchars($arrPage['pageTitle'], true); $row['link'] = $arrPage['title']; $row['href'] = $href; $row['nofollow'] = strncmp($arrPage['robots'], 'noindex', 7) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $arrPage['description']); // Override the link target if ($arrPage['type'] == 'redirect' && $arrPage['target']) { $row['target'] = ' target="_blank"'; } $items[] = $row; } } } // Add classes first and last $items[0]['class'] = trim($items[0]['class'] . ' first'); $last = count($items) - 1; $items[$last]['class'] = trim($items[$last]['class'] . ' last'); $objTemplate->items = $items; $this->Template->request = \Environment::get('indexFreeRequest'); $this->Template->skipId = 'skipNavigation' . $this->id; $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']); $this->Template->items = !empty($items) ? $objTemplate->parse() : ''; }
public function generate(array $arrOptions = array()) { $this->arrOptions = array_merge($this->arrOptions, $arrOptions); $arrData = $this->getData($this->arrOptions); if (!$arrOptions['dlh_googlemap_nocss']) { \delahaye\googlemaps\Googlemap::CssInjection(); } $this->arrOptions['staticMap'] = $this->generateStatic($this->arrOptions); $objTemplate = new \FrontendTemplate($this->arrOptions['dlh_googlemap_template']); if (!isset($GLOBALS['TL_JAVASCRIPT']['googlemaps'])) { $strUrl = '//maps.google.com/maps/api/js'; $strUrl = Url::addQueryString('language=' . $this->arrOptions['language'], $strUrl); global $objPage; if (($objRootPage = \PageModel::findPublishedById($objPage->rootId)) !== null && $objRootPage->dlh_googlemaps_apikey) { $strUrl = Url::addQueryString('key=' . $objRootPage->dlh_googlemaps_apikey, $strUrl); } $GLOBALS['TL_JAVASCRIPT']['googlemaps'] = $strUrl; } $objTemplate->map = $arrData; $objTemplate->tabs = $arrData['dlh_googlemap_tabs']; $objTemplate->labels = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels']; return $objTemplate->parse(); }
protected function generateParentList($objPage) { $type = null; $pageId = $objPage->id; $pages = array($objPage->row()); $items = array(); // Get all pages up to the root page $objPages = \PageModel::findParentsById($objPage->pid); if ($objPages !== null) { while ($pageId > 0 && $type != 'root' && $objPages->next()) { $type = $objPages->type; $pageId = $objPages->pid; $pages[] = $objPages->row(); } } // Get the first active regular page and display it instead of the root page if ($type == 'root') { $objFirstPage = \PageModel::findFirstPublishedByPid($objPages->id); $items[] = array('isRoot' => true, 'isActive' => false, 'href' => $objFirstPage !== null ? \Controller::generateFrontendUrl($objFirstPage->row()) : \Environment::get('base'), 'title' => specialchars($objPages->pageTitle ?: $objPages->title, true), 'link' => $objPages->title, 'data' => $objFirstPage->row(), 'class' => ''); array_pop($pages); } // Build the breadcrumb menu for ($i = count($pages) - 1; $i > 0; $i--) { if ($pages[$i]['hide'] && !$this->showHidden || !$pages[$i]['published'] && !BE_USER_LOGGED_IN) { continue; } // Get href switch ($pages[$i]['type']) { case 'redirect': $href = $pages[$i]['url']; if (strncasecmp($href, 'mailto:', 7) === 0) { $href = \String::encodeEmail($href); } break; case 'forward': $objNext = \PageModel::findPublishedById($pages[$i]['jumpTo']); if ($objNext !== null) { $href = \Controller::generateFrontendUrl($objNext->row()); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = \Controller::generateFrontendUrl($pages[$i]); break; } $items[] = array('isRoot' => false, 'isActive' => false, 'href' => $href, 'title' => specialchars($pages[$i]['pageTitle'] ?: $pages[$i]['title'], true), 'link' => $pages[$i]['title'], 'data' => $pages[$i], 'class' => ''); } // Active page $items[] = array('isRoot' => false, 'isActive' => true, 'href' => \Controller::generateFrontendUrl($pages[0]), 'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title']), 'link' => $pages[0]['title'], 'data' => $pages[0], 'class' => 'last'); $items[0]['class'] = 'first'; return $items; }
/** * Generate the module */ protected function compile() { global $objPage; $items = array(); $groups = 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 pages $objPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages); // Return if there are no pages if ($objPages === null) { return; } $arrPages = array(); while ($objPages->next()) { $arrPages[] = $objPages->row(); } // Set default template if ($this->navigationTpl == '') { $this->navigationTpl = 'nav_default'; } $objTemplate = new \FrontendTemplate($this->navigationTpl); $objTemplate->type = get_class($this); $objTemplate->level = 'level_1'; foreach ($arrPages as $arrPage) { $_groups = deserialize($arrPage['groups']); // Do not show protected pages unless a back end or front end user is logged in if (!$arrPage['protected'] || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($_groups, $groups)) || $this->showProtected) { // Get href switch ($arrPage['type']) { case 'redirect': $href = $arrPage['url']; break; case 'forward': if (($objNext = \PageModel::findPublishedById($arrPage['jumpTo'])) !== null) { $href = $this->generateFrontendUrl($objNext->row()); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $this->generateFrontendUrl($arrPage); break; } // Active page if ($objPage->id == $arrPage['id']) { $strClass = trim($arrPage['cssClass']); $row = $arrPage; $row['isActive'] = true; $row['class'] = trim('active ' . $strClass); $row['title'] = specialchars($arrPage['title'], true); $row['pageTitle'] = specialchars($arrPage['pageTitle'], true); $row['link'] = $arrPage['title']; $row['href'] = $href; $row['nofollow'] = strncmp($arrPage['robots'], 'noindex', 7) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $arrPage['description']); // Override the link target if ($arrPage['type'] == 'redirect' && $arrPage['target']) { $row['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; } $items[] = $row; } else { $strClass = trim($arrPage['cssClass'] . (in_array($arrPage['id'], $objPage->trail) ? ' trail' : '')); $row = $arrPage; $row['isActive'] = false; $row['class'] = $strClass; $row['title'] = specialchars($arrPage['title'], true); $row['pageTitle'] = specialchars($arrPage['pageTitle'], true); $row['link'] = $arrPage['title']; $row['href'] = $href; $row['nofollow'] = strncmp($arrPage['robots'], 'noindex', 7) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $arrPage['description']); // Override the link target if ($arrPage['type'] == 'redirect' && $arrPage['target']) { $row['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; } $items[] = $row; } } } // Add classes first and last $items[0]['class'] = trim($items[0]['class'] . ' first'); $last = count($items) - 1; $items[$last]['class'] = trim($items[$last]['class'] . ' last'); $objTemplate->items = $items; $this->Template->request = $this->getIndexFreeRequest(true); $this->Template->skipId = 'skipNavigation' . $this->id; $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']); $this->Template->items = !empty($items) ? $objTemplate->parse() : ''; }
/** * Redirect to a jumpTo page or reload the current page * @param integer|array * @param string * @param string */ protected function jumpToOrReload($intId, $strParams = null, $strForceLang = null) { global $objPage; if (is_array($intId)) { if ($intId['id'] == '' || $intId['id'] == $objPage->id) { $this->reload(); } else { $this->redirect($this->generateFrontendUrl($intId, $strParams, $strForceLang)); } } elseif ($intId > 0) { if ($intId == $objPage->id) { $this->reload(); } else { $objNextPage = \PageModel::findPublishedById($intId); if ($objNextPage !== null) { $this->redirect($this->generateFrontendUrl($objNextPage->row(), $strParams, $strForceLang)); } } } $this->reload(); }
/** * Generate the module */ protected function compile() { global $objPage; $this->import('Sermoner'); $this->Template->sermons = ''; // Get the sermon item $objSermon = \SermonerItemsModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->serm_sermonarchive); if ($objSermon === 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->sermons = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>'; return; } //Add OG-Tags for Facebook to Head $GLOBALS['TL_HEAD'][] = '<meta property="og:title" content="' . $objSermon->title . '"/>'; $GLOBALS['TL_HEAD'][] = '<meta property="og:description" content="Eine Predigt der Kirche Lindenwiese mit ' . $objSermon->speaker . '"/>'; // Add an image if ($objSermon->addImage && $objSermon->singleSRC != '') { $objModel = \FilesModel::findByUuid($objSermon->singleSRC); if (is_file(TL_ROOT . '/' . $objModel->path)) { $GLOBALS['TL_HEAD'][] = '<meta property="og:image" content="' . \Environment::get('base') . $objModel->path . '"/>'; } } //Configuration $objConfig = new \stdClass(); $objConfig->template = $this->serm_template; $strSermon = $this->Sermoner->parseSermon($objSermon, false, '', 0, $objConfig); $this->Template->sermons = $strSermon; // Overwrite the page title (see #2853 and #4955) if ($objSermon->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objSermon->title)); } //Weiterleitung auf Predigtarchiv, wenn in Moduleeinstellungen gesetzt (Ausnahme: Facebook-Crawler) if ($this->skipReader) { if (\Environment::get('httpUserAgent') != "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)") { if (($objNextPage = \PageModel::findPublishedById($this->jumpToList)) !== null) { $this->redirect($this->generateFrontendUrl($objNextPage->row()) . "#" . standardize(\String::restoreBasicEntities($objSermon->title))); } } } return; }