diff --git a/feed.php b/feed.php index 3b58670d56f6a90984a1ea744d361ce57120e5b2..8b24d2d28c284af6b5a65542a86dac0e0349cb30 100644 --- a/feed.php +++ b/feed.php @@ -77,7 +77,7 @@ * @author Andreas Gohr <andi@splitbrain.org> */ function rssRecentChanges(&$rss,$num,$ltype){ - $recents = getRecents($num); + $recents = getRecents(0,$num); foreach(array_keys($recents) as $id){ $desc = cleanDesc(p_wiki_xhtml($id,'',false)); $item = new FeedItem(); diff --git a/inc/common.php b/inc/common.php index 775071b7f94bfc75559aca85f308eb9a3eacc472..162a1a8e4cb437acd7869d2f2871d9fa2f99f989 100644 --- a/inc/common.php +++ b/inc/common.php @@ -476,16 +476,18 @@ function addLogEntry($date,$id,$summary=""){ /** * returns an array of recently changed files using the * changelog + * first : first entry in array returned * num : return 'num' entries - * num = 0: return count of entries set by $conf['recent'] - * num = -1: return all available entries * * @author Andreas Gohr <andi@splitbrain.org> */ -function getRecents($num=0,$incdel=false){ +function getRecents($first,$num,$incdel=false){ global $conf; $recent = array(); - if(!$num) $num = $conf['recent']; + $names = array(); + + if(!$num) + return $recent; if(!@is_readable($conf['changelog'])){ msg($conf['changelog'].' is not readable',-1); @@ -500,17 +502,20 @@ function getRecents($num=0,$incdel=false){ if(empty($line)) continue; //skip empty lines $info = split("\t",$line); //split into parts //add id if not in yet and file still exists and is allowed to read - if(!$recent[$info[2]] && + if(!$names[$info[2]] && (@file_exists(wikiFN($info[2])) || $incdel) && (auth_quickaclcheck($info[2]) >= AUTH_READ) ){ + $names[$info[2]] = 1; + if(--$first >= 0) continue; /* skip "first" entries */ + $recent[$info[2]]['date'] = $info[0]; $recent[$info[2]]['ip'] = $info[1]; $recent[$info[2]]['user'] = $info[3]; $recent[$info[2]]['sum'] = $info[4]; $recent[$info[2]]['del'] = !@file_exists(wikiFN($info[2])); } - if($num != -1 && count($recent) >= $num){ + if(count($recent) >= $num){ break; //finish if enough items found } } diff --git a/inc/html.php b/inc/html.php index c9b1539f10ddc604831bf7679b7a81a958d32db1..b08f313e14dd03a00def0ab08ed86124bbe86a75 100644 --- a/inc/html.php +++ b/inc/html.php @@ -446,22 +446,28 @@ function html_revisions(){ * display recent changes * * @author Andreas Gohr <andi@splitbrain.org> + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> */ function html_recent($first=0){ global $conf; global $lang; - $recents = getRecents(-1,true); - - if($first >= count($recents)) $first = 0; - $last = $first + $conf['recent']; - if ($last > count($recents)) - $last = count($recents); + + /* we need to get one additionally log entry to be able to + * decide if this is the last page or is there another one. + * This is the cheapest solution to get this information. + */ + $recents = getRecents($first,$conf['recent'] + 1,true); + if(count($recents) == 0 && $first != 0){ + $first=0; + $recents = getRecents(0,$conf['recent'] + 1,true); + } + $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; print p_locale_xhtml('recent'); print '<ul>'; $keys = array_keys($recents); - for ($n=$first; $n < $last; $n++){ + for ($n=0; $n < $cnt; $n++){ $id = $keys[$n]; $date = date($conf['dformat'],$recents[$id]['date']); print '<li>'; @@ -492,16 +498,17 @@ function html_recent($first=0){ print '</ul>'; print '<div class="pagenav">'; + $last = $first + $conf['recent']; if ($first > 0) { $first -= $conf['recent']; if ($first < 0) $first = 0; print '<div class="pagenav-prev">'; - print html_btn('prevpage','',"p",array('do' => 'recent', 'first' => $first)); + print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); print '</div>'; } - if ($last < count($recents)) { + if ($conf['recent'] < count($recents)) { print '<div class="pagenav-next">'; - print html_btn('nextpage','',"n",array('do' => 'recent', 'first' => $last)); + print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); print '</div>'; } print '</div>'; diff --git a/inc/template.php b/inc/template.php index a5e6564432993b0bdfdf8040d69df263e3181d62..ea8b99b6c6d0a990b62790b0d3895bfa1e48713b 100644 --- a/inc/template.php +++ b/inc/template.php @@ -75,8 +75,7 @@ function tpl_content(){ html_diff(); break; case 'recent': - $first = $_REQUEST['first']; - if(empty($first)) $first=0; + $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; html_recent($first); break; case 'index': diff --git a/lang/de/lang.php b/lang/de/lang.php index eaf4286e8f5dda5ef4f21deea273496d30528751..145be6bccdd7651e2ce8a4a1beb08f7815cc5752 100644 --- a/lang/de/lang.php +++ b/lang/de/lang.php @@ -18,8 +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_newer'] = '<< jüngere Änderungen'; +$lang['btn_older'] = 'ältere Änderungen >>'; $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 d9825673649c121cf32bb56596ae2d4d27f9e2fc..d639276d960ef8a1fa403c8cb71ce1303ea4c728 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -17,8 +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_newer'] = '<< more recent'; +$lang['btn_older'] = 'less recent >>'; $lang['btn_revs'] = 'Old revisions'; $lang['btn_recent'] = 'Recent changes'; $lang['btn_upload'] = 'Upload';