pkg_search_results: rewrite of pagination

* Most of the PHP-code was moved to pkgfuncs.php to keep the template simple.

Signed-off-by: PyroPeter <abi1789@googlemail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
PyroPeter 2011-02-16 18:48:09 +01:00 committed by Lukas Fleischer
parent 0de4ce61be
commit 1fdecbd5a4
3 changed files with 46 additions and 69 deletions

View file

@ -559,6 +559,32 @@ function pkg_search_page($SID="") {
if ($total > 1 || $total == 0) {
# calculation of pagination links
$per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 25;
$current = ceil($first / $per_page);
$pages = ceil($total / $per_page);
$templ_pages = array();
if ($current > 1) {
$templ_pages[__('First')] = 0;
$templ_pages[__('Previous')] = ($current - 2) * $per_page;
}
if ($current - 5 > 1)
$templ_pages["..."] = false;
for ($i = max($current - 5, 1); $i <= min($pages, $current + 5); $i++) {
$templ_pages[$i] = ($i - 1) * $per_page;
}
if ($current + 5 < $pages)
$templ_pages["... "] = false;
if ($current < $pages) {
$templ_pages[__('Next')] = $current * $per_page;
$templ_pages[__('Last')] = ($pages - 1) * $per_page;
}
include('pkg_search_form.php');
include('pkg_search_results.php');
}