/** * Collect the images from page * @param object * @param object */ public function collectPageImages($objPage, $objLayout) { if (!$objLayout->socialImages) { return; } // Initialize the array if (!is_array($GLOBALS['SOCIAL_IMAGES'])) { $GLOBALS['SOCIAL_IMAGES'] = array(); } // Add the current page image if ($objPage->socialImage && ($objImage = \FilesModel::findByUuid($objPage->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) { array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path); } else { $objTrail = \PageModel::findParentsById($objPage->id); if ($objTrail !== null) { while ($objTrail->next()) { // Add the image if ($objTrail->socialImage && ($objImage = \FilesModel::findByUuid($objTrail->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) { array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path); break; } } } } }
/** * Parse the template * @return string */ public function generate() { if (TL_MODE == 'BE') { // create new backend template $objTemplate = new \BackendTemplate('be_include'); // get the article $objArticle = \ArticleModel::findByPk($this->articleAlias); if ($objArticle === null) { return parent::generate(); } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { return parent::generate(); } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // set breadcrumb to original element $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN)); // get include breadcrumbs $includes = \IncludeInfoHelper::getIncludes('articleAlias', $this->articleAlias, $this->id); // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } // add CSS $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; // return info + content return $objTemplate->parse() . parent::generate(); } // return content only return parent::generate(); }
/** * Parse the template * @return string */ public function generate() { if (TL_MODE == 'BE') { // create new backend template $objTemplate = new \BackendTemplate('be_include'); // get all include elements $objElements = \ContentModel::findBy('module', $this->module, array('order' => 'id')); // prepare include breadcrumbs $includes = array(); // go throuch each include element while ($objElements->next()) { // get the parent article $objArticle = \ArticleModel::findByPk($objElements->pid); if ($objArticle === null) { continue; } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { continue; } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // css classes for list $classes = array(); if ($objElements->id == $this->id) { $classes[] = 'self'; } if ($objElements->invisible) { $classes[] = 'hidden'; } // create breadcrumb $includes[] = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN), 'class' => implode(' ', $classes)); } // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } // add CSS $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; // return info + content return $objTemplate->parse() . parent::generate(); } // return content only return parent::generate(); }
public static function getIncludes($where, $includeId, $selfId = null) { // get all include elements $objElements = \ContentModel::findBy($where, $includeId, array('order' => 'id')); // check for result if ($objElements === null) { return array(); } // prepare include breadcrumbs $includes = array(); // go throuch each include element while ($objElements->next()) { // get the parent article $objArticle = \ArticleModel::findByPk($objElements->pid); if ($objArticle === null) { continue; } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { continue; } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // css classes for list $classes = array(); if ($objElements->id == $selfId) { $classes[] = 'self'; } if ($objElements->invisible) { $classes[] = 'hidden'; } // create breadcrumb $includes[] = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN), 'class' => implode(' ', $classes)); } // return the include elements return $includes; }
public function addWebfonts(\PageModel $objPage, \LayoutModel $objLayout, \PageRegular $objPageRegular) { $objRecords = $this->Database->prepare("SELECT * FROM tl_webfonts WHERE published=1 ORDER by sorting ASC")->execute(); if ($objRecords !== null) { while ($objRecords->next()) { $arrPages = unserialize($objRecords->pages); foreach ($arrPages as $intPageId) { $arrWebfonts[$intPageId] = $objRecords; } if (isset($arrWebfonts[$objPage->id])) { $this->callProvider($arrWebfonts[$objPage->id]); } else { $objParentPage = \PageModel::findParentsById($objPage->id); if ($objParentPage !== null) { while ($objParentPage->next()) { if (isset($arrWebfonts[$objParentPage->id])) { $this->callProvider($arrWebfonts[$objParentPage->id]); } } } } } } }
/** * Get the details of a page including inherited parameters * * @return static The page model */ public function loadDetails() { // Loaded already if ($this->blnDetailsLoaded) { return $this; } // Set some default values $this->protected = (bool) $this->protected; $this->groups = $this->protected ? deserialize($this->groups) : false; $this->layout = $this->includeLayout ? $this->layout : false; $this->mobileLayout = $this->includeLayout ? $this->mobileLayout : false; $this->cache = $this->includeCache ? $this->cache : false; $pid = $this->pid; $type = $this->type; $alias = $this->alias; $name = $this->title; $title = $this->pageTitle ?: $this->title; $folderUrl = ''; $palias = ''; $pname = ''; $ptitle = ''; $trail = array($this->id, $pid); // Inherit the settings if ($this->type == 'root') { $objParentPage = $this; // see #4610 } else { // Load all parent pages $objParentPage = \PageModel::findParentsById($pid); if ($objParentPage !== null) { while ($pid > 0 && $type != 'root' && $objParentPage->next()) { $pid = $objParentPage->pid; $type = $objParentPage->type; // Parent title if ($ptitle == '') { $palias = $objParentPage->alias; $pname = $objParentPage->title; $ptitle = $objParentPage->pageTitle ?: $objParentPage->title; } // Page title if ($type != 'root') { $alias = $objParentPage->alias; $name = $objParentPage->title; $title = $objParentPage->pageTitle ?: $objParentPage->title; $folderUrl = basename($alias) . '/' . $folderUrl; $trail[] = $objParentPage->pid; } // Cache if ($objParentPage->includeCache && $this->cache === false) { $this->cache = $objParentPage->cache; } // Layout if ($objParentPage->includeLayout) { if ($this->layout === false) { $this->layout = $objParentPage->layout; } if ($this->mobileLayout === false) { $this->mobileLayout = $objParentPage->mobileLayout; } } // Protection if ($objParentPage->protected && $this->protected === false) { $this->protected = true; $this->groups = deserialize($objParentPage->groups); } } } // Set the titles $this->mainAlias = $alias; $this->mainTitle = $name; $this->mainPageTitle = $title; $this->parentAlias = $palias; $this->parentTitle = $pname; $this->parentPageTitle = $ptitle; $this->folderUrl = $folderUrl; } // Set the root ID and title if ($objParentPage !== null && $objParentPage->type == 'root') { $this->rootId = $objParentPage->id; $this->rootAlias = $objParentPage->alias; $this->rootTitle = $objParentPage->title; $this->rootPageTitle = $objParentPage->pageTitle ?: $objParentPage->title; $this->domain = $objParentPage->dns; $this->rootLanguage = $objParentPage->language; $this->language = $objParentPage->language; $this->staticFiles = $objParentPage->staticFiles; $this->staticPlugins = $objParentPage->staticPlugins; $this->dateFormat = $objParentPage->dateFormat; $this->timeFormat = $objParentPage->timeFormat; $this->datimFormat = $objParentPage->datimFormat; $this->adminEmail = $objParentPage->adminEmail; // Store whether the root page has been published $time = \Date::floorToMinute(); $this->rootIsPublic = $objParentPage->published && ($objParentPage->start == '' || $objParentPage->start <= $time) && ($objParentPage->stop == '' || $objParentPage->stop > $time + 60); $this->rootIsFallback = true; $this->rootUseSSL = $objParentPage->useSSL; $this->rootFallbackLanguage = $objParentPage->language; // Store the fallback language (see #6874) if (!$objParentPage->fallback) { $this->rootIsFallback = false; $this->rootFallbackLanguage = null; $objFallback = static::findPublishedFallbackByHostname($objParentPage->dns); if ($objFallback !== null) { $this->rootFallbackLanguage = $objFallback->language; } } } elseif (TL_MODE == 'FE' && $this->type != 'root') { header('HTTP/1.1 404 Not Found'); \System::log('Page ID "' . $this->id . '" does not belong to a root page', __METHOD__, TL_ERROR); die_nicely('be_no_root', 'No root page found'); } $this->trail = array_reverse($trail); // Do not cache protected pages if ($this->protected) { $this->cache = 0; } // Use the global date format if none is set (see #6104) if ($this->dateFormat == '') { $this->dateFormat = \Config::get('dateFormat'); } if ($this->timeFormat == '') { $this->timeFormat = \Config::get('timeFormat'); } if ($this->datimFormat == '') { $this->datimFormat = \Config::get('datimFormat'); } // Prevent saving (see #6506 and #7199) $this->preventSaving(); $this->blnDetailsLoaded = true; return $this; }
/** * 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; }
/** * Generate the module */ protected function compile() { /** @var \PageModel $objPage */ global $objPage; $type = null; $pageId = $objPage->id; $pages = array($objPage); $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->current(); } } // 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 ? $objFirstPage->getFrontendUrl() : \Environment::get('base'), 'title' => specialchars($objPages->pageTitle ?: $objPages->title, true), 'link' => $objPages->title, 'data' => $objFirstPage->row(), 'class' => ''); array_pop($pages); } /** @var \PageModel[] $pages */ 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 = \StringUtil::encodeEmail($href); } break; case 'forward': if (($objNext = $pages[$i]->getRelated('jumpTo')) !== null || ($objNext = \PageModel::findFirstPublishedRegularByPid($pages[$i]->id)) !== null) { /** @var \PageModel $objNext */ $href = $objNext->getFrontendUrl(); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $pages[$i]->getFrontendUrl(); 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]->row(), 'class' => ''); } // Active article if (isset($_GET['articles'])) { $items[] = array('isRoot' => false, 'isActive' => false, 'href' => $pages[0]->getFrontendUrl(), 'title' => specialchars($pages[0]->pageTitle ?: $pages[0]->title, true), 'link' => $pages[0]->title, 'data' => $pages[0]->row(), 'class' => ''); list($strSection, $strArticle) = explode(':', \Input::get('articles')); if ($strArticle === null) { $strArticle = $strSection; } $objArticle = \ArticleModel::findByIdOrAlias($strArticle); $strAlias = $objArticle->alias != '' && !\Config::get('disableAlias') ? $objArticle->alias : $objArticle->id; if ($objArticle->inColumn != 'main') { $strAlias = $objArticle->inColumn . ':' . $strAlias; } if ($objArticle !== null) { $items[] = array('isRoot' => false, 'isActive' => true, 'href' => $pages[0]->getFrontendUrl('/articles/' . $strAlias), 'title' => specialchars($objArticle->title, true), 'link' => $objArticle->title, 'data' => $objArticle->row(), 'class' => ''); } } else { $items[] = array('isRoot' => false, 'isActive' => true, 'href' => $pages[0]->getFrontendUrl(), 'title' => specialchars($pages[0]->pageTitle ?: $pages[0]->title), 'link' => $pages[0]->title, 'data' => $pages[0]->row(), '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; }
/** * Get the details of a page including inherited parameters * * @param mixed $intId A page ID or a Model object * * @return \Model|null The page model or null */ protected function getPageDetails($intId) { if (is_object($intId)) { $objPage = $intId; $intId = $objPage->id; $strKey = __METHOD__ . '-' . $objPage->id; if (\Cache::has($strKey)) { return \Cache::get($strKey); } } else { if (!strlen($intId) || $intId < 1) { return null; } $strKey = __METHOD__ . '-' . $intId; if (\Cache::has($strKey)) { return \Cache::get($strKey); } $objPage = \PageModel::findByPk($intId); if ($objPage === null) { return null; } } // Set some default values $objPage->protected = (bool) $objPage->protected; $objPage->groups = $objPage->protected ? deserialize($objPage->groups) : false; $objPage->layout = $objPage->includeLayout ? $objPage->layout : false; $objPage->mobileLayout = $objPage->includeLayout ? $objPage->mobileLayout : false; $objPage->cache = $objPage->includeCache ? $objPage->cache : false; $pid = $objPage->pid; $type = $objPage->type; $alias = $objPage->alias; $name = $objPage->title; $title = $objPage->pageTitle ?: $objPage->title; $folderUrl = basename($objPage->alias); $palias = ''; $pname = ''; $ptitle = ''; $trail = array($intId, $pid); // Load all parent pages $objParentPage = \PageModel::findParentsById($pid); // Inherit settings if ($objParentPage !== null) { while ($objParentPage->next() && $pid > 0 && $type != 'root') { $pid = $objParentPage->pid; $type = $objParentPage->type; // Parent title if ($ptitle == '') { $palias = $objParentPage->alias; $pname = $objParentPage->title; $ptitle = $objParentPage->pageTitle ?: $objParentPage->title; } // Page title if ($type != 'root') { $alias = $objParentPage->alias; $name = $objParentPage->title; $title = $objParentPage->pageTitle ?: $objParentPage->title; $folderUrl = basename($alias) . '/' . $folderUrl; $trail[] = $objParentPage->pid; } // Cache if ($objParentPage->includeCache && $objPage->cache === false) { $objPage->cache = $objParentPage->cache; } // Layout if ($objParentPage->includeLayout) { if ($objPage->layout === false) { $objPage->layout = $objParentPage->layout; } if ($objPage->mobileLayout === false) { $objPage->mobileLayout = $objParentPage->mobileLayout; } } // Protection if ($objParentPage->protected && $objPage->protected === false) { $objPage->protected = true; $objPage->groups = deserialize($objParentPage->groups); } } } // Set the titles $objPage->mainAlias = $alias; $objPage->mainTitle = $name; $objPage->mainPageTitle = $title; $objPage->parentAlias = $palias; $objPage->parentTitle = $pname; $objPage->parentPageTitle = $ptitle; $objPage->folderUrl = $folderUrl; // Set the root ID and title if ($objParentPage !== null && $objParentPage->type == 'root') { $objPage->rootId = $objParentPage->id; $objPage->rootTitle = $objParentPage->pageTitle ?: $objParentPage->title; $objPage->domain = $objParentPage->dns; $objPage->rootLanguage = $objParentPage->language; $objPage->language = $objParentPage->language; $objPage->staticFiles = $objParentPage->staticFiles; $objPage->staticSystem = $objParentPage->staticSystem; $objPage->staticPlugins = $objParentPage->staticPlugins; $objPage->dateFormat = $objParentPage->dateFormat; $objPage->timeFormat = $objParentPage->timeFormat; $objPage->datimFormat = $objParentPage->datimFormat; $objPage->adminEmail = $objParentPage->adminEmail; // Store whether the root page has been published $time = time(); $objPage->rootIsPublic = $objParentPage->published && ($objParentPage->start == '' || $objParentPage->start < $time) && ($objParentPage->stop == '' || $objParentPage->stop > $time); $objPage->rootIsFallback = $objParentPage->fallback != ''; } elseif (TL_MODE == 'FE' && $objPage->type != 'root') { header('HTTP/1.1 404 Not Found'); $this->log('Page ID "' . $objPage->id . '" does not belong to a root page', 'Controller getPageDetails()', TL_ERROR); die('No root page found'); } $objPage->trail = array_reverse($trail); // Remove insert tags from all titles (see #2853) $objPage->title = strip_insert_tags($objPage->title); $objPage->pageTitle = strip_insert_tags($objPage->pageTitle); $objPage->parentTitle = strip_insert_tags($objPage->parentTitle); $objPage->parentPageTitle = strip_insert_tags($objPage->parentPageTitle); $objPage->mainTitle = strip_insert_tags($objPage->mainTitle); $objPage->mainPageTitle = strip_insert_tags($objPage->mainPageTitle); $objPage->rootTitle = strip_insert_tags($objPage->rootTitle); // Do not cache protected pages if ($objPage->protected) { $objPage->cache = 0; } \Cache::set($strKey, $objPage); return $objPage; }
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 widget and return it as string * @return string */ public function generate() { // create new include template $objTemplate = new \BackendTemplate('be_include'); // get the active record $activeRecord = $this->arrConfiguration['activeRecord']; // get the type $type = $activeRecord->type; // get the table $table = $this->arrConfiguration['strTable']; // depending on type if ($type == 'alias') { // get the element $objElement = \ContentModel::findByPk($activeRecord->cteAlias); if ($objElement === null) { return ''; } // get the parent article $objArticle = \ArticleModel::findByPk($objElement->pid); if ($objArticle === null) { return parent::generate(); } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { return parent::generate(); } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // set breadcrumb to original element $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN)); // get include breadcrumbs $includes = \IncludeInfoHelper::getIncludes('cteAlias', $activeRecord->cteAlias, $activeRecord->id); // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } } elseif ($type == 'article') { // get the article $objArticle = \ArticleModel::findByPk($activeRecord->articleAlias); if ($objArticle === null) { return parent::generate(); } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { return parent::generate(); } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // set breadcrumb to original element $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN)); // get include breadcrumbs $includes = \IncludeInfoHelper::getIncludes('articleAlias', $activeRecord->articleAlias, $activeRecord->id); // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } } elseif ($table == 'tl_content') { // get include breadcrumbs that reference this content element $includes = \IncludeInfoHelper::getIncludes(array("cteAlias = ? AND type = 'alias'"), array($activeRecord->id)); // set include breadcrumbs if (count($includes) > 0) { $objTemplate->includes = $includes; } } elseif ($table == 'tl_article') { // get include breadcrumbs that reference this article $includes = \IncludeInfoHelper::getIncludes(array("articleAlias = ? AND type = 'article'"), array($activeRecord->id)); // set include breadcrumbs if (count($includes) > 0) { $objTemplate->includes = $includes; } } elseif ($table == 'tl_module') { // get include breadcrumbs that reference this module $includes = \IncludeInfoHelper::getIncludes(array("module = ? AND type = 'module'"), array($activeRecord->id)); // set include breadcrumbs if (count($includes) > 0) { $objTemplate->includes = $includes; } } // check for includes and add CSS if ($objTemplate->includes) { $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; } // return template return $objTemplate->parse(); }
public static function getRootDomain($intPage) { if (($objTarget = \PageModel::findByPk($intPage)) !== null) { if ($objTarget->type == 'root') { return static::doGetRootDomain($objTarget); } else { foreach (\PageModel::findParentsById($objTarget->id) as $objParent) { if ($objParent->type == 'root') { return static::doGetRootDomain($objParent); } } } } return false; }