本文整理汇总了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);
}
示例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;
}
示例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());
}
示例4: testGetsPagesInOutOfBoundsRange
public function testGetsPagesInOutOfBoundsRange()
{
$actual = $this->_paginator->getPagesInRange(-1, 12);
$this->assertEquals(array_combine(range(1, 11), range(1, 11)), $actual);
}
示例5: testGetPagesInRangeOutOfBounds
public function testGetPagesInRangeOutOfBounds()
{
$this->_restorePaginatorDefaults();
$actual = $this->_paginator->getPagesInRange(-1, 12);
$this->assertEquals(array_combine(range(1, 11), range(1, 11)), $actual);
}