From 0a7233101a755bb1345006c54ac8e3d324651586 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 9 Jul 2008 10:55:30 +0000 Subject: Further pagination change. git-svn-id: https://code.elgg.org/elgg/trunk@1347 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/navigation/pagination.php | 88 +++++++++++++++++---------------- 1 file changed, 46 insertions(+), 42 deletions(-) (limited to 'views/default/navigation') diff --git a/views/default/navigation/pagination.php b/views/default/navigation/pagination.php index 15fa63a67..0ce3b963a 100644 --- a/views/default/navigation/pagination.php +++ b/views/default/navigation/pagination.php @@ -70,52 +70,56 @@ } - $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)) + if ($offset > 0 || $offset < ($count - $limit)) { + + $currentpage = round($offset / $limit) + 1; + $allpages = ceil($count / $limit); + + $i = 1; + $pagesarray = array(); + while ($i <= $allpages && $i <= 3) { $pagesarray[] = $i; - $i++; - } - - sort($pagesarray); - - $prev = 0; - foreach($pagesarray as $i) { - - if (($i - $prev) > 1) { - - echo " ... "; - + $i++; } - - $counturl = $baseurl; - $curoffset = (($i - 1) * $limit); - if (substr_count($baseurl,'?')) { - $counturl .= "&{$word}=" . $curoffset; - } else { - $counturl .= "?{$word}=" . $curoffset; + $i = $currentpage - 1; + while ($i <= $allpages && $i <= ($currentpage + 1)) { + if ($i > 0 && !in_array($i,$pagesarray)) + $pagesarray[] = $i; + $i++; } - if ($curoffset != $offset) { - echo " {$i} "; - } else { - echo " {$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; + } - $prev = $i; } -- cgit v1.2.3