mirror of
https://github.com/torrentpier/torrentpier-lts.git
synced 2025-03-01 15:21:02 +03:00
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Zend Framework (http://framework.zend.com/)
|
|
*
|
|
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
|
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
*/
|
|
|
|
namespace Zend\Paginator\ScrollingStyle;
|
|
|
|
use Zend\Paginator\Paginator;
|
|
|
|
/**
|
|
* A Google-like scrolling style. Incrementally expands the range to about
|
|
* twice the given page range, then behaves like a slider. See the example
|
|
* link.
|
|
*
|
|
* @link http://www.google.com/search?q=Zend+Framework
|
|
*/
|
|
class Elastic extends Sliding
|
|
{
|
|
/**
|
|
* Returns an array of "local" pages given a page number and range.
|
|
*
|
|
* @param Paginator $paginator
|
|
* @param int $pageRange Unused
|
|
* @return array
|
|
*/
|
|
public function getPages(Paginator $paginator, $pageRange = null)
|
|
{
|
|
$pageRange = $paginator->getPageRange();
|
|
$pageNumber = $paginator->getCurrentPageNumber();
|
|
|
|
$originalPageRange = $pageRange;
|
|
$pageRange = $pageRange * 2 - 1;
|
|
|
|
if ($originalPageRange + $pageNumber - 1 < $pageRange) {
|
|
$pageRange = $originalPageRange + $pageNumber - 1;
|
|
} elseif ($originalPageRange + $pageNumber - 1 > count($paginator)) {
|
|
$pageRange = $originalPageRange + count($paginator) - $pageNumber;
|
|
}
|
|
|
|
return parent::getPages($paginator, $pageRange);
|
|
}
|
|
}
|