r93 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92‎ | r93 | r94 >
Date:05:28, 8 February 2002
Author:vibber
Status:old
Tags:
Comment:
5-minute minimum wait between refreshes of WantedPages
Modified paths:
  • /trunk/phpwiki/fpw/special_wantedpages.php (modified) (history)
  • /trunk/phpwiki/fpw/wikiTextEn.php (modified) (history)

Diff [purge]

Index: trunk/phpwiki/fpw/special_wantedpages.php
@@ -1,7 +1,7 @@
22 <?
33 function refreshWantedPages () {
44 global $showNumberPages , $linkedLinks , $unlinkedLinks , $vpage , $wikiWantedText , $wikiWantedLine ;
5 - global $wikiWantedToggleNumbers ;
 5+ global $wikiWantedToggleNumbers, $wikiLastRefreshed ;
66 $vpage->special ( "The Most Wanted Pages" ) ;
77 $vpage->namespace = "" ;
88 if ( $showNumberPages == "" ) $showNumberPages = "off" ;
@@ -61,28 +61,44 @@
6262 }
6363 }
6464 $ret .= implode ( "" , $o ) ;
 65+
 66+ $now = time () ;
 67+ $lc = wikiGetDate ( $now ) . date ( ", H:i" , $now ) ;
 68+ #$lc .= ", ".substr ( $now , 8 , 2 ) ;
 69+ #$lc .= ":".substr ( $now , 10 , 2 ) ;
 70+ $ret .= "\n<p>" . str_replace ( "$1", $lc, $wikiLastRefreshed ) . "</p>\n" ;
6571
6672 return $ret ;
6773 }
6874
6975 function WantedPages () {
70 - global $doRefresh , $wikiRefreshThisPage , $wikiResourcesWarning ;
 76+ global $doRefresh , $wikiRefreshThisPage , $wikiResourcesWarning , $wikiNoRefresh ;
7177 $pn = "Log:Most_Wanted" ;
 78+ $minRefreshPeriod = 5*60; # Refuse to update more often than every 5 minutes
7279 $ret = "<nowiki>" ;
7380
7481 $ret .= "<p align=center><font size='+1'><b><a href=\"" ;
7582 $ret .= wikiLink ( "special:WantedPages&doRefresh=yes" ) ;
7683 $ret .= "\">$wikiRefreshThisPage</a></b></font><br>$wikiResourcesWarning</p></nowiki>\n" ;
7784 if ( $doRefresh == "yes" ) {
78 - $o = refreshWantedPages () ;
79 - $ret .= $o ;
80 - $p = new wikiPage ;
81 - $p->setTitle ( $pn ) ;
82 - $p->ensureExistence () ;
83 - $p->setEntry ( $o , "Refresh" , 0 , "System" , 1 , ",cur_timestamp=cur_timestamp" ) ; # Storing, don't show on RC
84 - } else {
85 - $ret .= getMySQL ( "cur" , "cur_text" , "cur_title=\"$pn\"" ) ;
 85+ $timestamp = getMySQL ( "cur" , "UNIX_TIMESTAMP(cur_timestamp)" , "cur_title=\"$pn\"" ) ;
 86+ if ( ( $lastrefreshed = time() - $timestamp ) < $minRefreshPeriod ) {
 87+ $ret .= "<p><i>" . str_replace ( array ( "$1", "$2" ) ,
 88+ array ( round ( $lastrefreshed / 60 ) , round ( ( $minRefreshPeriod - $lastrefreshed ) / 60 ) ),
 89+ $wikiNoRefresh ) . "</i></p>\n\n";
 90+ } else {
 91+ $o = refreshWantedPages () ;
 92+ $ret .= $o ;
 93+ $p = new wikiPage ;
 94+ $p->setTitle ( $pn ) ;
 95+ $p->ensureExistence () ;
 96+ #$p->setEntry ( $o , "Refresh" , 0 , "System" , 1 , ",cur_timestamp=cur_timestamp" ) ; # Storing, don't show on RC
 97+ $p->setEntry ( $o , "Refresh" , 0 , "System" , 1 , "" ) ; # Storing, don't show on RC
 98+ $timestamp2 = getMySQL ( "cur" , "UNIX_TIMESTAMP(cur_timestamp)" , "cur_title=\"$pn\"" ) ;
 99+ return $ret;
 100+ }
86101 }
 102+ $ret .= getMySQL ( "cur" , "cur_text" , "cur_title=\"$pn\"" ) ;
87103 return $ret ;
88104 }
89 -?>
\ No newline at end of file
 105+?>
Index: trunk/phpwiki/fpw/wikiTextEn.php
@@ -337,6 +337,8 @@
338338 $wikiPopularPages = "Most popular" ;
339339 $wikiRefreshThisPage = "Refresh this page" ;
340340 $wikiResourcesWarning = "(Please, do this only when necessary, as this function uses a high amount of system resources)" ;
 341+$wikiNoRefresh = "(The page was last refreshed just $1 minutes ago; please wait another $2 minutes and try again.)" ;
 342+$wikiLastRefreshed = "Last refreshed $1" ;
341343
342344 #---------------------------
343345 #Functions

Status & tagging log