From 15237ee78dffa40407cedf69a267248a517fb126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Wed, 26 Jun 2013 21:28:04 +0200 Subject: [PATCH] Add paging to the customize page. --- base.php | 12 ++++++------ customize.php | 12 +++++++++++- lang/Localization_en.json | 2 ++ lang/Localization_fr.json | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/base.php b/base.php index adbd513..670e79e 100644 --- a/base.php +++ b/base.php @@ -437,9 +437,9 @@ class Page public function isPaginated () { global $config; - return ($config['cops_max_item_per_page'] != -1 && + return (getCurrentOption ("max_item_per_page") != -1 && $this->totalNumber != -1 && - $this->totalNumber > $config['cops_max_item_per_page']); + $this->totalNumber > getCurrentOption ("max_item_per_page")); } public function getNextLink () @@ -447,7 +447,7 @@ class Page global $config; $currentUrl = $_SERVER['QUERY_STRING']; $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . $_SERVER['QUERY_STRING']); - if (($this->n) * $config['cops_max_item_per_page'] < $this->totalNumber) { + if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) { return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", "Page suivante"); } return NULL; @@ -467,7 +467,7 @@ class Page public function getMaxPage () { global $config; - return ceil ($this->totalNumber / $config['cops_max_item_per_page']); + return ceil ($this->totalNumber / getCurrentOption ("max_item_per_page")); } public function containsBook () @@ -772,7 +772,7 @@ abstract class Base global $config; $totalResult = -1; - if ($config['cops_max_item_per_page'] != -1 && $n != -1) + if (getCurrentOption ("max_item_per_page") != -1 && $n != -1) { // First check total number of results $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); @@ -781,7 +781,7 @@ abstract class Base // Next modify the query and params $query .= " limit ?, ?"; - array_push ($params, ($n - 1) * $config['cops_max_item_per_page'], $config['cops_max_item_per_page']); + array_push ($params, ($n - 1) * getCurrentOption ("max_item_per_page"), getCurrentOption ("max_item_per_page")); } $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter)); diff --git a/customize.php b/customize.php index 2c2f78a..a3c2afc 100644 --- a/customize.php +++ b/customize.php @@ -11,13 +11,15 @@ require_once ("base.php"); - header ("Content-Type:application/xhtml+xml;charset=utf-8"); + header ("Content-Type:text/html;charset=utf-8"); $database = GetUrlParam (DB); $use_fancybox = ""; if (getCurrentOption ("use_fancyapps") == 1) { $use_fancybox = "checked='checked'"; } + $max_item_per_page = getCurrentOption ("max_item_per_page"); + ?> @@ -30,7 +32,11 @@ " />