File indexing completed on 2024-12-22 05:36:53

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Paginator
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /**
0023  * @see Zend_Paginator_ScrollingStyle_Sliding
0024  */
0025 // require_once 'Zend/Paginator/ScrollingStyle/Sliding.php';
0026 
0027 /**
0028  * A Google-like scrolling style.  Incrementally expands the range to about
0029  * twice the given page range, then behaves like a slider.  See the example
0030  * link.
0031  *
0032  * @link       http://www.google.com/search?q=Zend+Framework
0033  * @category   Zend
0034  * @package    Zend_Paginator
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  */
0038 class Zend_Paginator_ScrollingStyle_Elastic extends Zend_Paginator_ScrollingStyle_Sliding
0039 {
0040     /**
0041      * Returns an array of "local" pages given a page number and range.
0042      *
0043      * @param  Zend_Paginator $paginator
0044      * @param  integer $pageRange Unused
0045      * @return array
0046      */
0047     public function getPages(Zend_Paginator $paginator, $pageRange = null)
0048     {
0049         $pageRange  = $paginator->getPageRange();
0050         $pageNumber = $paginator->getCurrentPageNumber();
0051 
0052         $originalPageRange = $pageRange;
0053         $pageRange         = $pageRange * 2 - 1;
0054 
0055         if ($originalPageRange + $pageNumber - 1 < $pageRange) {
0056             $pageRange = $originalPageRange + $pageNumber - 1;
0057         } else if ($originalPageRange + $pageNumber - 1 > count($paginator)) {
0058             $pageRange = $originalPageRange + count($paginator) - $pageNumber;
0059         }
0060 
0061         return parent::getPages($paginator, $pageRange);
0062     }
0063 }