diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-18 13:34:58 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-18 13:34:58 +0000 |
commit | 269386b9cfa0e1558edde89442c6f571ef32c645 (patch) | |
tree | 8714e84ec6bcfca99bf3ee560024090d36cc6543 /views/default/navigation/pagination.php | |
parent | c3a4bafc3f3f0984e8751e00e024ab8c09e0ff1b (diff) | |
download | elgg-269386b9cfa0e1558edde89442c6f571ef32c645.tar.gz elgg-269386b9cfa0e1558edde89442c6f571ef32c645.tar.bz2 |
Added generic listing and pagination functions
git-svn-id: https://code.elgg.org/elgg/trunk@964 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/navigation/pagination.php')
-rw-r--r-- | views/default/navigation/pagination.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/views/default/navigation/pagination.php b/views/default/navigation/pagination.php new file mode 100644 index 000000000..c946544ae --- /dev/null +++ b/views/default/navigation/pagination.php @@ -0,0 +1,82 @@ +<?php
+
+ /**
+ * Elgg pagination
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ *
+ */
+
+ if (!isset($vars['offset'])) {
+ $offset = 0;
+ } else {
+ $offset = $vars['offset'];
+ }
+ if (!isset($vars['limit'])) {
+ $limit = 10;
+ } else {
+ $limit = $vars['limit'];
+ }
+ if (!isset($vars['count'])) {
+ $count = 0;
+ } else {
+ $count = $vars['count'];
+ }
+
+ $totalpages = ceil($count / $limit);
+ $currentpage = ceil($offset / $limit) + 1;
+
+ $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$vars['baseurl']);
+
+?>
+
+<div class="pagination">
+ <p>
+<?php
+
+ if ($count == 0) {
+
+ echo elgg_echo("notfound");
+
+ }
+
+ if ($offset > 0) {
+
+ $prevoffset = $offset - $limit;
+ if ($prevoffset < 0) $prevoffset = 0;
+
+ $prevurl = $baseurl;
+ if (substr_count($baseurl,'?')) {
+ $prevurl .= "&offset=" . $prevoffset;
+ } else {
+ $prevurl .= "?offset=" . $prevoffset;
+ }
+
+ echo "<a href=\"{$prevurl}\"><< ". elgg_echo("previous") ."</a> ";
+
+ }
+
+ if ($offset < ($count - $limit)) {
+
+ $nextoffset = $offset + $limit;
+ if ($nextoffset >= $count) $nextoffset--;
+
+ $nexturl = $baseurl;
+ if (substr_count($baseurl,'?')) {
+ $nexturl .= "&offset=" . $nextoffset;
+ } else {
+ $nexturl .= "?offset=" . $nextoffset;
+ }
+
+ echo " <a href=\"{$nexturl}\">" . elgg_echo("next") . " >></a>";
+
+ }
+
+?>
+ </p>
+</div>
\ No newline at end of file |