當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PageModel::findFirstPublishedByPid方法代碼示例

本文整理匯總了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;
 }
開發者ID:rikaix,項目名稱:core,代碼行數:21,代碼來源:PageRoot.php

示例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;
 }
開發者ID:iCodr8,項目名稱:core,代碼行數:22,代碼來源:PageRoot.php

示例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;
 }
開發者ID:bytehead,項目名稱:contao-core,代碼行數:26,代碼來源:PageRoot.php

示例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;
 }
開發者ID:rburch,項目名稱:core,代碼行數:78,代碼來源:ModuleBreadcrumb.php

示例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;
 }
開發者ID:eknoes,項目名稱:core,代碼行數:82,代碼來源:ModuleBreadcrumb.php

示例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;
 }
開發者ID:heimrichhannot,項目名稱:contao-watchlist,代碼行數:53,代碼來源:Watchlist.php

示例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;
 }
開發者ID:verstaerker,項目名稱:i18nl10n,代碼行數:44,代碼來源:I18nl10n.php

示例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;
 }
開發者ID:verstaerker,項目名稱:i18nl10n,代碼行數:79,代碼來源:I18nl10nFrontend.php


注:本文中的PageModel::findFirstPublishedByPid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。