From a39955b0135f89ef41e583346fd459934a652025 Mon Sep 17 00:00:00 2001 From: matthiasgrimm Date: Mon, 23 May 2005 18:58:26 +0200 Subject: history navigation buttons This patch adds a 'next' and a 'previous' button to the history page. They make it possible to see more than one page of history data. darcs-hash:20050523165826-7ef76-77a2c21e8b172200f169e0aea8441e8b100ab278.gz --- inc/common.php | 5 ++++- inc/html.php | 29 ++++++++++++++++++++++++++--- inc/template.php | 4 +++- lang/de/lang.php | 2 ++ lang/en/lang.php | 2 ++ tpl/default/design.css | 26 ++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 5 deletions(-) diff --git a/inc/common.php b/inc/common.php index 728319e09..775071b7f 100644 --- a/inc/common.php +++ b/inc/common.php @@ -476,6 +476,9 @@ function addLogEntry($date,$id,$summary=""){ /** * returns an array of recently changed files using the * changelog + * num : return 'num' entries + * num = 0: return count of entries set by $conf['recent'] + * num = -1: return all available entries * * @author Andreas Gohr */ @@ -507,7 +510,7 @@ function getRecents($num=0,$incdel=false){ $recent[$info[2]]['sum'] = $info[4]; $recent[$info[2]]['del'] = !@file_exists(wikiFN($info[2])); } - if(count($recent) >= $num){ + if($num != -1 && count($recent) >= $num){ break; //finish if enough items found } } diff --git a/inc/html.php b/inc/html.php index 370754c52..c9b1539f1 100644 --- a/inc/html.php +++ b/inc/html.php @@ -447,14 +447,22 @@ function html_revisions(){ * * @author Andreas Gohr */ -function html_recent(){ +function html_recent($first=0){ global $conf; global $lang; - $recents = getRecents(0,true); + $recents = getRecents(-1,true); + + if($first >= count($recents)) $first = 0; + $last = $first + $conf['recent']; + if ($last > count($recents)) + $last = count($recents); print p_locale_xhtml('recent'); print '
    '; - foreach(array_keys($recents) as $id){ + + $keys = array_keys($recents); + for ($n=$first; $n < $last; $n++){ + $id = $keys[$n]; $date = date($conf['dformat'],$recents[$id]['date']); print '
  • '; @@ -482,6 +490,21 @@ function html_recent(){ print '
  • '; } print '
'; + + print ''; } /** diff --git a/inc/template.php b/inc/template.php index f76e48108..a5e656443 100644 --- a/inc/template.php +++ b/inc/template.php @@ -75,7 +75,9 @@ function tpl_content(){ html_diff(); break; case 'recent': - html_recent(); + $first = $_REQUEST['first']; + if(empty($first)) $first=0; + html_recent($first); break; case 'index': html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? diff --git a/lang/de/lang.php b/lang/de/lang.php index 9a4e95c43..eaf4286e8 100644 --- a/lang/de/lang.php +++ b/lang/de/lang.php @@ -18,6 +18,8 @@ $lang['btn_search'] = 'Suche'; $lang['btn_save'] = 'Speichern'; $lang['btn_preview']= 'Vorschau'; $lang['btn_top'] = 'Nach oben'; +$lang['btn_prevpage']= '<< zurück'; +$lang['btn_nextpage']= 'weiter >>'; $lang['btn_revs'] = 'Ältere Versionen'; $lang['btn_recent'] = 'Letzte Änderungen'; $lang['btn_upload'] = 'Hochladen'; diff --git a/lang/en/lang.php b/lang/en/lang.php index b56e489c4..d98256736 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -17,6 +17,8 @@ $lang['btn_search'] = 'Search'; $lang['btn_save'] = 'Save'; $lang['btn_preview']= 'Preview'; $lang['btn_top'] = 'Back to top'; +$lang['btn_prevpage']= '<< previous page'; +$lang['btn_nextpage']= 'next page >>'; $lang['btn_revs'] = 'Old revisions'; $lang['btn_recent'] = 'Recent changes'; $lang['btn_upload'] = 'Upload'; diff --git a/tpl/default/design.css b/tpl/default/design.css index 75210ac18..792f508be 100644 --- a/tpl/default/design.css +++ b/tpl/default/design.css @@ -148,6 +148,32 @@ div.secedit input.button { display: inline; } +/* ----------- page navigator ------------- */ + +div.pagenav { + margin-top:1em; +} + +div.pagenav-prev { + text-align:right; + float:left; + width:50% +} + +div.pagenav-prev input.button { + margin-right:5px; +} + +div.pagenav-next { + text-align:left; + float:right; + width:50% +} + +div.pagenav-next input.button { + margin-left:5px; +} + /* --------------- Links ------------------ */ a { -- cgit v1.2.3