seperate view and logic for pagenavi

remotes/origin/stable
Robin Appelman 14 years ago
parent 5249f09f70
commit 900ece18e7
  1. 31
      lib/base.php
  2. 31
      templates/part.pagenavi.php

@ -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);
}

@ -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>
Loading…
Cancel
Save