From 8fd02a1636bc0df98b73a8be151bb56db57aacae Mon Sep 17 00:00:00 2001 From: Slavi Asenov Date: Wed, 21 Oct 2015 16:44:13 +0300 Subject: [PATCH] Update Pagination.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Предлагам getPage() да не връща по-голяма стойност от общия брой страници. --- Pagination.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Pagination.php b/Pagination.php index d5478f3..5fdf225 100644 --- a/Pagination.php +++ b/Pagination.php @@ -106,14 +106,16 @@ public function setPage($page) */ public function getPage() { - // the page was previously set - if ($this->page) { - return $this->page; + // the page wasn't previously set + if (!$this->page) { + // get the current page from the URI + if (preg_match($this->buildPattern(), $this->getUri(), $matches)) { + $this->setPage((int) $matches[1]); + } } - // get the current page from the URI - if (preg_match($this->buildPattern(), $this->getUri(), $matches)) { - return (int) $matches[1]; + if ($this->page) { + return min($this->page, $this->getTotalPages()); } // default page is 1