Add paging to the customize page.
This commit is contained in:
parent
0e7f282563
commit
15237ee78d
12
base.php
12
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));
|
||||
|
|
|
@ -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");
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -30,7 +32,11 @@
|
|||
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
|
||||
<script type="text/javascript">
|
||||
|
||||
function updateCookie (id) {
|
||||
if($(id).prop('pattern') && !$(id).val().match(new RegExp ($(id).prop('pattern')))) {
|
||||
return;
|
||||
}
|
||||
var name = $(id).attr('id');
|
||||
var value = $(id).val ();
|
||||
$.cookie(name, value);
|
||||
|
@ -105,6 +111,10 @@
|
|||
<h2><?php echo localize ("customize.fancybox") ?></h2>
|
||||
<h4><input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" <?php echo $use_fancybox ?> /></h4>
|
||||
</article>
|
||||
<article class="frontpage">
|
||||
<h2><?php echo localize ("customize.paging") ?></h2>
|
||||
<h4><input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="<?php echo $max_item_per_page ?>" min="-1" max="1200" pattern="^[-+]?[0-9]+$" /></h4>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
|
|
|
@ -326,6 +326,8 @@
|
|||
"paging.previous.alternate":"Previous",
|
||||
"customize.title":"Customize COPS UI",
|
||||
"customize.style":"Theme",
|
||||
"customize.fancybox":"Use a Lightbox",
|
||||
"customize.fancybox":"Use Fancybox",
|
||||
"customize.paging":"Max number of books per page (-1 to disable)",
|
||||
"fin":"fin"
|
||||
}
|
||||
|
|
|
@ -119,7 +119,8 @@
|
|||
"paging.previous.alternate":"Précédent",
|
||||
"customize.title":"Paramétrage de COPS",
|
||||
"customize.style":"Thème",
|
||||
"customize.fancybox":"Utiliser Fancybox",
|
||||
"customize.fancybox":"Utiliser une Lightbox",
|
||||
"customize.paging":"Nombre de livres par page (-1 pour désactiver)",
|
||||
"languages.eng":"Anglais",
|
||||
"languages.fra":"Français",
|
||||
"fin":"fin"
|
||||
|
|
Loading…
Reference in a new issue