aboutsummaryrefslogtreecommitdiff
path: root/views/default/navigation/pagination.php
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/navigation/pagination.php')
-rw-r--r--views/default/navigation/pagination.php88
1 files changed, 46 insertions, 42 deletions
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 " <a href=\"{$counturl}\">{$i}</a> ";
- } 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 " <a href=\"{$counturl}\">{$i}</a> ";
+ } else {
+ echo " {$i} ";
+ }
+ $prev = $i;
+
}
- $prev = $i;
}