Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Paginator / ScrollingStyle / Sliding.php
blobe75edc65c302968c2e2af7aefd332c0eaf999c3e
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Paginator\ScrollingStyle;
12 use Zend\Paginator\Paginator;
14 /**
15 * A Yahoo! Search-like scrolling style. The cursor will advance to
16 * the middle of the range, then remain there until the user reaches
17 * the end of the page set, at which point it will continue on to
18 * the end of the range and the last page in the set.
20 * @link http://search.yahoo.com/search?p=Zend+Framework
22 class Sliding implements ScrollingStyleInterface
24 /**
25 * Returns an array of "local" pages given a page number and range.
27 * @param Paginator $paginator
28 * @param int $pageRange (Optional) Page range
29 * @return array
31 public function getPages(Paginator $paginator, $pageRange = null)
33 if ($pageRange === null) {
34 $pageRange = $paginator->getPageRange();
37 $pageNumber = $paginator->getCurrentPageNumber();
38 $pageCount = count($paginator);
40 if ($pageRange > $pageCount) {
41 $pageRange = $pageCount;
44 $delta = ceil($pageRange / 2);
46 if ($pageNumber - $delta > $pageCount - $pageRange) {
47 $lowerBound = $pageCount - $pageRange + 1;
48 $upperBound = $pageCount;
49 } else {
50 if ($pageNumber - $delta < 0) {
51 $delta = $pageNumber;
54 $offset = $pageNumber - $delta;
55 $lowerBound = $offset + 1;
56 $upperBound = $offset + $pageRange;
59 return $paginator->getPagesInRange($lowerBound, $upperBound);