本文整理汇总了PHP中PageModel::findFirstPublishedByPid方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::findFirstPublishedByPid方法的具体用法?PHP PageModel::findFirstPublishedByPid怎么用?PHP PageModel::findFirstPublishedByPid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::findFirstPublishedByPid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Redirect to the first active regular page
* @param integer
* @param boolean
* @return integer
* @return integer
*/
public function generate($pageId, $blnReturn = false)
{
$objNextPage = \PageModel::findFirstPublishedByPid($pageId);
// No published pages yet
if ($objNextPage === null) {
header('HTTP/1.1 404 Not Found');
$this->log('No active page found under root page "' . $pageId . '")', 'PageRoot generate()', TL_ERROR);
die('No active pages found');
}
if (!$blnReturn) {
$this->redirect($this->generateFrontendUrl($objNextPage->row()));
}
return $objNextPage->id;
}
示例2: generate
/**
* Redirect to the first active regular page
* @param integer
* @param boolean
* @return integer
* @return integer
*/
public function generate($pageId, $blnReturn = false)
{
$objNextPage = \PageModel::findFirstPublishedByPid($pageId);
// No published pages yet
if ($objNextPage === null) {
header('HTTP/1.1 404 Not Found');
$this->log('No active page found under root page "' . $pageId . '")', __METHOD__, TL_ERROR);
die_nicely('be_no_active', 'No active pages found');
}
if (!$blnReturn) {
global $objPage;
$this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objPage->language));
}
return $objNextPage->id;
}
示例3: generate
/**
* Redirect to the first active regular page
*
* @param integer $pageId
* @param boolean $blnReturn
* @param boolean $blnPreferAlias
*
* @return integer
*/
public function generate($pageId, $blnReturn = false, $blnPreferAlias = false)
{
$objNextPage = \PageModel::findFirstPublishedByPid($pageId);
// No published pages yet
if (null === $objNextPage) {
header('HTTP/1.1 404 Not Found');
$this->log('No active page found under root page "' . $pageId . '"', __METHOD__, TL_ERROR);
die_nicely('be_no_active', 'No active pages found');
}
if (!$blnReturn) {
$this->redirect($objNextPage->getFrontendUrl());
}
if ($blnPreferAlias && $objNextPage->alias != '') {
return $objNextPage->alias;
}
return $objNextPage->id;
}
示例4: compile
/**
* 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;
}
示例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: generateParentList
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;
}
示例7: replaceI18nl10nInsertTags
/**
* Replace i18nl10n insert tags
*
* @param string $strTag
* @param bool $blnCache
*
* @return bool|string
*/
public static function replaceI18nl10nInsertTags($strTag, $blnCache = true)
{
global $objPage;
$arrArguments = explode('::', $strTag);
if ($arrArguments[0] === 'i18nl10n' && $arrArguments[1] === 'link') {
$objNextPage = I18nl10n::getInstance()->findL10nWithDetails($arrArguments[2], $GLOBALS['TL_LANGUAGE']);
if ($objNextPage === null) {
return false;
}
switch ($objNextPage->type) {
case 'redirect':
$strUrl = parent::replaceInsertTags($objNextPage->url);
if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
$strUrl = \String::encodeEmail($strUrl);
}
break;
case 'forward':
$intForwardId = $objNextPage->jumpTo ?: \PageModel::findFirstPublishedByPid($objNextPage->id)->current()->id;
$objNext = \PageModel::findWithDetails($intForwardId);
if ($objNext !== null) {
$strUrl = self::generateFrontendUrl($objNext->row(), null, '');
break;
}
// no break
// no break
default:
$strUrl = self::generateFrontendUrl($objNextPage->row(), null, '');
break;
}
$strName = $objNextPage->title;
$strTarget = $objNextPage->target ? $objPage->outputFormat == 'xhtml' ? LINK_NEW_WINDOW : ' target="_blank"' : '';
$strTitle = $objNextPage->pageTitle ?: $objNextPage->title;
return sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, specialchars($strTitle), $strTarget, specialchars($strName));
}
return false;
}
示例8: i18nl10nNavItems
/**
* Replace title and pageTitle with translated equivalents
* just before display them as menu.
*
* @param Array $items The menu items on the current menu level
* @param Bool [$blnUseFallback] Keep original item if no translation found
* @return Array $i18n_items
*/
public function i18nl10nNavItems(array $items, $blnUseFallback = false)
{
if (empty($items)) {
return false;
}
/**
* Info:
* Be aware that Contao 3.4.0 supports 'isActive' only for start pages
* with the alias 'index'. See ticket #7562 (https://github.com/contao/core/issues/7562)
*/
$arrLanguages = I18nl10n::getInstance()->getLanguagesByDomain();
//get item ids
$item_ids = array();
foreach ($items as $row) {
$item_ids[] = $row['id'];
}
$arrI18nItems = array();
if ($GLOBALS['TL_LANGUAGE'] !== $arrLanguages['default']) {
$time = time();
$fields = 'alias,pid,title,pageTitle,description,url,language';
$sqlPublishedCondition = $blnUseFallback || BE_USER_LOGGED_IN ? '' : " AND (start='' OR start < {$time}) AND (stop='' OR stop > {$time}) AND i18nl10n_published = 1 ";
$sql = "\n SELECT {$fields}\n FROM tl_page_i18nl10n\n WHERE\n " . $this->Database->findInSet('pid', $item_ids) . '
AND language = ?
' . $sqlPublishedCondition;
$arrLocalizedPages = $this->Database->prepare($sql)->limit(1000)->execute($GLOBALS['TL_LANGUAGE'])->fetchAllassoc();
foreach ($items as $item) {
$foundItem = false;
foreach ($arrLocalizedPages as $row) {
// Update navigation items with localization values
if ($row['pid'] === $item['id']) {
$foundItem = true;
$alias = $row['alias'] ?: $item['alias'];
$item['alias'] = $alias;
$row['alias'] = $alias;
$item['language'] = $row['language'];
switch ($item['type']) {
case 'forward':
$intForwardId = $item['jumpTo'] ?: \PageModel::findFirstPublishedByPid($item['id'])->current()->id;
$arrPage = \PageModel::findWithDetails($intForwardId)->row();
$item['href'] = $this->generateFrontendUrl($arrPage);
break;
case 'redirect':
if ($row['url']) {
$item['href'] = $row['url'];
}
break;
default:
$item['href'] = $this->generateFrontendUrl($item);
break;
}
$item['pageTitle'] = specialchars($row['pageTitle'], true);
$item['title'] = specialchars($row['title'], true);
$item['link'] = $item['title'];
$item['description'] = str_replace(array('\\n', '\\r'), array(' ', ''), specialchars($row['description']));
array_push($arrI18nItems, $item);
}
}
if ($blnUseFallback && !$foundItem) {
array_push($arrI18nItems, $item);
}
}
} else {
foreach ($items as $item) {
if (!$blnUseFallback && $item['i18nl10n_published'] == '') {
continue;
}
array_push($arrI18nItems, $item);
}
}
return $arrI18nItems;
}