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


PHP PageModel::findByIdOrAlias方法代码示例

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


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

示例1: doReplace


//.........这里部分代码省略.........
                 }
                 break;
                 // Link
             // Link
             case 'link':
             case 'link_open':
             case 'link_url':
             case 'link_title':
             case 'link_target':
             case 'link_name':
                 $strTarget = null;
                 // Back link
                 if ($elements[1] == 'back') {
                     $strUrl = 'javascript:history.go(-1)';
                     $strTitle = $GLOBALS['TL_LANG']['MSC']['goBack'];
                     // No language files if the page is cached
                     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 = \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;
                 }
开发者ID:bytehead,项目名称:core-bundle,代码行数:67,代码来源:InsertTags.php

示例2: replaceInsertTags


//.........这里部分代码省略.........
                     }
                     // Convert special characters (see #1890)
                     $arrCache[$strTag] = specialchars($arrCache[$strTag]);
                 }
                 break;
                 // Link
             // Link
             case 'link':
             case 'link_open':
             case 'link_url':
             case 'link_title':
                 // Back link
                 if ($elements[1] == 'back') {
                     $strUrl = 'javascript:history.go(-1)';
                     $strTitle = $GLOBALS['TL_LANG']['MSC']['goBack'];
                     // No language files if the page is cached
                     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);
开发者ID:rikaix,项目名称:core,代码行数:67,代码来源:Controller.php

示例3: replaceInsertTags


