summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrank Karlitschek <karlitschek@kde.org>2011-04-17 19:46:09 +0200
committerFrank Karlitschek <karlitschek@kde.org>2011-04-17 19:46:09 +0200
commit91b5d8575a403877106e4cd048d90e0c117dae66 (patch)
tree14d925684eecb0ce4b30c270fe171e643cb638f4 /lib
parent47223ae2d98cf74101fd42a49d388ba48d01f80e (diff)
downloadnextcloud-server-91b5d8575a403877106e4cd048d90e0c117dae66.tar.gz
nextcloud-server-91b5d8575a403877106e4cd048d90e0c117dae66.zip
add pager function to the base lib and remove the default table width
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/base.php b/lib/base.php
index fad4007aa19..ec305250809 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -231,6 +231,48 @@ class OC_UTIL {
return date($timeformat,$timestamp);
}
+ /**
+ * Shows a pagenavi widget where you can jump to different pages.
+ *
+ * @param int $pagecount
+ * @param int $page
+ * @param string $url
+ * @return html-string
+ */
+ public static function showPageNavi($pagecount,$page,$url) {
+
+ $pagelinkcount=8;
+ $txt='';
+ if ($pagecount>1) {
+ $txt.='<center><table class="pager" cellspacing="0" cellpadding="0" border="0"><tr><td width="1">';
+
+ if ($page>'0') {
+ $txt.='<span class="pagerbutton1"><a href="'.$url.($page-1).'">prev</a>&nbsp;&nbsp;</span>';
+ }
+ $txt.='</td><td width="1">';
+
+ $pagestart=$page-$pagelinkcount;
+ if($pagestart<0) $pagestart=0;
+ $pagestop=$page+$pagelinkcount;
+ if($pagestop>$pagecount) $pagestop=$pagecount;
+ if ($pagestart<>0) $txt.='...';
+ for ($i=$pagestart; $i < $pagestop;$i++) {
+ if ($i<>$page) {
+ $txt.='<a href="'.$url.$i.'">&nbsp;'.($i+1).'&nbsp;</a>';
+ } else {
+ $txt.='&nbsp;<b>'.($i+1).'</b>&nbsp;';
+ }
+ }
+ if ($pagecount>$pagestop) $txt.='...';
+ $txt.='</td><td width="1">';
+ if (($page+1)<$pagecount) {
+ $txt.='<span class="pagerbutton2"><a href="'.$url.($page+1).'">next</a></span>';
+ }
+ $txt.='</td></tr></table></center>';
+ }
+ echo($txt);
+ }
+
/**