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


PHP PageModel::findPublishedByIdOrAlias方法代码示例

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


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

示例1: processFormData

 public function processFormData($arrSubmitted, $arrData, $arrFiles, $arrLabels, \Form $objForm)
 {
     // check if there is a form field which we use as the code
     if (($objField = \FormFieldModel::findBy(array("pid = ?", "useCode = '1'"), array($objForm->id))) === null) {
         return;
     }
     // check if there is submitted data for the form field
     if (!isset($arrSubmitted[$objField->name])) {
         return;
     }
     // get the code
     $code = $arrSubmitted[$objField->name];
     // check if there is a page present for this alias
     if (($objPage = \PageModel::findPublishedByIdOrAlias($code)) === null) {
         return;
     }
     // redirect to page
     \Controller::redirect(\Controller::generateFrontendUrl($objPage->row(), null, null, true));
 }
开发者ID:fritzmg,项目名称:contao-form-code-redirect,代码行数:19,代码来源:FormCodeRedirect.php

示例2: processTarget

 public static function processTarget($target)
 {
     // replace insert tags for Contao 3.5.7 and up
     if (version_compare(VERSION . '.' . BUILD, '3.5.7', '>=')) {
         $target = \Controller::replaceInsertTags($target);
     }
     // check for insert tag
     if (stripos($target, '{{link_url::') === 0) {
         // get the page id
         $pageId = substr($target, 12, strpos($target, '}}') - 12);
         // get the page
         if (($objPage = \PageModel::findPublishedByIdOrAlias($pageId)) === null) {
             return;
         }
         // load details of the page
         $objPage->current()->loadDetails();
         // generate the URL
         $target = \Controller::generateFrontendUrl($objPage->row(), null, $objPage->rootLanguage, true) . substr($target, strpos($target, '}}') + 2);
     }
     // return processed target
     return $target;
 }
开发者ID:fritzmg,项目名称:contao-short-urls,代码行数:22,代码来源:ShortURLs.php

示例3: replaceRelation

 public static function replaceRelation(array $arrRelation, $strTag)
 {
     $params = preg_split('/::/', $strTag);
     if (!isset($arrRelation['insertTagLink']) || !isset($arrRelation['table'])) {
         return false;
     }
     $relParams = str_replace(array('{', '}'), '', $arrRelation['insertTagLink']);
     $relParams = preg_split('/::/', $relParams);
     // check if given relation inserttag is provided
     if ($relParams[0] != $params[0]) {
         return false;
     }
     $pageId = null;
     $moduleId = null;
     $entityId = null;
     if (($pageIdx = array_search('PAGE_ID', $relParams)) !== false) {
         $pageId = $params[$pageIdx];
     }
     if (($entityIdx = array_search('ENTITY_ID', $relParams)) !== false) {
         $entityId = $params[$entityIdx];
     }
     if (($moduleIdx = array_search('MODULE_ID', $relParams)) !== false) {
         $moduleId = $params[$moduleIdx];
     }
     if ($pageId === null || ($objPage = \PageModel::findPublishedByIdOrAlias($pageId)) === null) {
         return false;
     }
     if ($moduleId === null || ($objModule = \ModuleModel::findByPk($moduleId)) === null) {
         return false;
     }
     if ($entityId === null || ($objEntity = SubmissionCreator::findRelatedEntity($entityId, $arrRelation, $objModule->current())) === null) {
         return false;
     }
     if (StringUtil::endsWith($params[0], '_link')) {
         return SubmissionCreator::getRelationLink($objPage->current(), $objEntity->current(), $arrRelation);
     }
     return false;
 }
开发者ID:heimrichhannot,项目名称:contao-submissions_creator,代码行数:38,代码来源:InsertTags.php