//.........这里部分代码省略.........
                     // Convert special characters (see #1890)
                     $arrCache[$strTag] = specialchars($arrCache[$strTag]);
                 }
                 break;
                 // Link
             // Link
             case 'link':
             case 'link_open':
             case 'link_url':
             case 'link_title':
                 $strTarget = null;
                 // Back link
                 if ($elements[1] == 'back') {
                     $strUrl = 'javascript:history.go(-1)';
                     $strTitle = $GLOBALS['TL_LANG']['MSC']['goBack'];
                     // No language files if the page is cached
                     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 = $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;
开发者ID:iCodr8,项目名称:core,代码行数:67,代码来源:Controller.php

示例4: compile

 protected function compile()
 {
     // Read jump to page details
     $objPage = \PageModel::findByIdOrAlias($this->jumpTo);
     // Check if filter should be displayed
     if (!$this->company_filter_disabled) {
         $objTemplateFilter = new FrontendTemplate('company_list_filter');
         // Filter category
         $intFilterCategory = Input::get('filterCategory');
         $strFilterUrl = '';
         if ($intFilterCategory > 0) {
             $strFilterUrl = '&filterCategory=' . $intFilterCategory;
         }
         // Filter search
         $strSearch = Input::get('search');
         $strSearchUrl = 'search=%s';
         $objTemplateFilter->strLink = $strSearch != '' ? Environment::get('base') . $this->addToUrl(sprintf($strSearchUrl, $strSearch) . '&filterCategory=ID', true) : Environment::get('base') . $this->addToUrl('filterCategory=ID', true);
         // Generate letters
         $arrAlphabet = range('A', 'Z');
         $strHtml = '<a href="' . $this->addToUrl($strFilterUrl, TRUE) . '">Alle</a> ';
         for ($i = 0; $i < count($arrAlphabet); $i++) {
             $strHtml .= '<a href="' . $this->addToUrl(sprintf($strSearchUrl, $arrAlphabet[$i]) . $strFilterUrl, TRUE) . '">' . $arrAlphabet[$i] . '</a> ';
         }
         $objTemplateFilter->strFilterName = $strHtml;
         // Get Categories
         $this->loadLanguageFile('tl_company_category');
         $objCategories = CompanyCategoryModel::findBy('pid', $this->company_archiv, array('order' => 'title ASC'));
         $strOptions = '<option value="0">' . $GLOBALS['TL_LANG']['tl_company_category']['category'][0] . '</option>';
         if ($objCategories) {
             while ($objCategories->next()) {
                 $strOptions .= '<option value="' . $objCategories->id . '"' . ($intFilterCategory != $objCategories->id ? '' : ' selected') . '>' . $objCategories->title . '</option>';
             }
         }
         $objTemplateFilter->strCategoryOptions = $strOptions;
         $this->Template->strFilter = $objTemplateFilter->parse();
     } else {
         $strSearch = '';
         $intFilterCategory = 0;
     }
     // Get items to calculate total number of items
     $objCompanies = CompanyModel::findItems($this->company_archiv, $strSearch, $intFilterCategory);
     // Pagination
     $intLimit = 0;
     $intOffset = 0;
     $intTotal = 0;
     // Set limit to maximum number of items
     if ($this->numberOfItems > 0) {
         $intLimit = $this->numberOfItems;
         $intTotal = $this->numberOfItems;
     } elseif ($objCompanies) {
         $intTotal = $objCompanies->count();
     }
     // If per page is set and maximum number of items greater than per page use Pagination
     if ($objCompanies && $this->perPage > 0 && ($intLimit == 0 || $this->numberOfItems > $this->perPage)) {
         // Set limit, page and offset
         $intLimit = $this->perPage;
         $intPage = $this->Input->get('page') ? $this->Input->get('page') : 1;
         $intOffset = ($intPage - 1) * $intLimit;
         // Add pagination menu
         $objPagination = new \Pagination($intTotal, $intLimit);
         $this->Template->strPagination = $objPagination->generate();
     }
     // Order
     $objCompanyArchive = CompanyArchiveModel::findByPk($this->company_archiv);
     switch ($objCompanyArchive->sort_order) {
         case 2:
             $strOrder = 'sorting ASC';
             break;
         case 1:
         default:
             $strOrder = $this->company_random ? 'RAND()' : 'company ASC';
             break;
     }
     $objCompanies = CompanyModel::findItems($this->company_archiv, $strSearch, $intFilterCategory, $intOffset, $intLimit, $strOrder);
     if ($objCompanies) {
         $this->Template->strCompanies = $this->getCompanies($objCompanies, $objPage);
     } else {
         $this->Template->strCompanies = 'Mit den ausgewählten Filterkriterien sind keine Einträge vorhanden.';
     }
 }
开发者ID:mindbird,项目名称:contao-unternehmen,代码行数:80,代码来源:CompanyList.php

示例5: userHasPermissionToEditPageType

 /**
  * Check if current be user has permission to edit the given page type
  *
  * @param $arrRow
  * @param $strTable
  *
  * @return boolean
  */
 private function userHasPermissionToEditPageType($arrRow, $strTable = 'tl_page_i18nl10n')
 {
     return $this->User->isAdmin || in_array($strTable === 'tl_page_i18nl10n' ? \PageModel::findByIdOrAlias($arrRow['pid'])->type : $arrRow['type'], (array) $this->User->alpty);
 }
开发者ID:verstaerker,项目名称:i18nl10n,代码行数:12,代码来源:tl_page_i18nl10n.php

示例6: parseCustomizeFrontendTemplate

 /**
  * Edit the Frontend Template
  */
 public function parseCustomizeFrontendTemplate($strContent, $strTemplate)
 {
     global $objPage;
     $isFullpage = $this->isFullPageEnabled($objPage);
     if ($strTemplate == "mod_article") {
         $sectionHeaderID = 3;
         // TODO: verwaltbar machen!!!
         $sectionFooterID = 4;
         $objArticle = NULL;
         $articleClass = array();
         $articlePattern = '/<div([A-Za-z0-9\\s\\-_=;",:\\.\\(\\)\'#\\/%]{0,})class="mod_article([A-Za-z0-9\\s\\-_]{0,})"([A-Za-z0-9\\s\\-_=;",:\\.\\(\\)\'#\\/%]{0,})>/';
         preg_match_all('/id="([A-Za-z0-9\\-_]{0,})"/', $strContent, $idMatches);
         if (is_array($idMatches) && count($idMatches[0]) > 0) {
             $objArticle = \ArticleModel::findByIdOrAlias($idMatches[1][0]);
         }
         if ($isFullpage) {
             if ($objArticle) {
                 if ($objArticle->enableSectionHeader) {
                     $sectionHeaderID = $objArticle->sectionHeaderModule;
                     $strContent = preg_replace($articlePattern, '<div$1class="mod_article$2"$3><div class="header section-header">{{insert_module::' . $sectionHeaderID . '}}</div>', $strContent);
                 }
                 if ($objArticle->enableSectionFooter) {
                     $sectionFooterID = $objArticle->sectionFooterModule;
                     $strContent = preg_replace('/<\\/div>$/', '<div class="footer section-footer">{{insert_module::' . $sectionFooterID . '}}</div></div>', $strContent);
                 }
                 if ($objArticle->enableOverlay) {
                     $strOverlayContent = '';
                     if ($objArticle->showTitleInOverlay) {
                         $strArticleTitle = $objArticle->title;
                         if (strlen($objArticle->alt_title)) {
                             $strArticleTitle = $objArticle->alt_title;
                         }
                         $strOverlayContent = '<div class="overlay-title"><div class="title-inner">' . $strArticleTitle . '</div></div>';
                     }
                     $strClass = "";
                     if ($objArticle->overlayTransparent) {
                         $strClass = " overlay-trans";
                     }
                     $strOverlayTags = '<div class="show-overlay"></div><div class="overlay article-overlay' . $strClass . ' shown"><div class="close"></div>' . $strOverlayContent . '</div>';
                     $strContent = preg_replace($articlePattern, '<div$1class="mod_article has-overlay$2"$3>', $strContent);
                     $strContent = preg_replace('/<\\/div>$/', $strOverlayTags . '</div>', $strContent);
                 }
                 if ($objArticle->enableFullpageNavigation) {
                     $navNext = "";
                     $navPrev = "";
                     if ($objPage->fullpageDirection == "horizontal") {
                         // TODO NAVI RIGHT UND LEFT!!
                     } else {
                         $navNext = '<div class="navigation-top" onClick="DPS.Fullpage.sectionBack(this);"></div>';
                         $navPrev = '<div class="navigation-bottom" onClick="DPS.Fullpage.sectionForward(this);"></div>';
                     }
                     $navigationTags = '<div class="fullpage-navigation">' . $navNext . $navPrev . '</div>';
                     //						$strContent			= preg_replace($articlePattern, '', $strContent);
                     $strContent = preg_replace('/<\\/div>$/', $navigationTags . '</div>', $strContent);
                 }
             }
             if ($objPage->fullpageDirection == "horizontal") {
                 $articleClass[] = 'slide';
             } else {
                 $articleClass[] = 'section';
             }
             //				$strContent = preg_replace('/<div([A-Za-z0-9\s\-_=;",:\\.\(\)\'#\/%]{0,})class="mod_article([A-Za-z0-9\s\-_]{0,})"([A-Za-z0-9\s\-_=;",:\\.\(\)\'#\/%]{0,})>/', '<div$1class="mod_article$2"$3><div class="article-inner">', $strContent);
             //				$strContent = $strContent . '</div>';
         }
         if ($objArticle) {
             if ($objArticle->enableBackgroundImage && $objArticle->singleSRC != "") {
                 $objFile = \FilesModel::findByUuid($objArticle->singleSRC);
                 if ($objFile === null && !\Validator::isUuid($objArticle->singleSRC)) {
                     $strContent = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>' . $strContent;
                 }
                 if ($objFile && is_file(TL_ROOT . '/' . $objFile->path)) {
                     preg_match_all($articlePattern, $strContent, $arrArticleMatches);
                     if (is_array($arrArticleMatches[0]) && count($arrArticleMatches[0]) > 0) {
                         $bgPosition = str_replace('_', ' ', $objArticle->backgroundImagePosition);
                         if (!$bgPosition) {
                             $bgPosition = "center center";
                         }
                         if (preg_match('/style="/', $arrArticleMatches[0][0])) {
                             $styles = 'background-image:url(\'' . $objFile->path . '\');background-position:' . $bgPosition . ';';
                             $replStyles = '';
                             if (preg_match('/style="/', $arrArticleMatches[1][0])) {
                                 $replStyles = str_replace('style="', 'style="' . $styles, $arrArticleMatches[1][0]);
                             } elseif (preg_match('/style="/', $arrArticleMatches[3][0])) {
                                 $replStyles = str_replace('style="', 'style="' . $styles, $arrArticleMatches[3][0]);
                             }
                             $strContent = preg_replace($articlePattern, '<div' . $replStyles . 'class="mod_article$2"$3>', $strContent);
                         } else {
                             $strContent = preg_replace($articlePattern, '<div$1class="mod_article$2" style="background-image:url(\'' . $objFile->path . '\');background-position:' . $bgPosition . ';"$3>', $strContent);
                         }
                         $strContent = preg_replace($articlePattern, '<div$1class="mod_article has-background-image bg-fixed bg-image bg-cover$2"$3">', $strContent);
                     }
                 }
             }
             if ($objArticle->enableNavigation) {
                 $articleNavigationTag = '<div class="navigation-container">';
                 $objAllArticles = \ArticleModel::findBy(array("pid=?", "inColumn=?", "published=?"), array($objArticle->pid, "main", "1"), array("order" => "sorting"));
                 $nextArticle = false;
//.........这里部分代码省略.........
开发者ID:pressi,项目名称:zdps_customize,代码行数:101,代码来源:Template.php


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