當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Paginator::getPagesInRange方法代碼示例

本文整理匯總了PHP中Zend_Paginator::getPagesInRange方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Paginator::getPagesInRange方法的具體用法?PHP Zend_Paginator::getPagesInRange怎麽用?PHP Zend_Paginator::getPagesInRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Paginator的用法示例。


在下文中一共展示了Zend_Paginator::getPagesInRange方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPages

 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  Zend_Paginator $paginator
  * @param  integer $pageRange Unused
  * @return array
  */
 public function getPages(Zend_Paginator $paginator, $pageRange = null)
 {
     $pageRange = $paginator->getPageRange();
     $pageNumber = $paginator->getCurrentPageNumber();
     $delta = $pageNumber % $pageRange;
     if ($delta == 0) {
         $delta = $pageRange;
     }
     $offset = $pageNumber - $delta;
     $lowerBound = $offset + 1;
     $upperBound = $offset + $pageRange;
     return $paginator->getPagesInRange($lowerBound, $upperBound);
 }
開發者ID:jkimdon,項目名稱:cohomeals,代碼行數:20,代碼來源:Jumping.php

示例2: getPages

 /**
  * Create the page object used in View - paginator method
  * @access public
  * @return object
  */
 public function getPages()
 {
     $pages = new stdClass();
     $pageCount = $this->_paginator->count();
     $pages->pageCount = $pageCount;
     $pages->itemCountPerPage = $this->_itemCountPerPage;
     $pages->first = 1;
     $pages->current = (int) $this->_currentPage;
     $pages->last = $pageCount;
     // Previous and next
     if ($this->_currentPage - 1 > 0) {
         $pages->previous = $this->_currentPage - 1;
     }
     if ($this->_currentPage + 1 <= $pageCount) {
         $pages->next = $this->_currentPage + 1;
     }
     // Pages in range
     $pageRange = $this->_paginator->getPageRange();
     if ($pageRange > $pageCount) {
         $pageRange = $pageCount;
     }
     $delta = ceil($pageRange / 2);
     if ($this->_currentPage - $delta > $pageCount - $pageRange) {
         $lowerBound = $pageCount - $pageRange + 1;
         $upperBound = $pageCount;
     } else {
         if ($this->_currentPage - $delta < 0) {
             $delta = $this->_currentPage;
         }
         $offset = $this->_currentPage - $delta;
         $lowerBound = $offset + 1;
         $upperBound = $offset + $pageRange;
     }
     $pages->pagesInRange = $this->_paginator->getPagesInRange($lowerBound, $upperBound);
     $pages->firstPageInRange = min($pages->pagesInRange);
     $pages->lastPageInRange = max($pages->pagesInRange);
     // Item numbers
     if ($this->_currentItems == null) {
         $this->getCurrentItems();
     }
     if ($this->_currentItems !== null) {
         $pages->currentItemCount = $this->_paginator->getCurrentItemCount();
         $pages->itemCountPerPage = $this->_paginator->getItemCountPerPage();
         $pages->totalItemCount = $this->_paginator->getTotalItemCount();
         $pages->firstItemNumber = ($this->_currentPage - 1) * $this->_paginator->getItemCountPerPage() + 1;
         $pages->lastItemNumber = $pages->firstItemNumber + $pages->currentItemCount - 1;
     }
     return $pages;
 }
開發者ID:sandeepdwarkapuria,項目名稱:dotkernel,代碼行數:54,代碼來源:Paginator.php

示例3: getPages

 /**
  * Returns an array of all pages given a page number and range.
  *
  * @param  Zend_Paginator $paginator
  * @param  integer $pageRange Unused
  * @return array
  */
 public function getPages(Zend_Paginator $paginator, $pageRange = null)
 {
     return $paginator->getPagesInRange(1, $paginator->count());
 }
開發者ID:fredcido,項目名稱:cenbrap,代碼行數:11,代碼來源:All.php

示例4: testGetsPagesInOutOfBoundsRange

 public function testGetsPagesInOutOfBoundsRange()
 {
     $actual = $this->_paginator->getPagesInRange(-1, 12);
     $this->assertEquals(array_combine(range(1, 11), range(1, 11)), $actual);
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:5,代碼來源:PaginatorTest.php

示例5: testGetPagesInRangeOutOfBounds

 public function testGetPagesInRangeOutOfBounds()
 {
     $this->_restorePaginatorDefaults();
     $actual = $this->_paginator->getPagesInRange(-1, 12);
     $this->assertEquals(array_combine(range(1, 11), range(1, 11)), $actual);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:6,代碼來源:PaginatorTest.php


注:本文中的Zend_Paginator::getPagesInRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。