示例4: determineCurrentPage

 /**
  * Do not use global $objPage, as long as pagelink module is enabled
  * because $objPage will hold the target page
  */
 protected function determineCurrentPage()
 {
     if (!in_array('pagelink', $this->Config->getActiveModules())) {
         global $objPage;
         return $objPage;
     }
     $pageId = $this->getPageIdFromUrl();
     $objPage = \PageModel::findPublishedByIdOrAlias($pageId);
     // Check the URL and language of each page if there are multiple results
     if ($objPage !== null && $objPage->count() > 1) {
         $objNewPage = null;
         $arrPages = array();
         // Order by domain and language
         while ($objPage->next()) {
             $objCurrentPage = $objPage->current()->loadDetails();
             $domain = $objCurrentPage->domain ?: '*';
             $arrPages[$domain][$objCurrentPage->rootLanguage] = $objCurrentPage;
             // Also store the fallback language
             if ($objCurrentPage->rootIsFallback) {
                 $arrPages[$domain]['*'] = $objCurrentPage;
             }
         }
         $strHost = \Environment::get('host');
         // Look for a root page whose domain name matches the host name
         if (isset($arrPages[$strHost])) {
             $arrLangs = $arrPages[$strHost];
         } else {
             $arrLangs = $arrPages['*'];
             // Empty domain
         }
         // Use the first result (see #4872)
         if (!$GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
             $objNewPage = current($arrLangs);
         } elseif (($lang = Input::get('language')) != '' && isset($arrLangs[$lang])) {
             $objNewPage = $arrLangs[$lang];
         }
         // Store the page object
         if (is_object($objNewPage)) {
             $objPage = $objNewPage;
         }
     }
     return $objPage;
 }
开发者ID:heimrichhannot,项目名称:contao-blocks,代码行数:47,代码来源:ModuleBlock.php

