本文整理汇总了PHP中PageModel::findFirstPublishedRegularByPid方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::findFirstPublishedRegularByPid方法的具体用法?PHP PageModel::findFirstPublishedRegularByPid怎么用?PHP PageModel::findFirstPublishedRegularByPid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::findFirstPublishedRegularByPid方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* 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);
}
示例2: generate
/**
* Redirect to an internal page
* @param \PageModel $objPage
*/
public function generate($objPage)
{
// Forward to the jumpTo or first published page
if ($objPage->jumpTo) {
/** @var \PageModel $objNextPage */
$objNextPage = $objPage->getRelated('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', __METHOD__, TL_ERROR);
die_nicely('be_no_forward', 'Forward page not found');
}
$strForceLang = null;
// Check the target page language (see #4706)
if (\Config::get('addLanguageToUrl')) {
$objNextPage->loadDetails();
// see #3983
$strForceLang = $objNextPage->language;
}
$strGet = '';
$strQuery = \Environment::get('queryString');
$arrQuery = array();
// Extract the query string keys (see #5867)
if ($strQuery != '') {
$arrChunks = explode('&', $strQuery);
foreach ($arrChunks as $strChunk) {
list($k, ) = explode('=', $strChunk, 2);
$arrQuery[] = $k;
}
}
// Add $_GET parameters
if (!empty($_GET)) {
foreach (array_keys($_GET) as $key) {
if (\Config::get('disableAlias') && $key == 'id') {
continue;
}
if (\Config::get('addLanguageToUrl') && $key == 'language') {
continue;
}
// Ignore the query string parameters (see #5867)
if (in_array($key, $arrQuery)) {
continue;
}
// Ignore the auto_item parameter (see #5886)
if ($key == 'auto_item') {
$strGet .= '/' . \Input::get($key);
} else {
$strGet .= '/' . $key . '/' . \Input::get($key);
}
}
}
// Append the query string (see #5867)
if ($strQuery != '') {
$strQuery = '?' . $strQuery;
}
$this->redirect($this->generateFrontendUrl($objNextPage->row(), $strGet, $strForceLang) . $strQuery, $objPage->redirect == 'temporary' ? 302 : 301);
}
示例3: renderNavigation
/**
* Recursively compile the navigation menu and return it as HTML string
* @param integer
* @param integer
* @param string
* @param string
* @return string
*/
protected function renderNavigation($pid, $level = 1, $host = null, $language = null)
{
// 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->cssID = $this->cssID;
// see #4897
$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);
// 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 || 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->Database->getChildRecords($objSubpages->id, 'tl_page'))))) {
$subitems = $this->renderNavigation($objSubpages->id, $level, $host, $language);
}
// 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 = $objSubpages->getRelated('jumpTo');
} else {
$objNext = \PageModel::findFirstPublishedRegularByPid($objSubpages->id);
}
if ($objNext !== null) {
// Hide the link if the target page is invisible
if (!$objNext->published || $objNext->start != '' && $objNext->start > time() || $objNext->stop != '' && $objNext->stop < time()) {
continue 2;
}
$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($objSubpages->row(), null, $language, true);
break;
}
$row = $objSubpages->row();
// Active page
if (($objPage->id == $objSubpages->id || $objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo) && !$this instanceof \ModuleSitemap && !\Input::get('articles')) {
// Mark active forward pages (see #4822)
$strClass = ($objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo ? 'forward' . (in_array($objSubpages->id, $objPage->trail) ? ' trail' : '') : 'active') . ($subitems != '' ? ' submenu' : '') . ($objSubpages->protected ? ' protected' : '') . ($objSubpages->cssClass != '' ? ' ' . $objSubpages->cssClass : '');
$row['isActive'] = true;
} else {
$strClass = ($subitems != '' ? 'submenu' : '') . ($objSubpages->protected ? ' protected' : '') . (in_array($objSubpages->id, $objPage->trail) ? ' trail' : '') . ($objSubpages->cssClass != '' ? ' ' . $objSubpages->cssClass : '');
// Mark pages on the same level (see #2419)
if ($objSubpages->pid == $objPage->pid) {
$strClass .= ' sibling';
}
$row['isActive'] = false;
}
$row['subitems'] = $subitems;
//.........这里部分代码省略.........
示例4: doReplace
//.........这里部分代码省略.........
$strTitle = 'Go back';
}
$strName = $strTitle;
} elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) {
$strUrl = $elements[1];
$strTitle = $elements[1];
$strName = str_replace(array('http://', 'https://'), '', $elements[1]);
} else {
// User login page
if ($elements[1] == 'login') {
if (!FE_USER_LOGGED_IN) {
break;
}
$this->import('FrontendUser', 'User');
$elements[1] = $this->User->loginPage;
}
$objNextPage = \PageModel::findByIdOrAlias($elements[1]);
if ($objNextPage === null) {
break;
}
// Page type specific settings (thanks to Andreas Schempp)
switch ($objNextPage->type) {
case 'redirect':
$strUrl = $objNextPage->url;
if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
$strUrl = \StringUtil::encodeEmail($strUrl);
}
break;
case 'forward':
if ($objNextPage->jumpTo) {
/** @var PageModel $objNext */
$objNext = $objNextPage->getRelated('jumpTo');
} else {
$objNext = \PageModel::findFirstPublishedRegularByPid($objNextPage->id);
}
if ($objNext instanceof PageModel) {
$strUrl = $objNext->getFrontendUrl();
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
$strUrl = $objNextPage->getFrontendUrl();
break;
}
$strName = $objNextPage->title;
$strTarget = $objNextPage->target ? ' target="_blank"' : '';
$strTitle = $objNextPage->pageTitle ?: $objNextPage->title;
}
// Replace the tag
switch (strtolower($elements[0])) {
case 'link':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, \StringUtil::specialchars($strTitle), $strTarget, $strName);
break;
case 'link_open':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>', $strUrl, \StringUtil::specialchars($strTitle), $strTarget);
break;
case 'link_url':
$arrCache[$strTag] = $strUrl;
break;
case 'link_title':
$arrCache[$strTag] = \StringUtil::specialchars($strTitle);
break;
case 'link_target':
$arrCache[$strTag] = $strTarget;
break;
示例5: compile
/**
* 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;
}
示例6: replaceInsertTags
//.........这里部分代码省略.........
if (!strlen($strTitle)) {
$strTitle = 'Go back';
}
$strName = $strTitle;
} elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) {
$strUrl = $elements[1];
$strTitle = $elements[1];
$strName = str_replace(array('http://', 'https://'), '', $elements[1]);
} else {
// User login page
if ($elements[1] == 'login') {
if (!FE_USER_LOGGED_IN) {
break;
}
$this->import('FrontendUser', 'User');
$elements[1] = $this->User->loginPage;
}
$objNextPage = \PageModel::findByIdOrAlias($elements[1]);
if ($objNextPage === null) {
break;
}
// Page type specific settings (thanks to Andreas Schempp)
switch ($objNextPage->type) {
case 'redirect':
$strUrl = $objNextPage->url;
if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
$strUrl = \String::encodeEmail($strUrl);
}
break;
case 'forward':
if (($objTarget = $objNextPage->getRelated('jumpTo')) !== null) {
$strUrl = $this->generateFrontendUrl($objTarget->row());
break;
} elseif (($objTarget = \PageModel::findFirstPublishedRegularByPid($objNextPage->id)) !== null) {
if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
$objTarget = $this->getPageDetails($objTarget);
// see #3983
$strUrl = $this->generateFrontendUrl($objTarget->row(), null, $objTarget->language);
} else {
$strUrl = $this->generateFrontendUrl($objTarget->row());
}
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
$objNextPage = $this->getPageDetails($objNextPage);
// see #3983
$strUrl = $this->generateFrontendUrl($objNextPage->row(), null, $objNextPage->language);
} else {
$strUrl = $this->generateFrontendUrl($objNextPage->row());
}
break;
}
$strName = $objNextPage->title;
$strTarget = $objNextPage->target ? $objPage->outputFormat == 'xhtml' ? LINK_NEW_WINDOW : ' target="_blank"' : '';
$strTitle = $objNextPage->pageTitle ?: $objNextPage->title;
}
// Replace the tag
switch (strtolower($elements[0])) {
case 'link':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, specialchars($strTitle), $strTarget, specialchars($strName));
break;
case 'link_open':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>', $strUrl, specialchars($strTitle), $strTarget);
示例7: replaceInsertTags
//.........这里部分代码省略.........
$strTitle = 'Go back';
}
$strName = $strTitle;
} elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) {
$strUrl = $elements[1];
$strTitle = $elements[1];
$strName = str_replace(array('http://', 'https://'), '', $elements[1]);
} else {
// User login page
if ($elements[1] == 'login') {
if (!FE_USER_LOGGED_IN) {
break;
}
$this->import('FrontendUser', 'User');
$elements[1] = $this->User->loginPage;
}
$objNextPage = \PageModel::findByIdOrAlias($elements[1]);
if ($objNextPage === null) {
break;
}
// Page type specific settings (thanks to Andreas Schempp)
switch ($objNextPage->type) {
case 'redirect':
$strUrl = $this->replaceInsertTags($objNextPage->url);
// see #6765
if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
$strUrl = \String::encodeEmail($strUrl);
}
break;
case 'forward':
if ($objNextPage->jumpTo) {
$objNext = $objNextPage->getRelated('jumpTo');
} else {
$objNext = \PageModel::findFirstPublishedRegularByPid($objNextPage->id);
}
if ($objNext !== null) {
$strForceLang = null;
$objNext->loadDetails();
// Check the target page language (see #4706)
if (\Config::get('addLanguageToUrl')) {
$strForceLang = $objNext->language;
}
$strUrl = $this->generateFrontendUrl($objNext->row(), null, $strForceLang, true);
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
$strForceLang = null;
$objNextPage->loadDetails();
// Check the target page language (see #4706, #5465)
if (\Config::get('addLanguageToUrl')) {
$strForceLang = $objNextPage->language;
}
$strUrl = $this->generateFrontendUrl($objNextPage->row(), null, $strForceLang, true);
break;
}
$strName = $objNextPage->title;
$strTarget = $objNextPage->target ? $objPage->outputFormat == 'xhtml' ? LINK_NEW_WINDOW : ' target="_blank"' : '';
$strTitle = $objNextPage->pageTitle ?: $objNextPage->title;
}
// Replace the tag
switch (strtolower($elements[0])) {
case 'link':
$arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, specialchars($strTitle), $strTarget, specialchars($strName));
break;
示例8: compile
/**
* 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()) {
$arrPages[$objPages->id] = $objPages->current();
}
$arrPages = array_values(array_filter($arrPages));
// 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';
/** @var \PageModel[] $arrPages */
foreach ($arrPages as $objModel) {
$_groups = deserialize($objModel->groups);
// Do not show protected pages unless a back end or front end user is logged in
if (!$objModel->protected || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($_groups, $groups)) || $this->showProtected) {
// Get href
switch ($objModel->type) {
case 'redirect':
$href = $objModel->url;
break;
case 'forward':
if (($objNext = $objModel->getRelated('jumpTo')) !== null || ($objNext = \PageModel::findFirstPublishedRegularByPid($objModel->id)) !== null) {
/** @var \PageModel $objNext */
$href = $objNext->getFrontendUrl();
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
$href = $objModel->getFrontendUrl();
break;
}
$trail = in_array($objModel->id, $objPage->trail);
// Active page
if ($objPage->id == $objModel->id && $href == \Environment::get('request')) {
$strClass = trim($objModel->cssClass);
$row = $objModel->row();
$row['isActive'] = true;
$row['isTrail'] = false;
$row['class'] = trim('active ' . $strClass);
$row['title'] = specialchars($objModel->title, true);
$row['pageTitle'] = specialchars($objModel->pageTitle, true);
$row['link'] = $objModel->title;
$row['href'] = $href;
$row['nofollow'] = strncmp($objModel->robots, 'noindex,nofollow', 16) === 0;
$row['target'] = '';
$row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $objModel->description);
// Override the link target
if ($objModel->type == 'redirect' && $objModel->target) {
$row['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
}
$items[] = $row;
} else {
$strClass = trim($objModel->cssClass . ($trail ? ' trail' : ''));
$row = $objModel->row();
$row['isActive'] = false;
$row['isTrail'] = $trail;
$row['class'] = $strClass;
$row['title'] = specialchars($objModel->title, true);
$row['pageTitle'] = specialchars($objModel->pageTitle, true);
$row['link'] = $objModel->title;
$row['href'] = $href;
$row['nofollow'] = strncmp($objModel->robots, 'noindex,nofollow', 16) === 0;
$row['target'] = '';
$row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $objModel->description);
// Override the link target
//.........这里部分代码省略.........
示例9: getPageData
protected function getPageData($pagesResult, $imageSize = null)
{
$href = null;
if ($pagesResult->type === 'redirect') {
$href = $pagesResult->url;
if (strncasecmp($href, 'mailto:', 7) === 0) {
$href = \StringUtil::encodeEmail($href);
}
} else {
if ($pagesResult->type === 'forward') {
if ($pagesResult->jumpTo) {
$targetPage = $pagesResult->getRelated('jumpTo');
} else {
$targetPage = \PageModel::findFirstPublishedRegularByPid($pagesResult->id);
}
if ($targetPage !== null) {
$forceLang = null;
$targetPage->loadDetails();
if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
$forceLang = $targetPage->language;
}
$href = $this->generateFrontendUrl($targetPage->row(), null, $forceLang);
if ($targetPage->domain != '' && $targetPage->domain != \Environment::get('host')) {
$href = (\Environment::get('ssl') ? 'https://' : 'http://') . $targetPage->domain . TL_PATH . '/' . $href;
}
}
}
}
if (!$href) {
$href = $this->generateFrontendUrl($pagesResult->row(), null, $language);
if ($pagesResult->domain != '' && $pagesResult->domain != \Environment::get('host')) {
$href = (\Environment::get('ssl') ? 'https://' : 'http://') . $pagesResult->domain . TL_PATH . '/' . $href;
}
}
if (($GLOBALS['objPage']->id == $pagesResult->id || $pagesResult->type == 'forward' && $GLOBALS['objPage']->id == $pagesResult->jumpTo) && !\Input::get('articles')) {
$cssClass = ($pagesResult->type == 'forward' && $GLOBALS['objPage']->id == $pagesResult->jumpTo ? 'forward' . (in_array($pagesResult->id, $GLOBALS['objPage']->trail) ? ' trail' : '') : 'active') . ($pagesResult->protected ? ' protected' : '') . ($pagesResult->cssClass != '' ? ' ' . $pagesResult->cssClass : '');
$page['isActive'] = true;
} else {
$cssClass = ($pagesResult->protected ? ' protected' : '') . (in_array($pagesResult->id, $GLOBALS['objPage']->trail) ? ' trail' : '') . ($pagesResult->cssClass != '' ? ' ' . $pagesResult->cssClass : '');
if ($pagesResult->pid == $GLOBALS['objPage']->pid) {
$cssClass .= ' sibling';
}
$page['isActive'] = false;
}
$page = $pagesResult->row();
$page['class'] = trim($cssClass);
$page['title'] = specialchars($pagesResult->title, true);
$page['pageTitle'] = specialchars($pagesResult->pageTitle, true);
$page['link'] = $pagesResult->title;
$page['href'] = $href ?: './';
$page['nofollow'] = strncmp($pagesResult->robots, 'noindex', 7) === 0;
$page['target'] = '';
$page['description'] = str_replace(array("\n", "\r"), array(' ', ''), $pagesResult->description);
$page['rsmm_image'] = $this->getImageObject($page['rsmm_image'], $imageSize);
// Override the link target
if ($pagesResult->type == 'redirect' && $pagesResult->target) {
$page['target'] = ' target="_blank"';
}
return $page;
}
示例10: getFullpageNavigationUrl
public static function getFullpageNavigationUrl($arrItem)
{
$objSubpages = \PageModel::findByPk($arrItem['id']);
$language = null;
$strAlias = preg_replace('/\\/home/', '', $arrItem['alias']);
// 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 = $objSubpages->getRelated('jumpTo');
} else {
$objNext = \PageModel::findFirstPublishedRegularByPid($objSubpages->id);
}
if ($objNext !== null) {
$strForceLang = null;
$objNext->loadDetails();
// Check the target page language (see #4706)
if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
$strForceLang = $objNext->language;
}
$href = self::generateFrontendUrl($objNext->row(), '/' . $strAlias, $strForceLang);
// Add the domain if it differs from the current one (see #3765)
if ($objNext->domain != '' && $objNext->domain != \Environment::get('host')) {
$href = (\Environment::get('ssl') ? 'https://' : 'http://') . $objNext->domain . TL_PATH . '/' . $href;
}
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
$href = self::generateFrontendUrl($objSubpages->row(), null, $language);
// Add the domain if it differs from the current one (see #3765)
if ($objSubpages->domain != '' && $objSubpages->domain != \Environment::get('host')) {
$href = (\Environment::get('ssl') ? 'https://' : 'http://') . $objSubpages->domain . TL_PATH . '/' . $href;
}
break;
}
return $href;
}
示例11: compile
/**
* 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();
}
$items = array();
$arrPages = array_values(array_filter($arrPages));
/** @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 || ($objNext = \PageModel::findFirstPublishedRegularByPid($objPage->id)) !== 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']);
}