add pager function to the base lib and remove the default table width

This commit is contained in:
Frank Karlitschek 2011-04-17 19:46:09 +02:00
parent 47223ae2d9
commit 91b5d8575a
4 changed files with 72 additions and 2 deletions

View 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; }

View 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();
?>

View 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>
@ -13,6 +13,10 @@
<?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>

View 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);
}
/**