]> source.dussan.org Git - nextcloud-server.git/commitdiff
seperate view and logic for pagenavi
authorRobin Appelman <icewind1991@gmail.com>
Mon, 18 Apr 2011 09:30:56 +0000 (11:30 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Mon, 18 Apr 2011 09:31:01 +0000 (11:31 +0200)
lib/base.php
templates/part.pagenavi.php [new file with mode: 0644]

index ec3052508091181144311a87738aac1b6c9def57..352474e1e83dde91478fb4cce4f5ea5bad63e567 100644 (file)
@@ -242,35 +242,20 @@ class OC_UTIL {
        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>';
+                       
+                       $tmpl = new OC_TEMPLATE( '', 'part.pagenavi', '' );
+                       $tmpl->assign('page',$page);
+                       $tmpl->assign('pagecount',$pagecount);
+                       $tmpl->assign('pagestart',$pagestart);
+                       $tmpl->assign('pagestop',$pagestop);
+                       $tmpl->assign('url',$url);
+                       $tmpl->printPage();
                }
-               echo($txt);
        }
 
 
diff --git a/templates/part.pagenavi.php b/templates/part.pagenavi.php
new file mode 100644 (file)
index 0000000..1bb99b6
--- /dev/null
@@ -0,0 +1,31 @@
+<center>
+       <table class="pager" cellspacing="0" cellpadding="0" border="0">
+               <tr>
+                       <td width="1">
+                               <?php if($_['page']>0):?>
+                                       <span class="pagerbutton1"><a href="<?php echo $_['page']-1;?>">prev</a>&nbsp;&nbsp;</span>
+                               <?php endif; ?>
+                       </td>
+                       <td>
+                               <?php if ($_['pagestart']>0):?>
+                                       ...
+                               <?php endif;?>
+                               <?php for ($i=$_['pagestart']; $i < $_['pagestop'];$i++):?>
+                                       <?php if ($_['page']!=$i):?>
+                                               <a href="<?php echo $_['url'].$i;?>"><?php echo $i+1;?>&nbsp;</a>
+                                       <?php else:?>
+                                               <?php echo $i+1;?>&nbsp;
+                                       <?php endif?>
+                               <?php endfor;?>
+                               <?php if ($_['pagestop']<$_['pagecount']):?>
+                                       ...
+                               <?php endif;?>
+                       </td>
+                       <td width="1">
+                               <?php if(($_['page']+1)<$_['pagecount']):?>
+                                       <span class="pagerbutton2"><a href="<?php echo $_['page']+1;?>">next</a></span>
+                               <?php endif; ?>
+                       </td>
+               </tr>
+       </table>
+</center>
\ No newline at end of file