summaryrefslogtreecommitdiff
path: root/inc/html.php
diff options
context:
space:
mode:
authormatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-05-25 18:16:58 +0200
committermatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-05-25 18:16:58 +0200
commit5749f1ce740e4cfd6d886e8d2fda6b8782389d33 (patch)
tree49ab4432a0cf2028392913f8edef580ac8a947ac /inc/html.php
parent3bc80094f97f3145ebaf4a39d6d21657371a46e3 (diff)
downloadrpg-5749f1ce740e4cfd6d886e8d2fda6b8782389d33.tar.gz
rpg-5749f1ce740e4cfd6d886e8d2fda6b8782389d33.tar.bz2
fix for history navigation buttons
This patch adds some sanity checks for the history start parameter 'first'. Only the needed history entries will be loaded at once now. This will reduce server load a bit darcs-hash:20050525161658-7ef76-1ab681b4c784bbe834fae91301ee7b9cd2a2cd8b.gz
Diffstat (limited to 'inc/html.php')
-rw-r--r--inc/html.php27
1 files changed, 17 insertions, 10 deletions
diff --git a/inc/html.php b/inc/html.php
index c9b1539f1..b08f313e1 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>';