当前位置: 首页>>代码示例>>PHP>>正文


PHP PageModel::find404ByPid方法代码示例

本文整理汇总了PHP中PageModel::find404ByPid方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::find404ByPid方法的具体用法?PHP PageModel::find404ByPid怎么用?PHP PageModel::find404ByPid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PageModel的用法示例。


在下文中一共展示了PageModel::find404ByPid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * 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);
 }
开发者ID:Jobu,项目名称:core,代码行数:67,代码来源:PageError404.php

示例2: generate

 /**
  * 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);
 }
开发者ID:rburch,项目名称:core,代码行数:56,代码来源:PageError404.php


注:本文中的PageModel::find404ByPid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。