From be20753e7ed49d90ce70134da3569a4f0ecae03e Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 21 Aug 2003 13:47:14 +0000 Subject: [PATCH] Some better paging that now works with any number of pages --- lib/weblib.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 06564935f3..91dd2f0e09 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1618,30 +1618,35 @@ function obfuscate_mailto($email, $label="") { function print_paging_bar($totalcount, $page, $perpage, $baseurl) { /// Prints a single paging bar to provide access to other pages (usually in a search) - $maxdisplay = 30; + $maxdisplay = 20; if ($totalcount > $perpage) { + $lastpage = ceil($totalcount / $perpage); + if ($page > 15) { + $startpage = $page - 10; + } else { + $startpage = 0; + } + echo "
"; echo "

".get_string("page").":"; - $count = 0; - while ($totalcount > 0) { - $displaypage = $count+1; - if ($page == $count) { + $currpage = $startpage; + $displaycount = 0; + while ($displaycount < $maxdisplay and $currpage < $lastpage) { + $displaypage = $currpage+1; + if ($page == $currpage) { echo "  $displaypage"; } else { - echo "  $displaypage"; - } - $totalcount -= $perpage; - $count++; - if ($count > $maxdisplay) { - echo " ..."; - break; + echo "  $displaypage"; } + $displaycount++; + $currpage++; } $pagenum = $page + 1; - if ($pagenum != $count) { + if ($pagenum != $displaypage) { echo "  (".get_string("next").")"; } echo "

"; + echo "
"; } } -- 2.39.5