Пример #1
0
 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  \Paginator\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);
 }
Пример #2
0
 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  \Paginator\Paginator $paginator
  * @param  int $pageRange Unused
  * @return array
  */
 public function getPages(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);
 }
Пример #3
0
 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  \Paginator\Paginator $paginator
  * @param  int $pageRange (Optional) Page range
  * @return array
  */
 public function getPages(Paginator $paginator, $pageRange = null)
 {
     if ($pageRange === null) {
         $pageRange = $paginator->getPageRange();
     }
     $pageNumber = $paginator->getCurrentPageNumber();
     $pageCount = count($paginator);
     if ($pageRange > $pageCount) {
         $pageRange = $pageCount;
     }
     $delta = ceil($pageRange / 2);
     if ($pageNumber - $delta > $pageCount - $pageRange) {
         $lowerBound = $pageCount - $pageRange + 1;
         $upperBound = $pageCount;
     } else {
         if ($pageNumber - $delta < 0) {
             $delta = $pageNumber;
         }
         $offset = $pageNumber - $delta;
         $lowerBound = $offset + 1;
         $upperBound = $offset + $pageRange;
     }
     return $paginator->getPagesInRange($lowerBound, $upperBound);
 }