From face17f6060ff7e706423015341641eeadce6c7b Mon Sep 17 00:00:00 2001 From: "Vladislav O. Vlastovskiy" Date: Thu, 2 Aug 2012 13:07:38 +0400 Subject: [PATCH] Updated return a range of pages If page = 20 and maximum number of displayed pages 10, current 18, then: Old implementation: tmp = 18 - 5 = 13 begin = 13 end = 20 Total will be returned only 7 pages. In the new implementation: tmp = 18 - 5 + 1 = 14 (+1 for more shows to the next page) start = 14 end = 20 begin = 11 Total will be returned only 10 pages, because they exist, and do not reduce the navigation. --- Pager.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Pager.php b/Pager.php index 80f418a..0118191 100644 --- a/Pager.php +++ b/Pager.php @@ -213,11 +213,13 @@ public function getPages() { $pages = $this->getMaxPages(); - $tmp = $this->page - floor($pages / 2); + $tmp = $this->page - floor($pages / 2) + 1; - $begin = $tmp > $this->getFirstPage() ? $tmp : $this->getFirstPage(); + $start = $tmp > $this->getFirstPage() ? $tmp : $this->getFirstPage(); - $end = min($begin + $pages - 1, $this->getLastPage()); + $end = min($start + $pages - 1, $this->getLastPage()); + + $begin = ($end - $pages + 1) > $this->getFirstPage() ? $end - $pages + 1 : $this->getFirstPage(); return range($begin, $end, 1); }