From a34ad594a15751bc06b76ac13ed8b4d2c03bfe04 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 9 Jul 2008 10:52:50 +0000 Subject: Slightly more descriptive pagination. git-svn-id: https://code.elgg.org/elgg/trunk@1346 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/navigation/pagination.php | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'views') diff --git a/views/default/navigation/pagination.php b/views/default/navigation/pagination.php index 589acae02..15fa63a67 100644 --- a/views/default/navigation/pagination.php +++ b/views/default/navigation/pagination.php @@ -70,6 +70,55 @@ } + $currentpage = round($offset / $limit) + 1; + $allpages = ceil($count / $limit); + + $i = 1; + $pagesarray = array(); + while ($i <= $allpages && $i <= 3) { + $pagesarray[] = $i; + $i++; + } + $i = $currentpage - 1; + while ($i <= $allpages && $i <= ($currentpage + 1)) { + if ($i > 0 && !in_array($i,$pagesarray)) + $pagesarray[] = $i; + $i++; + } + $i = $allpages - 2; + while ($i <= $allpages) { + if ($i > 0 && !in_array($i,$pagesarray)) + $pagesarray[] = $i; + $i++; + } + + sort($pagesarray); + + $prev = 0; + foreach($pagesarray as $i) { + + if (($i - $prev) > 1) { + + echo " ... "; + + } + + $counturl = $baseurl; + $curoffset = (($i - 1) * $limit); + if (substr_count($baseurl,'?')) { + $counturl .= "&{$word}=" . $curoffset; + } else { + $counturl .= "?{$word}=" . $curoffset; + } + if ($curoffset != $offset) { + echo " {$i} "; + } else { + echo " {$i} "; + } + $prev = $i; + + } + if ($offset < ($count - $limit)) { $nextoffset = $offset + $limit; -- cgit v1.2.3