示例5: run

 /**
  * Run the controller
  */
 public function run()
 {
     global $objPage;
     $pageId = $this->getPageIdFromUrl();
     $objRootPage = null;
     // Load a website root page object if there is no page ID
     if ($pageId === null) {
         $objRootPage = $this->getRootPageFromUrl();
         $objHandler = new $GLOBALS['TL_PTY']['root']();
         $pageId = $objHandler->generate($objRootPage->id, true);
     } elseif ($pageId === false) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
     } elseif (Config::get('rewriteURL') && strncmp(Environment::get('request'), 'index.php/', 10) === 0) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
     }
     // Get the current page object(s)
     $objPage = PageModel::findPublishedByIdOrAlias($pageId);
     // Check the URL and language of each page if there are multiple results
     if ($objPage !== null && $objPage->count() > 1) {
         $objNewPage = null;
         $arrPages = array();
         // Order by domain and language
         while ($objPage->next()) {
             $objCurrentPage = $objPage->current()->loadDetails();
             $domain = $objCurrentPage->domain ?: '*';
             $arrPages[$domain][$objCurrentPage->rootLanguage] = $objCurrentPage;
             // Also store the fallback language
             if ($objCurrentPage->rootIsFallback) {
                 $arrPages[$domain]['*'] = $objCurrentPage;
             }
         }
         $strHost = Environment::get('host');
         // Look for a root page whose domain name matches the host name
         if (isset($arrPages[$strHost])) {
             $arrLangs = $arrPages[$strHost];
         } else {
             $arrLangs = $arrPages['*'] ?: array();
             // empty domain
         }
         // Use the first result (see #4872)
         if (!Config::get('addLanguageToUrl')) {
             $objNewPage = current($arrLangs);
         } elseif (($lang = Input::get('language')) != '' && isset($arrLangs[$lang])) {
             $objNewPage = $arrLangs[$lang];
         }
         // Store the page object
         if (is_object($objNewPage)) {
             $objPage = $objNewPage;
         }
     }
     // Throw a 404 error if the page could not be found or the result is still ambiguous
     if ($objPage === null || $objPage instanceof Model\Collection && $objPage->count() != 1) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
     }
     // Make sure $objPage is a Model
     if ($objPage instanceof Model\Collection) {
         $objPage = $objPage->current();
     }
     // Load a website root page object (will redirect to the first active regular page)
     if ($objPage->type == 'root') {
         $objHandler = new $GLOBALS['TL_PTY']['root']();
         $objHandler->generate($objPage->id);
     }
     // Inherit the settings from the parent pages if it has not been done yet
     if (!is_bool($objPage->protected)) {
         $objPage->loadDetails();
     }
     // Set the admin e-mail address
     if ($objPage->adminEmail != '') {
         list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = String::splitFriendlyEmail($objPage->adminEmail);
     } else {
         list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = String::splitFriendlyEmail(Config::get('adminEmail'));
     }
     // Exit if the root page has not been published (see #2425)
     // Do not try to load the 404 page, it can cause an infinite loop!
     if (!BE_USER_LOGGED_IN && !$objPage->rootIsPublic) {
         header('HTTP/1.1 404 Not Found');
         die_nicely('be_no_page', 'Page not found');
     }
     // Check wether the language matches the root page language
     if (Config::get('addLanguageToUrl') && Input::get('language') != $objPage->rootLanguage) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
     }
     // Check whether there are domain name restrictions
     if ($objPage->domain != '') {
         // Load an error 404 page object
         if ($objPage->domain != Environment::get('host')) {
             $this->User->authenticate();
             $objHandler = new $GLOBALS['TL_PTY']['error_404']();
//.........这里部分代码省略.........
开发者ID:iCodr8,项目名称:core,代码行数:101,代码来源:index.php

示例6: loadReaderPageFromUrl

 /**
  * Replace the current page with a reader page if applicable
  *
  * @param array $arrFragments
  *
  * @return array
  */
 public function loadReaderPageFromUrl($arrFragments)
 {
     $strKey = 'product';
     $strAlias = '';
     // Find products alias. Can't use Input because they're not yet initialized
     if ($GLOBALS['TL_CONFIG']['useAutoItem'] && in_array($strKey, $GLOBALS['TL_AUTO_ITEM'])) {
         $strKey = 'auto_item';
     }
     for ($i = 1, $c = count($arrFragments); $i < $c; $i += 2) {
         if ($arrFragments[$i] == $strKey) {
             $strAlias = $arrFragments[$i + 1];
         }
     }
     global $objIsotopeListPage;
     $objIsotopeListPage = null;
     if ($strAlias != '' && ($objPage = \PageModel::findPublishedByIdOrAlias($arrFragments[0])) !== null) {
         // Check the URL and language of each page if there are multiple results
         // see Contao's index.php
         if ($objPage !== null && $objPage->count() > 1) {
             $objNewPage = null;
             $arrPages = array();
             // Order by domain and language
             /** @var \PageModel $objCurrentPage */
             foreach ($objPage as $objCurrentPage) {
                 $objCurrentPage->loadDetails();
                 $domain = $objCurrentPage->domain ?: '*';
                 $arrPages[$domain][$objCurrentPage->rootLanguage] = $objCurrentPage;
                 // Also store the fallback language
                 if ($objCurrentPage->rootIsFallback) {
                     $arrPages[$domain]['*'] = $objCurrentPage;
                 }
             }
             $strHost = \Environment::get('host');
             // Look for a root page whose domain name matches the host name
             if (isset($arrPages[$strHost])) {
                 $arrLangs = $arrPages[$strHost];
             } else {
                 $arrLangs = $arrPages['*'];
                 // Empty domain
             }
             // Use the first result (see #4872)
             if (!$GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
                 $objNewPage = current($arrLangs);
             } elseif (($lang = \Input::get('language')) != '' && isset($arrLangs[$lang])) {
                 $objNewPage = $arrLangs[$lang];
             }
             // Store the page object
             if (is_object($objNewPage)) {
                 $objPage = $objNewPage;
             }
         }
         if ($objPage->iso_setReaderJumpTo && ($objReader = $objPage->getRelated('iso_readerJumpTo')) !== null) {
             /** @var \PageModel $objIsotopeListPage */
             $objIsotopeListPage = $objPage->current();
             $objIsotopeListPage->loadDetails();
             $arrFragments[0] = $objReader->alias ?: $objReader->id;
         }
     }
     return $arrFragments;
 }
开发者ID:bytehead,项目名称:core,代码行数:67,代码来源:Frontend.php

示例7: run

 /**
  * Run the controller
  */
 public function run()
 {
     global $objPage;
     $pageId = $this->getPageIdFromUrl();
     $objRootPage = null;
     // Load a website root page object if there is no page ID
     if ($pageId === null) {
         $objRootPage = $this->getRootPageFromUrl();
         $objHandler = new $GLOBALS['TL_PTY']['root']();
         $pageId = $objHandler->generate($objRootPage->id, true);
     } elseif ($pageId === false) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
     } elseif ($GLOBALS['TL_CONFIG']['rewriteURL'] && strncmp(Environment::get('request'), 'index.php/', 10) === 0) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
     }
     // Get the current page object(s)
     $objPage = PageModel::findPublishedByIdOrAlias($pageId);
     // Check the URL and language of each page if there are multiple results
     if ($objPage !== null && $objPage->count() > 1) {
         $objNewPage = null;
         $arrPages = array();
         // Order by domain and language
         while ($objPage->next()) {
             // Pass the ID so a new page object is created!
             $objCurrentPage = $this->getPageDetails($objPage->id);
             $domain = $objCurrentPage->domain ?: '*';
             $arrPages[$domain][$objCurrentPage->rootLanguage] = $objCurrentPage;
             // Also store the fallback language
             if ($objCurrentPage->rootIsFallback) {
                 $arrPages[$domain]['*'] = $objCurrentPage;
             }
         }
         // Look for a root page whose domain name matches the host name
         if (isset($arrPages[Environment::get('host')])) {
             $arrLangs = $arrPages[Environment::get('host')];
         } else {
             $arrLangs = $arrPages['*'];
             // Empty domain
         }
         // Try to find a page matching the language parameter
         if (!$GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
             $objNewPage = $arrLangs['*'];
             // Fallback language
         } elseif (($lang = Input::get('language')) != '' && isset($arrLangs[$lang])) {
             $objNewPage = $arrLangs[$lang];
         }
         // Store the page object
         if (is_object($objNewPage)) {
             $objPage = $objNewPage;
         }
     }
     // Throw a 404 error if the page could not be found or the result is still ambiguous
     if ($objPage === null || $objPage->count() != 1) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
     }
     // Load a website root page object (will redirect to the first active regular page)
     if ($objPage->type == 'root') {
         $objHandler = new $GLOBALS['TL_PTY']['root']();
         $objHandler->generate($objPage->id);
     }
     // Inherit the settings from the parent pages if it has not been done yet
     if (!is_bool($objPage->protected)) {
         $objPage = $this->getPageDetails($objPage);
     }
     // Use the global date format if none is set
     if ($objPage->dateFormat == '') {
         $objPage->dateFormat = $GLOBALS['TL_CONFIG']['dateFormat'];
     }
     if ($objPage->timeFormat == '') {
         $objPage->timeFormat = $GLOBALS['TL_CONFIG']['timeFormat'];
     }
     if ($objPage->datimFormat == '') {
         $objPage->datimFormat = $GLOBALS['TL_CONFIG']['datimFormat'];
     }
     // Set the admin e-mail address
     if ($objPage->adminEmail != '') {
         list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = $this->splitFriendlyName($objPage->adminEmail);
     } else {
         list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = $this->splitFriendlyName($GLOBALS['TL_CONFIG']['adminEmail']);
     }
     // Exit if the root page has not been published (see #2425) and
     // do not try to load the 404 page! It can cause an infinite loop.
     if (!BE_USER_LOGGED_IN && !$objPage->rootIsPublic) {
         header('HTTP/1.1 404 Not Found');
         die('Page not found');
     }
     // Check wether the language matches the root page language
     if ($GLOBALS['TL_CONFIG']['addLanguageToUrl'] && Input::get('language') != $objPage->rootLanguage) {
         $this->User->authenticate();
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($pageId);
//.........这里部分代码省略.........
开发者ID:rikaix,项目名称:core,代码行数:101,代码来源:index.php


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