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


PHP PageModel::getRelated方法代码示例

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


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

示例1: generate

 /**
  * Redirect to an internal page
  * @param \PageModel $objPage
  */
 public function generate($objPage)
 {
     // Forward to the jumpTo or first published page
     if ($objPage->jumpTo) {
         /** @var \PageModel $objNextPage */
         $objNextPage = $objPage->getRelated('jumpTo');
     } else {
         $objNextPage = \PageModel::findFirstPublishedRegularByPid($objPage->id);
     }
     // Forward page does not exist
     if ($objNextPage === null) {
         header('HTTP/1.1 404 Not Found');
         $this->log('Forward page ID "' . $objPage->jumpTo . '" does not exist', __METHOD__, TL_ERROR);
         die_nicely('be_no_forward', 'Forward page not found');
     }
     $strForceLang = null;
     // Check the target page language (see #4706)
     if (\Config::get('addLanguageToUrl')) {
         $objNextPage->loadDetails();
         // see #3983
         $strForceLang = $objNextPage->language;
     }
     $strGet = '';
     $strQuery = \Environment::get('queryString');
     $arrQuery = array();
     // Extract the query string keys (see #5867)
     if ($strQuery != '') {
         $arrChunks = explode('&', $strQuery);
         foreach ($arrChunks as $strChunk) {
             list($k, ) = explode('=', $strChunk, 2);
             $arrQuery[] = $k;
         }
     }
     // Add $_GET parameters
     if (!empty($_GET)) {
         foreach (array_keys($_GET) as $key) {
             if (\Config::get('disableAlias') && $key == 'id') {
                 continue;
             }
             if (\Config::get('addLanguageToUrl') && $key == 'language') {
                 continue;
             }
             // Ignore the query string parameters (see #5867)
             if (in_array($key, $arrQuery)) {
                 continue;
             }
             // Ignore the auto_item parameter (see #5886)
             if ($key == 'auto_item') {
                 $strGet .= '/' . \Input::get($key);
             } else {
                 $strGet .= '/' . $key . '/' . \Input::get($key);
             }
         }
     }
     // Append the query string (see #5867)
     if ($strQuery != '') {
         $strQuery = '?' . $strQuery;
     }
     $this->redirect($this->generateFrontendUrl($objNextPage->row(), $strGet, $strForceLang) . $strQuery, $objPage->redirect == 'temporary' ? 302 : 301);
 }
开发者ID:Jobu,项目名称:core,代码行数:64,代码来源:PageForward.php

示例2: parsePage

 /**
  * Parse the given page and return the image information
  * @param    \PageModel
  * @return   array
  */
 protected static function parsePage(\PageModel $objPage)
 {
     if ($objPage->pageImage == '') {
         return array();
     }
     $arrImages = array();
     $objImages = \FilesModel::findMultipleByIds(deserialize($objPage->pageImage, true));
     if (null !== $objImages) {
         while ($objImages->next()) {
             $objFile = new \File($objImages->path, true);
             if (!$objFile->isGdImage) {
                 continue;
             }
             $arrImage = $objImages->row();
             $arrMeta = static::getMetaData($objImages->meta, $objPage->language);
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename)));
             }
             $arrImage['alt'] = $objPage->pageImageAlt;
             $arrImage['imageUrl'] = $arrMeta['link'];
             $arrImage['caption'] = $arrMeta['caption'];
             if (null !== $objPage->getRelated('pageImageJumpTo')) {
                 $arrImage['hasLink'] = true;
                 $arrImage['title'] = $objPage->pageImageTitle ?: ($arrMeta['title'] ?: ($objJumpTo->pageTitle ?: $objJumpTo->title));
                 $arrImage['href'] = \Controller::generateFrontendUrl($objPage->getRelated('pageImageJumpTo')->row());
             }
             $arrImages[] = $arrImage;
         }
         $arrOrder = deserialize($objPage->pageImageOrder);
         if (!empty($arrOrder) && is_array($arrOrder)) {
             // Remove all values
             $arrOrder = array_map(function () {
             }, array_flip($arrOrder));
             // Move the matching elements to their position in $arrOrder
             foreach ($arrImages as $k => $v) {
                 if (array_key_exists($v['uuid'], $arrOrder)) {
                     $arrOrder[$v['uuid']] = $v;
                     unset($arrImages[$k]);
                 }
             }
             // Append the left-over images at the end
             if (!empty($arrImages)) {
                 $arrOrder = array_merge($arrOrder, array_values($arrImages));
             }
             // Remove empty (unreplaced) entries
             $arrImages = array_values(array_filter($arrOrder));
             unset($arrOrder);
         }
     }
     return $arrImages;
 }
开发者ID:delirius,项目名称:contao-pageimage,代码行数:57,代码来源:PageImage.php


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