* Note: edit user interface and cache support functions have been
* moved to separate EditPage and HTMLFileCache classes.
*
+ * @internal documentation reviewed 15 Mar 2010
*/
class Article {
/**@{{
var $mRedirectTarget = null; // !< Title object if set
var $mRedirectUrl = false; // !<
var $mRevIdFetched = 0; // !<
- var $mRevision; // !<
+ var $mRevision; // !< Revision object if set
var $mTimestamp = ''; // !<
- var $mTitle; // !<
+ var $mTitle; // !< Title object
var $mTotalAdjustment = 0; // !<
var $mTouched = '19700101000000'; // !<
var $mUser = -1; // !< Not loaded
- var $mUserText = ''; // !<
- var $mParserOptions; // !<
- var $mParserOutput; // !<
+ var $mUserText = ''; // !< username from Revision if set
+ var $mParserOptions; // !< ParserOptions object
+ var $mParserOutput; // !< ParserCache object if set
/**@}}*/
/**
}
}
- $sk = $wgUser->getSkin();
-
# getOldID may want us to redirect somewhere else
if ( $this->mRedirectUrl ) {
$wgOut->redirect( $this->mRedirectUrl );
wfIncrStats( 'pcache_miss_stub' );
}
- # For the main page, overwrite the <title> element with the con-
- # tents of 'pagetitle-view-mainpage' instead of the default (if
- # that's not empty).
- if ( $this->mTitle->equals( Title::newMainPage() )
- && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' )
- {
- $wgOut->setHTMLTitle( $m );
- }
-
$wasRedirected = $this->showRedirectedFromHeader();
$this->showNamespaceHeader();
# Keep going until $outputDone is set, or we run out of things to do.
$pass = 0;
$outputDone = false;
+ $this->mParserOutput = false;
while ( !$outputDone && ++$pass ) {
switch( $pass ) {
case 1:
}
}
+ # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
+ if ( $this->mParserOutput ) {
+ $titleText = $this->mParserOutput->getTitleText();
+ if ( strval( $titleText ) !== '' ) {
+ $wgOut->setPageTitle( $titleText );
+ }
+ }
+
+ # For the main page, overwrite the <title> element with the con-
+ # tents of 'pagetitle-view-mainpage' instead of the default (if
+ # that's not empty).
+ if ( $this->mTitle->equals( Title::newMainPage() )
+ && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' )
+ {
+ $wgOut->setHTMLTitle( $m );
+ }
+
# Now that we've filled $this->mParserOutput, we know whether
# there are any __NOINDEX__ tags on the page
$policy = $this->getRobotPolicy( 'view' );
* array
*/
public function getRobotPolicyForView() {
- wfDeprecated( __FUNC__ );
+ wfDeprecated( __METHOD__ );
$policy = $this->getRobotPolicy( 'view' );
return $policy['index'] . ',' . $policy['follow'];
}
$rmvtxt );
}
$wgOut->wrapWikiMsg( "<div id='mw_trackbacks'>$1</div>\n", array( 'trackbackbox', $tbtext ) );
- $this->mTitle->invalidateCache();
}
/**
/**
* @param $section empty/null/false or a section number (0, 1, 2, T1, T2...)
+ * @param $text String: new text of the section
+ * @param $summary String: new section's subject, only if $section is 'new'
+ * @param $edittime String: revision timestamp or null to use the current revision
* @return string Complete article text, or null if error
*/
public function replaceSection( $section, $text, $summary = '', $edittime = null ) {
/**
* Auto-generates a deletion reason
+ *
* @param &$hasHistory Boolean: whether the page has a history
+ * @return mixed String containing deletion reason or empty string, or boolean false
+ * if no revision occurred
*/
public function generateReason( &$hasHistory ) {
global $wgContLang;
$hasHistory = ( $res->numRows() > 1 );
$row = $dbw->fetchObject( $res );
- $onlyAuthor = $row->rev_user_text;
- // Try to find a second contributor
- foreach ( $res as $row ) {
- if ( $row->rev_user_text != $onlyAuthor ) {
- $onlyAuthor = false;
- break;
+ if ( $row ) { // $row is false if the only contributor is hidden
+ $onlyAuthor = $row->rev_user_text;
+ // Try to find a second contributor
+ foreach ( $res as $row ) {
+ if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999
+ $onlyAuthor = false;
+ break;
+ }
}
+ } else {
+ $onlyAuthor = false;
}
$dbw->freeResult( $res );
/**
* Back-end article deletion
* Deletes the article with database consistency, writes logs, purges caches
- * Returns success
+ *
+ * @param $reason string delete reason for deletion log
+ * @param suppress bitfield
+ * Revision::DELETED_TEXT
+ * Revision::DELETED_COMMENT
+ * Revision::DELETED_USER
+ * Revision::DELETED_RESTRICTED
+ * @param $id int article ID
+ * @param $commit boolean defaults to true, triggers transaction end
+ * @return boolean true if successful
*/
public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true ) {
global $wgUseSquid, $wgDeferredUpdateList;
* This function is called right before saving the wikitext,
* so we can do things like signatures and links-in-context.
*
- * @param $text String
+ * @param $text String article contents
+ * @return string article contents with altered wikitext markup (signatures
+ * converted, {{subst:}}, templates, etc.)
*/
public function preSaveTransform( $text ) {
global $wgParser, $wgUser;
* checkLastModified returns true if it has taken care of all
* output to the client that is necessary for this request.
* (that is, it has sent a cached version of the page)
+ *
+ * @return boolean true if cached version send, false otherwise
*/
protected function tryFileCache() {
static $called = false;
/**
* Loads page_touched and returns a value indicating if it should be used
- *
+ * @return boolean true if not a redirect
*/
public function checkTouched() {
if ( !$this->mDataLoaded ) {
/**
* Get the page_touched field
+ * @return string containing GMT timestamp
*/
public function getTouched() {
# Ensure that page data has been loaded
/**
* Get the page_latest field
+ * @return integer rev_id of current revision
*/
public function getLatest() {
if ( !$this->mDataLoaded ) {
$title->purgeSquid();
$title->deleteTitleProtection();
}
-
+
+ /**
+ * Clears caches when article is deleted
+ */
public static function onArticleDelete( $title ) {
global $wgMessageCache;
# Update existence markers on article/talk tabs...
/**
* Purge caches on page update etc
+ *
+ * @param $title Title object
+ * @todo: verify that $title is always a Title object (and never false or null), add Title hint to parameter $title
*/
- public static function onArticleEdit( $title, $flags = '' ) {
+ public static function onArticleEdit( $title ) {
global $wgDeferredUpdateList;
// Invalidate caches of articles which include this page
* on a given page. If page does not exist, returns false.
*
* @param $title Title object
- * @return array
+ * @return mixed array or boolean false
*/
public function pageCountInfo( $title ) {
$id = $title->getArticleId();
*
* @param $text String
* @param $cache Boolean
+ * @param $parserOptions mixed ParserOptions object, or boolean false
*/
public function outputWikiText( $text, $cache = true, $parserOptions = false ) {
global $wgOut;
* This does all the heavy lifting for outputWikitext, except it returns the parser
* output instead of sending it straight to $wgOut. Makes things nice and simple for,
* say, embedding thread pages within a discussion system (LiquidThreads)
+ *
+ * @param $text string
+ * @param $cache boolean
+ * @param $parserOptions parsing options, defaults to false
+ * @return string containing parsed output
*/
public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) {
global $wgParser, $wgOut, $wgEnableParserCache, $wgUseFileCache;
/**
* Get parser options suitable for rendering the primary article wikitext
+ * @return mixed ParserOptions object or boolean false
*/
public function getParserOptions() {
global $wgUser;
}
return $this->mParserOptions;
}
+
+ /**
+ * Updates cascading protections
+ *
+ * @param $parserOutput mixed ParserOptions object, or boolean false
+ **/
protected function doCascadeProtectionUpdates( $parserOutput ) {
if ( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
*
* @param $added array The names of categories that were added
* @param $deleted array The names of categories that were deleted
- * @return null
*/
public function updateCategoryCounts( $added, $deleted ) {
$ns = $this->mTitle->getNamespace();
}
}
- /** Lightweight method to get the parser output for a page, checking the parser cache
+ /**
+ * Lightweight method to get the parser output for a page, checking the parser cache
* and so on. Doesn't consider most of the stuff that Article::view is forced to
* consider, so it's not appropriate to use there.
+ *
+ * @param $oldid mixed integer Revision ID or null
*/
- function getParserOutput( $oldid = null ) {
+ public function getParserOutput( $oldid = null ) {
global $wgEnableParserCache, $wgUser, $wgOut;
// Should the parser cache be used?