]> source.dussan.org Git - nextcloud-server.git/commitdiff
add pager function to the base lib and remove the default table width
authorFrank Karlitschek <karlitschek@kde.org>
Sun, 17 Apr 2011 17:46:09 +0000 (19:46 +0200)
committerFrank Karlitschek <karlitschek@kde.org>
Sun, 17 Apr 2011 17:46:09 +0000 (19:46 +0200)
css/styles.css
help/index.php
help/templates/index.php
lib/base.php

index a186c1732416f7c8d3c7848b601d4535558842e4..f0832d059471ea06180b539fb8c726217e263cac 100644 (file)
@@ -70,7 +70,7 @@ form a { color:#000; text-decoration:none; }
 
 /* CONTENT ------------------------------------------------------------------ */
 #content { margin:7em 0 0 16em; }
-table { width:90%; margin:1em 5em 2em 3em; }
+table { margin:1em 5em 2em 3em; }
 table tr.mouseOver td { background-color:#eee; }
 table th, table td { padding:0; border-bottom:1px solid #ddd; text-align:left; font-style:italic; }
 table th { padding:0.5em; }
@@ -118,6 +118,23 @@ p.actions a.delete { background-image:url('../img/delete.png'); }
 #quota_indicator { margin:0 4em 1em 0; padding:0; border:1px solid #ddd; border-radius:10px; -webkit-border-radius:10px; -moz-border-radius:10px; }
 #quota_indicator div { background-color:#76A9EA; border-radius:10px; -webkit-border-radius:10px; -moz-border-radius:10px; }
 
+
+/* PAGER ------------------------------------------------------------ */
+.pager tr td
+{
+    border-bottom: 0px;
+}
+
+
+.pager tr td a
+{
+    text-decoration: none;
+    color: #666666;
+    font-size: 0.9em;
+    text-align: center;
+}
+
+
 /* LOGS --------------------------------------------------------------------- */
 #logs_options { width:auto; margin:0; }
 #logs_options p { padding:0.5em; text-align:left; }
index 426abe3956010af83f49e9934f78804e543b0c35..f77972f58a7f8f11b4f990a99dc09128c0a386fb 100644 (file)
@@ -7,6 +7,11 @@ if( !OC_USER::isLoggedIn()){
     exit();
 }
 
+//hardcode for testing
+$pagecount=8;
+$page=2;
+
+
 // Load the files we need
 OC_UTIL::addStyle( "help", "help" );
 
@@ -17,6 +22,8 @@ $kbe=OC_OCSCLIENT::getKnownledgebaseEntries();
 
 $tmpl = new OC_TEMPLATE( "help", "index", "admin" );
 $tmpl->assign( "kbe", $kbe );
+$tmpl->assign( "pagecount", $pagecount );
+$tmpl->assign( "page", $page );
 $tmpl->printPage();
 
 ?>
index b8444c556e95c9653d1fcb40295c832318316cfd..262ab3d8cabfc785f65d8b84a04543b9292e4b36 100644 (file)
@@ -1,7 +1,7 @@
 
 <h1>Questions and Answers</h1>
 
-<table cellspacing="0">
+<table cellspacing="0" width="100%">
        <tbody>
                <?php foreach($_["kbe"] as $kb): ?>
                        <tr>
                <?php endforeach; ?>
        </tbody>
 </table>
+<?php
+       $url=OC_HELPER::linkTo( "help", "index.php" ).'?page=';
+       OC_UTIL::showPageNavi($_['pagecount'],$_['page'],$url);
+?>
 <a target="_blank" class="prettybutton" href="http://apps.owncloud.com/knowledgebase/editquestion.php?action=new">ASK A QUESTION</a>
 
 
index fad4007aa195544c61422d75b4a6b86dd9587528..ec3052508091181144311a87738aac1b6c9def57 100644 (file)
@@ -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);
+       }
+
 
 
        /**