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


PHP NewsModel::countPublishedFromToByPids方法代码示例

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


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

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $limit = null;
     $offset = 0;
     $intBegin = 0;
     $intEnd = 0;
     $intYear = \Input::get('year');
     $intMonth = \Input::get('month');
     $intDay = \Input::get('day');
     // Jump to the current period
     if (!isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day']) && $this->news_jumpToCurrent != 'all_items') {
         switch ($this->news_format) {
             case 'news_year':
                 $intYear = date('Y');
                 break;
             default:
             case 'news_month':
                 $intMonth = date('Ym');
                 break;
             case 'news_day':
                 $intDay = date('Ymd');
                 break;
         }
     }
     // Create the date object
     try {
         if ($intYear) {
             $strDate = $intYear;
             $objDate = new \Date($strDate, 'Y');
             $intBegin = $objDate->yearBegin;
             $intEnd = $objDate->yearEnd;
             $this->headline .= ' ' . date('Y', $objDate->tstamp);
         } elseif ($intMonth) {
             $strDate = $intMonth;
             $objDate = new \Date($strDate, 'Ym');
             $intBegin = $objDate->monthBegin;
             $intEnd = $objDate->monthEnd;
             $this->headline .= ' ' . \Date::parse('F Y', $objDate->tstamp);
         } elseif ($intDay) {
             $strDate = $intDay;
             $objDate = new \Date($strDate, 'Ymd');
             $intBegin = $objDate->dayBegin;
             $intEnd = $objDate->dayEnd;
             $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $objDate->tstamp);
         } elseif ($this->news_jumpToCurrent == 'all_items') {
             $intBegin = 0;
             $intEnd = time();
         }
     } catch (\OutOfBoundsException $e) {
         /** @var \PageError404 $objHandler */
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($objPage->id);
     }
     $this->Template->articles = array();
     // Split the result
     if ($this->perPage > 0) {
         // Get the total number of items
         $intTotal = \NewsModel::countPublishedFromToByPids($intBegin, $intEnd, $this->news_archives);
         if ($intTotal > 0) {
             $total = $intTotal;
             // Get the current page
             $id = 'page_a' . $this->id;
             $page = \Input::get($id) !== null ? \Input::get($id) : 1;
             // Do not index or cache the page if the page number is outside the range
             if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
                 /** @var \PageError404 $objHandler */
                 $objHandler = new $GLOBALS['TL_PTY']['error_404']();
                 $objHandler->generate($objPage->id);
             }
             // Set limit and offset
             $limit = $this->perPage;
             $offset = (max($page, 1) - 1) * $this->perPage;
             // Add the pagination menu
             $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
             $this->Template->pagination = $objPagination->generate("\n  ");
         }
     }
     // Get the news items
     if (isset($limit)) {
         $objArticles = \NewsModel::findPublishedFromToByPids($intBegin, $intEnd, $this->news_archives, $limit, $offset);
     } else {
         $objArticles = \NewsModel::findPublishedFromToByPids($intBegin, $intEnd, $this->news_archives);
     }
     // Add the articles
     if ($objArticles !== null) {
         $this->Template->articles = $this->parseArticles($objArticles);
     }
     $this->Template->headline = trim($this->headline);
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['empty'];
 }
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:96,代码来源:ModuleNewsArchive.php

示例2: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $limit = null;
     $offset = 0;
     $intBegin = 0;
     $intEnd = 0;
     // Jump to the current period
     if (!isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day']) && $this->news_jumpToCurrent != 'all_items') {
         switch ($this->news_format) {
             case 'news_year':
                 \Input::setGet('year', date('Y'));
                 break;
             default:
             case 'news_month':
                 \Input::setGet('month', date('Ym'));
                 break;
             case 'news_day':
                 \Input::setGet('day', date('Ymd'));
                 break;
         }
     }
     // Display year
     if (\Input::get('year')) {
         $strDate = \Input::get('year');
         $objDate = new \Date($strDate, 'Y');
         $intBegin = $objDate->yearBegin;
         $intEnd = $objDate->yearEnd;
         $this->headline .= ' ' . date('Y', $objDate->tstamp);
     } elseif (\Input::get('month')) {
         $strDate = \Input::get('month');
         $objDate = new \Date($strDate, 'Ym');
         $intBegin = $objDate->monthBegin;
         $intEnd = $objDate->monthEnd;
         $this->headline .= ' ' . $this->parseDate('F Y', $objDate->tstamp);
     } elseif (\Input::get('day')) {
         $strDate = \Input::get('day');
         $objDate = new \Date($strDate, 'Ymd');
         $intBegin = $objDate->dayBegin;
         $intEnd = $objDate->dayEnd;
         $this->headline .= ' ' . $this->parseDate($objPage->dateFormat, $objDate->tstamp);
     } elseif ($this->news_jumpToCurrent == 'all_items') {
         $intBegin = 0;
         $intEnd = time();
     }
     $this->Template->articles = array();
     // Split the result
     if ($this->perPage > 0) {
         // Get the total number of items
         $intTotal = \NewsModel::countPublishedFromToByPids($intBegin, $intEnd, $this->news_archives);
         if ($intTotal > 0) {
             $total = $intTotal;
             // Get the current page
             $id = 'page_a' . $this->id;
             $page = \Input::get($id) ?: 1;
             // Do not index or cache the page if the page number is outside the range
             if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
                 global $objPage;
                 $objPage->noSearch = 1;
                 $objPage->cache = 0;
                 // Send a 404 header
                 header('HTTP/1.1 404 Not Found');
                 return;
             }
             // Set limit and offset
             $limit = $this->perPage;
             $offset = (max($page, 1) - 1) * $this->perPage;
             // Add the pagination menu
             $objPagination = new \Pagination($total, $this->perPage, 7, $id);
             $this->Template->pagination = $objPagination->generate("\n  ");
         }
     }
     // Get the news items
     if (isset($limit)) {
         $objArticles = \NewsModel::findPublishedFromToByPids($intBegin, $intEnd, $this->news_archives, $limit, $offset);
     } else {
         $objArticles = \NewsModel::findPublishedFromToByPids($intBegin, $intEnd, $this->news_archives);
     }
     // No items found
     if ($objArticles === null) {
         $this->Template = new \FrontendTemplate('mod_newsarchive_empty');
     } else {
         $this->Template->articles = $this->parseArticles($objArticles);
     }
     $this->Template->headline = trim($this->headline);
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['empty'];
 }
开发者ID:rikaix,项目名称:core,代码行数:91,代码来源:ModuleNewsArchive.php


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