summaryrefslogtreecommitdiff
path: root/web/lib
diff options
context:
space:
mode:
authorPyroPeter <abi1789@googlemail.com>2011-02-16 18:48:09 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2011-02-17 18:54:26 +0100
commit1fdecbd5a45ef631562a11937d870e4c8cf619b0 (patch)
tree3c0f027576576d31ca6666a503c55f6f5078db5b /web/lib
parent0de4ce61be3000cb110e538c61c194c429239579 (diff)
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>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgfuncs.inc26
1 files changed, 26 insertions, 0 deletions
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 2f69321..f5591f3 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -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');
}