aboutsummaryrefslogtreecommitdiff
path: root/views/default/navigation
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-09 10:52:50 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-09 10:52:50 +0000
commita34ad594a15751bc06b76ac13ed8b4d2c03bfe04 (patch)
tree72f26b37b6bafa28181541832f48af778078386d /views/default/navigation
parentc9db26a78f37b4288231233637a50f7a1f2f2102 (diff)
downloadelgg-a34ad594a15751bc06b76ac13ed8b4d2c03bfe04.tar.gz
elgg-a34ad594a15751bc06b76ac13ed8b4d2c03bfe04.tar.bz2
Slightly more descriptive pagination.
git-svn-id: https://code.elgg.org/elgg/trunk@1346 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/navigation')
-rw-r--r--views/default/navigation/pagination.php49
1 files changed, 49 insertions, 0 deletions
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 " <a href=\"{$counturl}\">{$i}</a> ";
+ } else {
+ echo " {$i} ";
+ }
+ $prev = $i;
+
+ }
+
if ($offset < ($count - $limit)) {
$nextoffset = $offset + $limit;