From be4bcf3e9fffe0ab2d72d945d7b36c66a80f2ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Fri, 21 Sep 2012 13:36:52 +0200 Subject: [PATCH] Add basing pagin support in HTML catalog --- base.php | 22 ++++++++++++++++++++++ index.php | 24 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/base.php b/base.php index cba5abe..40ffe0e 100644 --- a/base.php +++ b/base.php @@ -241,6 +241,28 @@ class Page array_push ($this->entryArray, Tag::getCount()); $this->entryArray = array_merge ($this->entryArray, Book::getCount()); } + + public function getNextLink () + { + global $config; + $currentUrl = $_SERVER['QUERY_STRING']; + $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . $_SERVER['QUERY_STRING']); + if (($this->n) * $config['cops_max_item_per_page'] < $this->totalNumber) { + return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", "Page suivante"); + } + return NULL; + } + + public function getPrevLink () + { + global $config; + $currentUrl = $_SERVER['QUERY_STRING']; + $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . $_SERVER['QUERY_STRING']); + if ($this->n > 1) { + return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", "Page precedente"); + } + return NULL; + } } diff --git a/index.php b/index.php index 4658893..b940c28 100644 --- a/index.php +++ b/index.php @@ -218,6 +218,30 @@ } ?> +totalNumber != -1) { + $prevLink = $currentPage->getPrevLink (); + $nextLink = $currentPage->getNextLink (); +?> +
+ + Prev + + + Next + +
+