{
# For now, assume title is correct dbkey
# and log pages always go in Wikipedia namespace
- $this->mTitle = $title;
+ $this->mTitle = str_replace( " ", "_", $title );
$this->mId = 0;
$this->mUpdateRecentChanges = true ;
$this->mContentLoaded = false;
function getContent( $defaulttext = "<ul>\n</ul>" )
{
- $sql = "SELECT cur_id,cur_text FROM cur " .
+ $sql = "SELECT cur_id,cur_text,cur_timestamp FROM cur " .
"WHERE cur_namespace=" . Namespace::getWikipedia() . " AND " .
"cur_title='" . wfStrencode($this->mTitle ) . "'";
$res = wfQuery( $sql, "LogPage::getContent" );
$s = wfFetchObject( $res );
$this->mId = $s->cur_id;
$this->mContent = $s->cur_text;
+ $this->mTimestamp = $s->cur_timestamp;
} else {
$this->mId = 0;
$this->mContent = $defaulttext;
+ $this->mTimestamp = wfTimestampNow();
}
$this->mContentLoaded = true; # Well, sort of
return $this->mContent;
}
+
+ function getTimestamp()
+ {
+ if( !$this->mContentLoaded ) {
+ $this->getContent();
+ }
+ return $this->mTimestamp;
+ }
function saveContent()
{
+ if( wfReadOnly() ) return;
+
global $wgUser;
$fname = "LogPage::saveContent";
$uid = $wgUser->getID();
$ut = wfStrencode( $wgUser->getName() );
if( !$this->mContentLoaded ) return false;
- $now = date( "YmdHis" );
+ $this->mTimestamp = $now = wfTimestampNow();
$won = wfInvertTimestamp( $now );
if($this->mId == 0) {
$sql = "INSERT INTO cur (cur_timestamp,cur_user,cur_user_text,
return $this->saveContent();
}
+
+ function replaceContent( $text, $comment = "" )
+ {
+ $this->mContent = $text;
+ $this->mComment = $comment;
+ $this->mTimestamp = wfTimestampNow();
+ return $this->saveContent();
+ }
+
+ function showAsDisabledPage( $rawhtml = true )
+ {
+ global $wgLang, $wgOut;
+ $wgOut->checkLastModified( $this->getTimestamp() );
+ $func = ( $rawhtml ? "addHTML" : "addWikiText" );
+ $wgOut->$func(
+ "<p>" . wfMsg( "perfdisabled" ) . "</p>\n\n" .
+ "<p>" . wfMsg( "perfdisabledsub", $wgLang->timeanddate( $this->getTimestamp() ) ) . "</p>\n\n" .
+ "<hr />\n\n" .
+ $this->getContent()
+ );
+ return;
+
+ }
}
?>
function indexShowToplevel()
{
- global $wgOut, $indexMaxperpage;
+ global $wgOut, $indexMaxperpage, $wgLang;
$fname = "indexShowToplevel";
- # FIXME: This may be slow; we may need to cache it
+
+ # Cache
+ $vsp = $wgLang->getValidSpecialPages();
+ $log = new LogPage( $vsp["Allpages"] );
+ $log->mUpdateRecentChanges = false;
+
+ global $wgMiserMode;
+ if ( $wgMiserMode ) {
+ $log->showAsDisabledPage();
+ return;
+ }
+
# $fromwhere = "FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0";
$fromwhere = "FROM cur WHERE cur_namespace=0";
$outpoint = $s->cur_title;
$out .= indexShowline( $inpoint, $outpoint );
$out .= "</table>\n";
+
+ # Saving cache
+ $log->replaceContent( $out );
$wgOut->addHtml( $out );
}
global $limit, $offset; # From query string
$fname = "wfSpecialLonelypages";
+ # Cache
+ $vsp = $wgLang->getValidSpecialPages();
+ $log = new LogPage( $vsp["Lonelypages"] );
+ $log->mUpdateRecentChanges = false;
+
global $wgMiserMode;
if ( $wgMiserMode ) {
- $wgOut->addWikiText( wfMsg( "perfdisabled" ) );
+ $log->showAsDisabledPage();
return;
}
$s .= "</ol>";
$wgOut->addHTML( $s );
$wgOut->addHTML( "<p>{$sl}\n" );
+
+ # Saving cache
+ if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
+ $log->replaceContent( $s );
}
?>
global $limit, $offset; # From query string
$fname = "wfSpecialLongpages";
+ # Cache
+ $vsp = $wgLang->getValidSpecialPages();
+ $log = new LogPage( $vsp["Longpages"] );
+ $log->mUpdateRecentChanges = false;
+
global $wgMiserMode;
if ( $wgMiserMode ) {
- $wgOut->addWikiText( wfMsg( "perfdisabled" ) );
+ $log->showAsDisabledPage();
return;
}
$s .= "</ol>";
$wgOut->addHTML( $s );
$wgOut->addHTML( "<p>{$sl}\n" );
+
+ # Saving cache
+ if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
+ $log->replaceContent( $s );
}
?>
global $limit, $offset; # From query string
$fname = "wfSpecialShortpages";
+ # Cache
+ $vsp = $wgLang->getValidSpecialPages();
+ $log = new LogPage( $vsp["Shortpages"] );
+ $log->mUpdateRecentChanges = false;
+
global $wgMiserMode;
if ( $wgMiserMode ) {
- $wgOut->addWikiText( wfMsg( "perfdisabled" ) );
+ $log->showAsDisabledPage();
return;
}
$s .= "</ol>";
$wgOut->addHTML( $s );
$wgOut->addHTML( "<p>{$sl}\n" );
+
+
+ # Saving cache
+ if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
+ $log->replaceContent( $s );
}
?>
<?
-global $IP;
-include_once ( "$IP/LogPage.php" ) ;
+
+include_once ( "LogPage.php" ) ;
function wfSpecialWantedpages()
{
# Cache
$vsp = $wgLang->getValidSpecialPages() ;
- $mw = $vsp["Wantedpages"] ;
- $mw = str_replace ( " " , "_" , $mw ) ; # DBKEY
- $log = new LogPage ( $mw ) ;
- $log->mUpdateRecentChanges = false ;
+ $log = new LogPage( $vsp["Wantedpages"] );
+ $log->mUpdateRecentChanges = false;
$wgOut->setRobotpolicy( "noindex,nofollow" );
global $wgMiserMode;
if ( $wgMiserMode ) {
- $s = "=== " . wfMsg( "perfdisabled" ) . " ===\n" ;
- $s .= $log->getContent() ;
- $wgOut->addWikiText ( $s ) ;
+ $log->showAsDisabledPage();
return;
}
# Saving cache
if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
- $log->mContent = $cache ;
- $log->mContentLoaded = true ;
- $log->saveContent() ;
+ $log->replaceContent( $s );
}
?>