Пример #1
0
 /**
  * Creates the page collection.
  *
  * @param  string $scrollingStyle Scrolling style
  * @return stdClass
  */
 protected function _createPages($scrollingStyle = null)
 {
     $pageCount = $this->count();
     $currentPageNumber = $this->getCurrentPageNumber();
     $pages = new stdClass();
     $pages->pageCount = $pageCount;
     $pages->itemCountPerPage = $this->getItemCountPerPage();
     $pages->first = 1;
     $pages->current = $currentPageNumber;
     $pages->last = $pageCount;
     // Previous and next
     if ($currentPageNumber - 1 > 0) {
         $pages->previous = $currentPageNumber - 1;
     }
     if ($currentPageNumber + 1 <= $pageCount) {
         $pages->next = $currentPageNumber + 1;
     }
     // Pages in range
     $scrollingStyle = $this->_loadScrollingStyle($scrollingStyle);
     $pages->pagesInRange = $scrollingStyle->getPages($this);
     $pages->firstPageInRange = min($pages->pagesInRange);
     $pages->lastPageInRange = max($pages->pagesInRange);
     // Item numbers
     if ($this->getCurrentItems() !== null) {
         $pages->currentItemCount = $this->getCurrentItemCount();
         $pages->totalItemCount = $this->_adapter->count();
         $pages->firstItemNumber = ($currentPageNumber - 1) * $this->_itemCountPerPage + 1;
         $pages->lastItemNumber = $pages->firstItemNumber + $pages->currentItemCount - 1;
     }
     return $pages;
 }
Пример #2
0
 /**
  * Calculates the page count.
  *
  * @return integer
  */
 protected function _calculatePageCount()
 {
     return (int) ceil($this->_adapter->count() / $this->_itemCountPerPage);
 }