Some better paging that now works with any number of pages
This commit is contained in:
+18
-13
@@ -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 "<center>";
|
||||
echo "<p>".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 " <a href=\"{$baseurl}page=$count\">$displaypage</a>";
|
||||
}
|
||||
$totalcount -= $perpage;
|
||||
$count++;
|
||||
if ($count > $maxdisplay) {
|
||||
echo " ...";
|
||||
break;
|
||||
echo " <a href=\"{$baseurl}page=$currpage\">$displaypage</a>";
|
||||
}
|
||||
$displaycount++;
|
||||
$currpage++;
|
||||
}
|
||||
$pagenum = $page + 1;
|
||||
if ($pagenum != $count) {
|
||||
if ($pagenum != $displaypage) {
|
||||
echo " (<a href=\"{$baseurl}page=$pagenum\">".get_string("next")."</a>)";
|
||||
}
|
||||
echo "</p>";
|
||||
echo "</center>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user