summaryrefslogtreecommitdiff
path: root/includes/Article.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /includes/Article.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'includes/Article.php')
-rw-r--r--includes/Article.php593
1 files changed, 314 insertions, 279 deletions
diff --git a/includes/Article.php b/includes/Article.php
index b07f309c..9ab4b6ba 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -1,6 +1,22 @@
<?php
/**
- * File for articles
+ * User interface for page actions.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @file
*/
@@ -9,7 +25,7 @@
*
* This maintains WikiPage functions for backwards compatibility.
*
- * @TODO: move and rewrite code to an Action class
+ * @todo move and rewrite code to an Action class
*
* See design.txt for an overview.
* Note: edit user interface and cache support functions have been
@@ -23,42 +39,69 @@ class Article extends Page {
*/
/**
- * @var IContextSource
+ * The context this Article is executed in
+ * @var IContextSource $mContext
*/
protected $mContext;
/**
- * @var WikiPage
+ * The WikiPage object of this instance
+ * @var WikiPage $mPage
*/
protected $mPage;
/**
- * @var ParserOptions: ParserOptions object for $wgUser articles
+ * ParserOptions object for $wgUser articles
+ * @var ParserOptions $mParserOptions
*/
public $mParserOptions;
+ /**
+ * Content of the revision we are working on
+ * @var string $mContent
+ */
var $mContent; // !<
+
+ /**
+ * Is the content ($mContent) already loaded?
+ * @var bool $mContentLoaded
+ */
var $mContentLoaded = false; // !<
+
+ /**
+ * The oldid of the article that is to be shown, 0 for the
+ * current revision
+ * @var int|null $mOldId
+ */
var $mOldId; // !<
/**
- * @var Title
+ * Title from which we were redirected here
+ * @var Title $mRedirectedFrom
*/
var $mRedirectedFrom = null;
/**
- * @var mixed: boolean false or URL string
+ * URL to redirect to or false if none
+ * @var string|false $mRedirectUrl
*/
var $mRedirectUrl = false; // !<
+
+ /**
+ * Revision ID of revision we are working on
+ * @var int $mRevIdFetched
+ */
var $mRevIdFetched = 0; // !<
/**
- * @var Revision
+ * Revision we are working on
+ * @var Revision $mRevision
*/
var $mRevision = null;
/**
- * @var ParserOutput
+ * ParserOutput object
+ * @var ParserOutput $mParserOutput
*/
var $mParserOutput;
@@ -188,11 +231,9 @@ class Article extends Page {
* This function has side effects! Do not use this function if you
* only want the real revision text if any.
*
- * @return Return the text of this revision
+ * @return string Return the text of this revision
*/
public function getContent() {
- global $wgUser;
-
wfProfileIn( __METHOD__ );
if ( $this->mPage->getID() === 0 ) {
@@ -204,7 +245,8 @@ class Article extends Page {
$text = '';
}
} else {
- $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
+ $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
+ $text = wfMessage( $message )->text();
}
wfProfileOut( __METHOD__ );
@@ -235,11 +277,10 @@ class Article extends Page {
* @return int The old id for the request
*/
public function getOldIDFromRequest() {
- global $wgRequest;
-
$this->mRedirectUrl = false;
- $oldid = $wgRequest->getIntOrNull( 'oldid' );
+ $request = $this->getContext()->getRequest();
+ $oldid = $request->getIntOrNull( 'oldid' );
if ( $oldid === null ) {
return 0;
@@ -248,17 +289,21 @@ class Article extends Page {
if ( $oldid !== 0 ) {
# Load the given revision and check whether the page is another one.
# In that case, update this instance to reflect the change.
- $this->mRevision = Revision::newFromId( $oldid );
- if ( $this->mRevision !== null ) {
- // Revision title doesn't match the page title given?
- if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
- $function = array( get_class( $this->mPage ), 'newFromID' );
- $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
+ if ( $oldid === $this->mPage->getLatest() ) {
+ $this->mRevision = $this->mPage->getRevision();
+ } else {
+ $this->mRevision = Revision::newFromId( $oldid );
+ if ( $this->mRevision !== null ) {
+ // Revision title doesn't match the page title given?
+ if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
+ $function = array( get_class( $this->mPage ), 'newFromID' );
+ $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
+ }
}
}
}
- if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
+ if ( $request->getVal( 'direction' ) == 'next' ) {
$nextid = $this->getTitle()->getNextRevisionID( $oldid );
if ( $nextid ) {
$oldid = $nextid;
@@ -266,7 +311,7 @@ class Article extends Page {
} else {
$this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
}
- } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) {
+ } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
$previd = $this->getTitle()->getPreviousRevisionID( $oldid );
if ( $previd ) {
$oldid = $previd;
@@ -306,9 +351,7 @@ class Article extends Page {
# Pre-fill content with error message so that if something
# fails we'll have something telling us what we intended.
- $t = $this->getTitle()->getPrefixedText();
- $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : '';
- $this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ;
+ $this->mContent = wfMessage( 'missing-revision', $oldid )->plain();
if ( $oldid ) {
# $this->mRevision might already be fetched by getOldIDFromRequest()
@@ -400,8 +443,7 @@ class Article extends Page {
* page of the given title.
*/
public function view() {
- global $wgUser, $wgOut, $wgRequest, $wgParser;
- global $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
+ global $wgParser, $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
wfProfileIn( __METHOD__ );
@@ -411,17 +453,19 @@ class Article extends Page {
# the first call of this method even if $oldid is used way below.
$oldid = $this->getOldID();
+ $user = $this->getContext()->getUser();
# Another whitelist check in case getOldID() is altering the title
- $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $wgUser );
+ $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
if ( count( $permErrors ) ) {
wfDebug( __METHOD__ . ": denied on secondary read check\n" );
wfProfileOut( __METHOD__ );
throw new PermissionsError( 'read', $permErrors );
}
+ $outputPage = $this->getContext()->getOutput();
# getOldID() may as well want us to redirect somewhere else
if ( $this->mRedirectUrl ) {
- $wgOut->redirect( $this->mRedirectUrl );
+ $outputPage->redirect( $this->mRedirectUrl );
wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
wfProfileOut( __METHOD__ );
@@ -429,7 +473,7 @@ class Article extends Page {
}
# If we got diff in the query, we want to see a diff page instead of the article.
- if ( $wgRequest->getCheck( 'diff' ) ) {
+ if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
wfDebug( __METHOD__ . ": showing diff page\n" );
$this->showDiffPage();
wfProfileOut( __METHOD__ );
@@ -438,31 +482,31 @@ class Article extends Page {
}
# Set page title (may be overridden by DISPLAYTITLE)
- $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() );
+ $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
- $wgOut->setArticleFlag( true );
+ $outputPage->setArticleFlag( true );
# Allow frames by default
- $wgOut->allowClickjacking();
+ $outputPage->allowClickjacking();
$parserCache = ParserCache::singleton();
$parserOptions = $this->getParserOptions();
# Render printable version, use printable version cache
- if ( $wgOut->isPrintable() ) {
+ if ( $outputPage->isPrintable() ) {
$parserOptions->setIsPrintable( true );
$parserOptions->setEditSection( false );
- } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit' ) ) {
+ } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) {
$parserOptions->setEditSection( false );
}
# Try client and file cache
if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
if ( $wgUseETag ) {
- $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
+ $outputPage->setETag( $parserCache->getETag( $this, $parserOptions ) );
}
# Is it client cached?
- if ( $wgOut->checkLastModified( $this->mPage->getTouched() ) ) {
+ if ( $outputPage->checkLastModified( $this->mPage->getTouched() ) ) {
wfDebug( __METHOD__ . ": done 304\n" );
wfProfileOut( __METHOD__ );
@@ -471,8 +515,8 @@ class Article extends Page {
} elseif ( $wgUseFileCache && $this->tryFileCache() ) {
wfDebug( __METHOD__ . ": done file cache\n" );
# tell wgOut that output is taken care of
- $wgOut->disable();
- $this->mPage->doViewUpdates( $wgUser );
+ $outputPage->disable();
+ $this->mPage->doViewUpdates( $user );
wfProfileOut( __METHOD__ );
return;
@@ -482,7 +526,7 @@ class Article extends Page {
# Should the parser cache be used?
$useParserCache = $this->mPage->isParserCacheUsed( $parserOptions, $oldid );
wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
- if ( $wgUser->getStubThreshold() ) {
+ if ( $user->getStubThreshold() ) {
wfIncrStats( 'pcache_miss_stub' );
}
@@ -520,14 +564,14 @@ class Article extends Page {
} else {
wfDebug( __METHOD__ . ": showing parser cache contents\n" );
}
- $wgOut->addParserOutput( $this->mParserOutput );
+ $outputPage->addParserOutput( $this->mParserOutput );
# Ensure that UI elements requiring revision ID have
# the correct version information.
- $wgOut->setRevisionId( $this->mPage->getLatest() );
+ $outputPage->setRevisionId( $this->mPage->getLatest() );
# Preload timestamp to avoid a DB hit
$cachedTimestamp = $this->mParserOutput->getTimestamp();
if ( $cachedTimestamp !== null ) {
- $wgOut->setRevisionTimestamp( $cachedTimestamp );
+ $outputPage->setRevisionTimestamp( $cachedTimestamp );
$this->mPage->setTimestamp( $cachedTimestamp );
}
$outputDone = true;
@@ -551,16 +595,16 @@ class Article extends Page {
# Ensure that UI elements requiring revision ID have
# the correct version information.
- $wgOut->setRevisionId( $this->getRevIdFetched() );
+ $outputPage->setRevisionId( $this->getRevIdFetched() );
# Preload timestamp to avoid a DB hit
- $wgOut->setRevisionTimestamp( $this->getTimestamp() );
+ $outputPage->setRevisionTimestamp( $this->getTimestamp() );
# Pages containing custom CSS or JavaScript get special treatment
if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) {
wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
$this->showCssOrJsPage();
$outputDone = true;
- } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
+ } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $outputPage ) ) ) {
# Allow extensions do their own custom view for certain pages
$outputDone = true;
} else {
@@ -569,10 +613,10 @@ class Article extends Page {
if ( $rt ) {
wfDebug( __METHOD__ . ": showing redirect=no page\n" );
# Viewing a redirect page (e.g. with parameter redirect=no)
- $wgOut->addHTML( $this->viewRedirect( $rt ) );
+ $outputPage->addHTML( $this->viewRedirect( $rt ) );
# Parse just to get categories, displaytitle, etc.
$this->mParserOutput = $wgParser->parse( $text, $this->getTitle(), $parserOptions );
- $wgOut->addParserOutputNoText( $this->mParserOutput );
+ $outputPage->addParserOutputNoText( $this->mParserOutput );
$outputDone = true;
}
}
@@ -587,12 +631,12 @@ class Article extends Page {
if ( !$poolArticleView->execute() ) {
$error = $poolArticleView->getError();
if ( $error ) {
- $wgOut->clearHTML(); // for release() errors
- $wgOut->enableClientCache( false );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ $outputPage->clearHTML(); // for release() errors
+ $outputPage->enableClientCache( false );
+ $outputPage->setRobotPolicy( 'noindex,nofollow' );
$errortext = $error->getWikiText( false, 'view-pool-error' );
- $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
+ $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
}
# Connection or timeout error
wfProfileOut( __METHOD__ );
@@ -600,12 +644,12 @@ class Article extends Page {
}
$this->mParserOutput = $poolArticleView->getParserOutput();
- $wgOut->addParserOutput( $this->mParserOutput );
+ $outputPage->addParserOutput( $this->mParserOutput );
# Don't cache a dirty ParserOutput object
if ( $poolArticleView->getIsDirty() ) {
- $wgOut->setSquidMaxage( 0 );
- $wgOut->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
+ $outputPage->setSquidMaxage( 0 );
+ $outputPage->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
}
$outputDone = true;
@@ -634,17 +678,17 @@ class Article extends Page {
if ( $this->getTitle()->isMainPage() ) {
$msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
if ( !$msg->isDisabled() ) {
- $wgOut->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
+ $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
}
}
# Check for any __NOINDEX__ tags on the page using $pOutput
$policy = $this->getRobotPolicy( 'view', $pOutput );
- $wgOut->setIndexPolicy( $policy['index'] );
- $wgOut->setFollowPolicy( $policy['follow'] );
+ $outputPage->setIndexPolicy( $policy['index'] );
+ $outputPage->setFollowPolicy( $policy['follow'] );
$this->showViewFooter();
- $this->mPage->doViewUpdates( $wgUser );
+ $this->mPage->doViewUpdates( $user );
wfProfileOut( __METHOD__ );
}
@@ -654,11 +698,10 @@ class Article extends Page {
* @param $pOutput ParserOutput
*/
public function adjustDisplayTitle( ParserOutput $pOutput ) {
- global $wgOut;
# Adjust the title if it was set by displaytitle, -{T|}- or language conversion
$titleText = $pOutput->getTitleText();
if ( strval( $titleText ) !== '' ) {
- $wgOut->setPageTitle( $titleText );
+ $this->getContext()->getOutput()->setPageTitle( $titleText );
}
}
@@ -667,13 +710,13 @@ class Article extends Page {
* Article::view() only, other callers should use the DifferenceEngine class.
*/
public function showDiffPage() {
- global $wgRequest, $wgUser;
-
- $diff = $wgRequest->getVal( 'diff' );
- $rcid = $wgRequest->getVal( 'rcid' );
- $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
- $purge = $wgRequest->getVal( 'action' ) == 'purge';
- $unhide = $wgRequest->getInt( 'unhide' ) == 1;
+ $request = $this->getContext()->getRequest();
+ $user = $this->getContext()->getUser();
+ $diff = $request->getVal( 'diff' );
+ $rcid = $request->getVal( 'rcid' );
+ $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
+ $purge = $request->getVal( 'action' ) == 'purge';
+ $unhide = $request->getInt( 'unhide' ) == 1;
$oldid = $this->getOldID();
$de = new DifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
@@ -683,7 +726,7 @@ class Article extends Page {
if ( $diff == 0 || $diff == $this->mPage->getLatest() ) {
# Run view updates for current revision only
- $this->mPage->doViewUpdates( $wgUser );
+ $this->mPage->doViewUpdates( $user );
}
}
@@ -695,22 +738,21 @@ class Article extends Page {
* page views.
*/
protected function showCssOrJsPage() {
- global $wgOut;
-
$dir = $this->getContext()->getLanguage()->getDir();
$lang = $this->getContext()->getLanguage()->getCode();
- $wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
+ $outputPage = $this->getContext()->getOutput();
+ $outputPage->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
'clearyourcache' );
// Give hooks a chance to customise the output
- if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
+ if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $outputPage ) ) ) {
// Wrap the whole lot in a <pre> and don't parse
$m = array();
preg_match( '!\.(css|js)$!u', $this->getTitle()->getText(), $m );
- $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
- $wgOut->addHTML( htmlspecialchars( $this->mContent ) );
- $wgOut->addHTML( "\n</pre>\n" );
+ $outputPage->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
+ $outputPage->addHTML( htmlspecialchars( $this->mContent ) );
+ $outputPage->addHTML( "\n</pre>\n" );
}
}
@@ -722,8 +764,7 @@ class Article extends Page {
* TODO: actions other than 'view'
*/
public function getRobotPolicy( $action, $pOutput ) {
- global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
- global $wgDefaultRobotPolicy, $wgRequest;
+ global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
$ns = $this->getTitle()->getNamespace();
@@ -745,13 +786,13 @@ class Article extends Page {
'index' => 'noindex',
'follow' => 'nofollow'
);
- } elseif ( $wgOut->isPrintable() ) {
+ } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
# Discourage indexing of printable versions, but encourage following
return array(
'index' => 'noindex',
'follow' => 'follow'
);
- } elseif ( $wgRequest->getInt( 'curid' ) ) {
+ } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
# For ?curid=x urls, disallow indexing
return array(
'index' => 'noindex',
@@ -794,7 +835,7 @@ class Article extends Page {
* merging of several policies using array_merge().
* @param $policy Mixed, returns empty array on null/false/'', transparent
* to already-converted arrays, converts String.
- * @return Array: 'index' => <indexpolicy>, 'follow' => <followpolicy>
+ * @return Array: 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
*/
public static function formatRobotPolicy( $policy ) {
if ( is_array( $policy ) ) {
@@ -820,15 +861,16 @@ class Article extends Page {
/**
* If this request is a redirect view, send "redirected from" subtitle to
- * $wgOut. Returns true if the header was needed, false if this is not a
- * redirect view. Handles both local and remote redirects.
+ * the output. Returns true if the header was needed, false if this is not
+ * a redirect view. Handles both local and remote redirects.
*
* @return boolean
*/
public function showRedirectedFromHeader() {
- global $wgOut, $wgRequest, $wgRedirectSources;
+ global $wgRedirectSources;
+ $outputPage = $this->getContext()->getOutput();
- $rdfrom = $wgRequest->getVal( 'rdfrom' );
+ $rdfrom = $this->getContext()->getRequest()->getVal( 'rdfrom' );
if ( isset( $this->mRedirectedFrom ) ) {
// This is an internally redirected page view.
@@ -841,21 +883,21 @@ class Article extends Page {
array( 'redirect' => 'no' )
);
- $wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
+ $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
// Set the fragment if one was specified in the redirect
if ( strval( $this->getTitle()->getFragment() ) != '' ) {
$fragment = Xml::escapeJsString( $this->getTitle()->getFragmentForURL() );
- $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" );
+ $outputPage->addInlineScript( "redirectToFragment(\"$fragment\");" );
}
// Add a <link rel="canonical"> tag
- $wgOut->addLink( array( 'rel' => 'canonical',
+ $outputPage->addLink( array( 'rel' => 'canonical',
'href' => $this->getTitle()->getLocalURL() )
);
- // Tell $wgOut the user arrived at this article through a redirect
- $wgOut->setRedirectedFrom( $this->mRedirectedFrom );
+ // Tell the output object that the user arrived at this article through a redirect
+ $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
return true;
}
@@ -864,7 +906,7 @@ class Article extends Page {
// If it was reported from a trusted site, supply a backlink.
if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
$redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
- $wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
+ $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
return true;
}
@@ -878,11 +920,9 @@ class Article extends Page {
* [[MediaWiki:Talkpagetext]]. For Article::view().
*/
public function showNamespaceHeader() {
- global $wgOut;
-
if ( $this->getTitle()->isTalkPage() ) {
if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
- $wgOut->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1\n</div>", array( 'talkpageheader' ) );
+ $this->getContext()->getOutput()->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1\n</div>", array( 'talkpageheader' ) );
}
}
}
@@ -891,11 +931,9 @@ class Article extends Page {
* Show the footer section of an ordinary page view
*/
public function showViewFooter() {
- global $wgOut;
-
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
if ( $this->getTitle()->getNamespace() == NS_USER_TALK && IP::isValid( $this->getTitle()->getText() ) ) {
- $wgOut->addWikiMsg( 'anontalkpagetext' );
+ $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
}
# If we have been passed an &rcid= parameter, we want to give the user a
@@ -912,33 +950,32 @@ class Article extends Page {
* desired, does nothing.
*/
public function showPatrolFooter() {
- global $wgOut, $wgRequest, $wgUser;
-
- $rcid = $wgRequest->getVal( 'rcid' );
+ $request = $this->getContext()->getRequest();
+ $outputPage = $this->getContext()->getOutput();
+ $user = $this->getContext()->getUser();
+ $rcid = $request->getVal( 'rcid' );
- if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol' ) ) {
+ if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol', $user ) ) {
return;
}
- $token = $wgUser->getEditToken( $rcid );
- $wgOut->preventClickjacking();
+ $token = $user->getEditToken( $rcid );
+ $outputPage->preventClickjacking();
- $wgOut->addHTML(
+ $link = Linker::linkKnown(
+ $this->getTitle(),
+ wfMessage( 'markaspatrolledtext' )->escaped(),
+ array(),
+ array(
+ 'action' => 'markpatrolled',
+ 'rcid' => $rcid,
+ 'token' => $token,
+ )
+ );
+
+ $outputPage->addHTML(
"<div class='patrollink'>" .
- wfMsgHtml(
- 'markaspatrolledlink',
- Linker::link(
- $this->getTitle(),
- wfMsgHtml( 'markaspatrolledtext' ),
- array(),
- array(
- 'action' => 'markpatrolled',
- 'rcid' => $rcid,
- 'token' => $token,
- ),
- array( 'known', 'noclasses' )
- )
- ) .
+ wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
'</div>'
);
}
@@ -948,7 +985,8 @@ class Article extends Page {
* namespace, show the default message text. To be called from Article::view().
*/
public function showMissingArticle() {
- global $wgOut, $wgRequest, $wgUser, $wgSend404Code;
+ global $wgSend404Code;
+ $outputPage = $this->getContext()->getOutput();
# Show info in user (talk) namespace. Does the user exist? Is he blocked?
if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) {
@@ -958,13 +996,13 @@ class Article extends Page {
$ip = User::isIP( $rootPart );
if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist
- $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
+ $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
} elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
LogEventsList::showLogExtract(
- $wgOut,
+ $outputPage,
'block',
- $user->getUserPage()->getPrefixedText(),
+ $user->getUserPage(),
'',
array(
'lim' => 1,
@@ -981,7 +1019,7 @@ class Article extends Page {
wfRunHooks( 'ShowMissingArticle', array( $this ) );
# Show delete and move logs
- LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->getTitle()->getPrefixedText(), '',
+ LogEventsList::showLogExtract( $outputPage, array( 'delete', 'move' ), $this->getTitle(), '',
array( 'lim' => 10,
'conds' => array( "log_action != 'revision'" ),
'showIfEmpty' => false,
@@ -991,7 +1029,7 @@ class Article extends Page {
if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
// If there's no backing content, send a 404 Not Found
// for better machine handling of broken links.
- $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
+ $this->getContext()->getRequest()->response()->header( "HTTP/1.1 404 Not Found" );
}
$hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
@@ -1003,56 +1041,50 @@ class Article extends Page {
# Show error message
$oldid = $this->getOldID();
if ( $oldid ) {
- $text = wfMsgNoTrans( 'missing-article',
- $this->getTitle()->getPrefixedText(),
- wfMsgNoTrans( 'missingarticle-rev', $oldid ) );
+ $text = wfMessage( 'missing-revision', $oldid )->plain();
} elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) {
// Use the default message text
$text = $this->getTitle()->getDefaultMessageText();
+ } elseif ( $this->getTitle()->quickUserCan( 'create', $this->getContext()->getUser() )
+ && $this->getTitle()->quickUserCan( 'edit', $this->getContext()->getUser() )
+ ) {
+ $text = wfMessage( 'noarticletext' )->plain();
} else {
- $createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $wgUser );
- $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $wgUser );
- $errors = array_merge( $createErrors, $editErrors );
-
- if ( !count( $errors ) ) {
- $text = wfMsgNoTrans( 'noarticletext' );
- } else {
- $text = wfMsgNoTrans( 'noarticletext-nopermission' );
- }
+ $text = wfMessage( 'noarticletext-nopermission' )->plain();
}
$text = "<div class='noarticletext'>\n$text\n</div>";
- $wgOut->addWikiText( $text );
+ $outputPage->addWikiText( $text );
}
/**
* If the revision requested for view is deleted, check permissions.
- * Send either an error message or a warning header to $wgOut.
+ * Send either an error message or a warning header to the output.
*
* @return boolean true if the view is allowed, false if not.
*/
public function showDeletedRevisionHeader() {
- global $wgOut, $wgRequest;
-
if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
// Not deleted
return true;
}
+ $outputPage = $this->getContext()->getOutput();
+ $user = $this->getContext()->getUser();
// If the user is not allowed to see it...
- if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
- $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
+ if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $user ) ) {
+ $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
'rev-deleted-text-permission' );
return false;
// If the user needs to confirm that they want to see it...
- } elseif ( $wgRequest->getInt( 'unhide' ) != 1 ) {
+ } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
# Give explanation and add a link to view the revision...
$oldid = intval( $this->getOldID() );
$link = $this->getTitle()->getFullUrl( "oldid={$oldid}&unhide=1" );
$msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
- $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
+ $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
array( $msg, $link ) );
return false;
@@ -1060,7 +1092,7 @@ class Article extends Page {
} else {
$msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
'rev-suppressed-text-view' : 'rev-deleted-text-view';
- $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
+ $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
return true;
}
@@ -1072,30 +1104,36 @@ class Article extends Page {
* Revision as of \<date\>; view current revision
* \<- Previous version | Next Version -\>
*
- * @param $oldid String: revision ID of this article revision
+ * @param $oldid int: revision ID of this article revision
*/
public function setOldSubtitle( $oldid = 0 ) {
- global $wgLang, $wgOut, $wgUser, $wgRequest;
-
if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
return;
}
- $unhide = $wgRequest->getInt( 'unhide' ) == 1;
+ $unhide = $this->getContext()->getRequest()->getInt( 'unhide' ) == 1;
# Cascade unhide param in links for easy deletion browsing
$extraParams = array();
- if ( $wgRequest->getVal( 'unhide' ) ) {
+ if ( $unhide ) {
$extraParams['unhide'] = 1;
}
- $revision = Revision::newFromId( $oldid );
+ if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
+ $revision = $this->mRevision;
+ } else {
+ $revision = Revision::newFromId( $oldid );
+ }
+
$timestamp = $revision->getTimestamp();
$current = ( $oldid == $this->mPage->getLatest() );
- $td = $wgLang->timeanddate( $timestamp, true );
- $tddate = $wgLang->date( $timestamp, true );
- $tdtime = $wgLang->time( $timestamp, true );
+ $language = $this->getContext()->getLanguage();
+ $user = $this->getContext()->getUser();
+
+ $td = $language->userTimeAndDate( $timestamp, $user );
+ $tddate = $language->userDate( $timestamp, $user );
+ $tdtime = $language->userTime( $timestamp, $user );
# Show user links if allowed to see them. If hidden, then show them only if requested...
$userlinks = Linker::revUserTools( $revision, !$unhide );
@@ -1104,89 +1142,85 @@ class Article extends Page {
? 'revision-info-current'
: 'revision-info';
- $wgOut->addSubtitle( "<div id=\"mw-{$infomsg}\">" . wfMessage( $infomsg,
+ $outputPage = $this->getContext()->getOutput();
+ $outputPage->addSubtitle( "<div id=\"mw-{$infomsg}\">" . wfMessage( $infomsg,
$td )->rawParams( $userlinks )->params( $revision->getID(), $tddate,
$tdtime, $revision->getUser() )->parse() . "</div>" );
$lnk = $current
- ? wfMsgHtml( 'currentrevisionlink' )
- : Linker::link(
+ ? wfMessage( 'currentrevisionlink' )->escaped()
+ : Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'currentrevisionlink' ),
+ wfMessage( 'currentrevisionlink' )->escaped(),
array(),
- $extraParams,
- array( 'known', 'noclasses' )
+ $extraParams
);
$curdiff = $current
- ? wfMsgHtml( 'diff' )
- : Linker::link(
+ ? wfMessage( 'diff' )->escaped()
+ : Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'diff' ),
+ wfMessage( 'diff' )->escaped(),
array(),
array(
'diff' => 'cur',
'oldid' => $oldid
- ) + $extraParams,
- array( 'known', 'noclasses' )
+ ) + $extraParams
);
$prev = $this->getTitle()->getPreviousRevisionID( $oldid ) ;
$prevlink = $prev
- ? Linker::link(
+ ? Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'previousrevision' ),
+ wfMessage( 'previousrevision' )->escaped(),
array(),
array(
'direction' => 'prev',
'oldid' => $oldid
- ) + $extraParams,
- array( 'known', 'noclasses' )
+ ) + $extraParams
)
- : wfMsgHtml( 'previousrevision' );
+ : wfMessage( 'previousrevision' )->escaped();
$prevdiff = $prev
- ? Linker::link(
+ ? Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'diff' ),
+ wfMessage( 'diff' )->escaped(),
array(),
array(
'diff' => 'prev',
'oldid' => $oldid
- ) + $extraParams,
- array( 'known', 'noclasses' )
+ ) + $extraParams
)
- : wfMsgHtml( 'diff' );
+ : wfMessage( 'diff' )->escaped();
$nextlink = $current
- ? wfMsgHtml( 'nextrevision' )
- : Linker::link(
+ ? wfMessage( 'nextrevision' )->escaped()
+ : Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'nextrevision' ),
+ wfMessage( 'nextrevision' )->escaped(),
array(),
array(
'direction' => 'next',
'oldid' => $oldid
- ) + $extraParams,
- array( 'known', 'noclasses' )
+ ) + $extraParams
);
$nextdiff = $current
- ? wfMsgHtml( 'diff' )
- : Linker::link(
+ ? wfMessage( 'diff' )->escaped()
+ : Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'diff' ),
+ wfMessage( 'diff' )->escaped(),
array(),
array(
'diff' => 'next',
'oldid' => $oldid
- ) + $extraParams,
- array( 'known', 'noclasses' )
+ ) + $extraParams
);
- $cdel = Linker::getRevDeleteLink( $wgUser, $revision, $this->getTitle() );
+ $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
if ( $cdel !== '' ) {
$cdel .= ' ';
}
- $wgOut->addSubtitle( "<div id=\"mw-revision-nav\">" . $cdel .
- wfMsgExt( 'revision-nav', array( 'escapenoentities', 'parsemag', 'replaceafter' ),
- $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>" );
+ $outputPage->addSubtitle( "<div id=\"mw-revision-nav\">" . $cdel .
+ wfMessage( 'revision-nav' )->rawParams(
+ $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
+ )->escaped() . "</div>" );
}
/**
@@ -1198,7 +1232,7 @@ class Article extends Page {
* @return string containing HMTL with redirect link
*/
public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
- global $wgOut, $wgStylePath;
+ global $wgStylePath;
if ( !is_array( $target ) ) {
$target = array( $target );
@@ -1208,7 +1242,8 @@ class Article extends Page {
$imageDir = $lang->getDir();
if ( $appendSubtitle ) {
- $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
+ $out = $this->getContext()->getOutput();
+ $out->addSubtitle( wfMessage( 'redirectpagesub' )->escaped() );
}
// the loop prepends the arrow image before the link, so the first case needs to be outside
@@ -1246,9 +1281,7 @@ class Article extends Page {
* Handle action=render
*/
public function render() {
- global $wgOut;
-
- $wgOut->setArticleBodyOnly( true );
+ $this->getContext()->getOutput()->setArticleBodyOnly( true );
$this->view();
}
@@ -1271,8 +1304,6 @@ class Article extends Page {
* UI entry point for page deletion
*/
public function delete() {
- global $wgOut, $wgRequest, $wgLang;
-
# This code desperately needs to be totally rewritten
$title = $this->getTitle();
@@ -1290,48 +1321,54 @@ class Article extends Page {
}
# Better double-check that it hasn't been deleted yet!
- $dbw = wfGetDB( DB_MASTER );
- $conds = $title->pageCond();
- $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
- if ( $latest === false ) {
- $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
- $wgOut->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
+ $this->mPage->loadPageData( 'fromdbmaster' );
+ if ( !$this->mPage->exists() ) {
+ $deleteLogPage = new LogPage( 'delete' );
+ $outputPage = $this->getContext()->getOutput();
+ $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
+ $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) )
);
- $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
+ $outputPage->addHTML(
+ Xml::element( 'h2', null, $deleteLogPage->getName()->text() )
+ );
LogEventsList::showLogExtract(
- $wgOut,
+ $outputPage,
'delete',
- $title->getPrefixedText()
+ $title
);
return;
}
- $deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
- $deleteReason = $wgRequest->getText( 'wpReason' );
+ $request = $this->getContext()->getRequest();
+ $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
+ $deleteReason = $request->getText( 'wpReason' );
if ( $deleteReasonList == 'other' ) {
$reason = $deleteReason;
} elseif ( $deleteReason != '' ) {
// Entry from drop down menu + additional comment
- $reason = $deleteReasonList . wfMsgForContent( 'colon-separator' ) . $deleteReason;
+ $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
+ $reason = $deleteReasonList . $colonseparator . $deleteReason;
} else {
$reason = $deleteReasonList;
}
- if ( $wgRequest->wasPosted() && $user->matchEditToken( $wgRequest->getVal( 'wpEditToken' ),
+ if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
array( 'delete', $this->getTitle()->getPrefixedText() ) ) )
{
# Flag to hide all contents of the archived revisions
- $suppress = $wgRequest->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
+ $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
$this->doDelete( $reason, $suppress );
- if ( $wgRequest->getCheck( 'wpWatch' ) && $user->isLoggedIn() ) {
- $this->doWatch();
- } elseif ( $title->userIsWatching() ) {
- $this->doUnwatch();
+ if ( $user->isLoggedIn() && $request->getCheck( 'wpWatch' ) != $user->isWatched( $title ) ) {
+ if ( $request->getCheck( 'wpWatch' ) ) {
+ WatchAction::doWatch( $title, $user );
+ } else {
+ WatchAction::doUnwatch( $title, $user );
+ }
}
return;
@@ -1347,10 +1384,10 @@ class Article extends Page {
if ( $hasHistory ) {
$revisions = $this->mTitle->estimateRevisionCount();
// @todo FIXME: i18n issue/patchwork message
- $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
- wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
- wfMsgHtml( 'word-separator' ) . Linker::link( $title,
- wfMsgHtml( 'history' ),
+ $this->getContext()->getOutput()->addHTML( '<strong class="mw-delete-warning-revisions">' .
+ wfMessage( 'historywarning' )->numParams( $revisions )->parse() .
+ wfMessage( 'word-separator' )->plain() . Linker::linkKnown( $title,
+ wfMessage( 'history' )->escaped(),
array( 'rel' => 'archives' ),
array( 'action' => 'history' ) ) .
'</strong>'
@@ -1358,12 +1395,12 @@ class Article extends Page {
if ( $this->mTitle->isBigDeletion() ) {
global $wgDeleteRevisionsLimit;
- $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
- array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
+ $this->getContext()->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
+ array( 'delete-warning-toobig', $this->getContext()->getLanguage()->formatNum( $wgDeleteRevisionsLimit ) ) );
}
}
- return $this->confirmDelete( $reason );
+ $this->confirmDelete( $reason );
}
/**
@@ -1372,16 +1409,15 @@ class Article extends Page {
* @param $reason String: prefilled reason
*/
public function confirmDelete( $reason ) {
- global $wgOut;
-
wfDebug( "Article::confirmDelete\n" );
- $wgOut->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
- $wgOut->addBacklinkSubtitle( $this->getTitle() );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
- $wgOut->addWikiMsg( 'confirmdeletetext' );
+ $outputPage = $this->getContext()->getOutput();
+ $outputPage->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
+ $outputPage->addBacklinkSubtitle( $this->getTitle() );
+ $outputPage->setRobotPolicy( 'noindex,nofollow' );
+ $outputPage->addWikiMsg( 'confirmdeletetext' );
- wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
+ wfRunHooks( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) );
$user = $this->getContext()->getUser();
@@ -1389,33 +1425,33 @@ class Article extends Page {
$suppress = "<tr id=\"wpDeleteSuppressRow\">
<td></td>
<td class='mw-input'><strong>" .
- Xml::checkLabel( wfMsg( 'revdelete-suppress' ),
+ Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) .
"</strong></td>
</tr>";
} else {
$suppress = '';
}
- $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $this->getTitle()->userIsWatching();
+ $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $this->getTitle() );
$form = Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
Xml::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) .
- Xml::tags( 'legend', null, wfMsgExt( 'delete-legend', array( 'parsemag', 'escapenoentities' ) ) ) .
+ Xml::tags( 'legend', null, wfMessage( 'delete-legend' )->escaped() ) .
Xml::openElement( 'table', array( 'id' => 'mw-deleteconfirm-table' ) ) .
"<tr id=\"wpDeleteReasonListRow\">
<td class='mw-label'>" .
- Xml::label( wfMsg( 'deletecomment' ), 'wpDeleteReasonList' ) .
+ Xml::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
"</td>
<td class='mw-input'>" .
Xml::listDropDown( 'wpDeleteReasonList',
- wfMsgForContent( 'deletereason-dropdown' ),
- wfMsgForContent( 'deletereasonotherlist' ), '', 'wpReasonDropDown', 1 ) .
+ wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
+ wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(), '', 'wpReasonDropDown', 1 ) .
"</td>
</tr>
<tr id=\"wpDeleteReasonRow\">
<td class='mw-label'>" .
- Xml::label( wfMsg( 'deleteotherreason' ), 'wpReason' ) .
+ Xml::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
"</td>
<td class='mw-input'>" .
Html::input( 'wpReason', $reason, 'text', array(
@@ -1434,7 +1470,7 @@ class Article extends Page {
<tr>
<td></td>
<td class='mw-input'>" .
- Xml::checkLabel( wfMsg( 'watchthis' ),
+ Xml::checkLabel( wfMessage( 'watchthis' )->text(),
'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
"</td>
</tr>";
@@ -1445,7 +1481,7 @@ class Article extends Page {
<tr>
<td></td>
<td class='mw-submit'>" .
- Xml::submitButton( wfMsg( 'deletepage' ),
+ Xml::submitButton( wfMessage( 'deletepage' )->text(),
array( 'name' => 'wpConfirmB', 'id' => 'wpConfirmB', 'tabindex' => '5' ) ) .
"</td>
</tr>" .
@@ -1458,17 +1494,19 @@ class Article extends Page {
$title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
$link = Linker::link(
$title,
- wfMsgHtml( 'delete-edit-reasonlist' ),
+ wfMessage( 'delete-edit-reasonlist' )->escaped(),
array(),
array( 'action' => 'edit' )
);
$form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
}
- $wgOut->addHTML( $form );
- $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
- LogEventsList::showLogExtract( $wgOut, 'delete',
- $this->getTitle()->getPrefixedText()
+ $outputPage->addHTML( $form );
+
+ $deleteLogPage = new LogPage( 'delete' );
+ $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
+ LogEventsList::showLogExtract( $outputPage, 'delete',
+ $this->getTitle()
);
}
@@ -1478,34 +1516,35 @@ class Article extends Page {
* @param $suppress bool
*/
public function doDelete( $reason, $suppress = false ) {
- global $wgOut;
-
$error = '';
- if ( $this->mPage->doDeleteArticle( $reason, $suppress, 0, true, $error ) ) {
+ $outputPage = $this->getContext()->getOutput();
+ $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error );
+ if ( $status->isGood() ) {
$deleted = $this->getTitle()->getPrefixedText();
- $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
+ $outputPage->setRobotPolicy( 'noindex,nofollow' );
- $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
+ $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
- $wgOut->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
- $wgOut->returnToMain( false );
+ $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
+ $outputPage->returnToMain( false );
} else {
- $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
+ $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
if ( $error == '' ) {
- $wgOut->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
- array( 'cannotdelete', wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
+ $outputPage->addWikiText(
+ "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
);
- $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
+ $deleteLogPage = new LogPage( 'delete' );
+ $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
LogEventsList::showLogExtract(
- $wgOut,
+ $outputPage,
'delete',
- $this->getTitle()->getPrefixedText()
+ $this->getTitle()
);
} else {
- $wgOut->addHTML( $error );
+ $outputPage->addHTML( $error );
}
}
}
@@ -1578,22 +1617,22 @@ class Article extends Page {
* @return ParserOutput or false if the given revsion ID is not found
*/
public function getParserOutput( $oldid = null, User $user = null ) {
- global $wgUser;
-
- $user = is_null( $user ) ? $wgUser : $user;
- $parserOptions = $this->mPage->makeParserOptions( $user );
+ if ( $user === null ) {
+ $parserOptions = $this->getParserOptions();
+ } else {
+ $parserOptions = $this->mPage->makeParserOptions( $user );
+ }
return $this->mPage->getParserOutput( $parserOptions, $oldid );
}
/**
* Get parser options suitable for rendering the primary article wikitext
- * @return ParserOptions|false
+ * @return ParserOptions
*/
public function getParserOptions() {
- global $wgUser;
if ( !$this->mParserOptions ) {
- $this->mParserOptions = $this->mPage->makeParserOptions( $wgUser );
+ $this->mParserOptions = $this->mPage->makeParserOptions( $this->getContext() );
}
// Clone to allow modifications of the return value without affecting cache
return clone $this->mParserOptions;
@@ -1645,6 +1684,7 @@ class Article extends Page {
/**
* Handle action=purge
* @deprecated since 1.19
+ * @return Action|bool|null false if the action is disabled, null if it is not recognised
*/
public function purge() {
return Action::factory( 'purge', $this )->show();
@@ -1679,7 +1719,7 @@ class Article extends Page {
}
/**
- * Add this page to $wgUser's watchlist
+ * Add this page to the current user's watchlist
*
* This is safe to be called multiple times
*
@@ -1687,9 +1727,8 @@ class Article extends Page {
* @deprecated since 1.18
*/
public function doWatch() {
- global $wgUser;
wfDeprecated( __METHOD__, '1.18' );
- return WatchAction::doWatch( $this->getTitle(), $wgUser );
+ return WatchAction::doWatch( $this->getTitle(), $this->getContext()->getUser() );
}
/**
@@ -1708,24 +1747,21 @@ class Article extends Page {
* @deprecated since 1.18
*/
public function doUnwatch() {
- global $wgUser;
wfDeprecated( __METHOD__, '1.18' );
- return WatchAction::doUnwatch( $this->getTitle(), $wgUser );
+ return WatchAction::doUnwatch( $this->getTitle(), $this->getContext()->getUser() );
}
/**
* Output a redirect back to the article.
* This is typically used after an edit.
*
- * @deprecated in 1.18; call $wgOut->redirect() directly
+ * @deprecated in 1.18; call OutputPage::redirect() directly
* @param $noRedir Boolean: add redirect=no
* @param $sectionAnchor String: section to redirect to, including "#"
* @param $extraQuery String: extra query params
*/
public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
wfDeprecated( __METHOD__, '1.18' );
- global $wgOut;
-
if ( $noRedir ) {
$query = 'redirect=no';
if ( $extraQuery )
@@ -1734,7 +1770,7 @@ class Article extends Page {
$query = $extraQuery;
}
- $wgOut->redirect( $this->getTitle()->getFullURL( $query ) . $sectionAnchor );
+ $this->getContext()->getOutput()->redirect( $this->getTitle()->getFullURL( $query ) . $sectionAnchor );
}
/**
@@ -1776,6 +1812,7 @@ class Article extends Page {
*
* @param $fname String Name of called method
* @param $args Array Arguments to the method
+ * @return mixed
*/
public function __call( $fname, $args ) {
if ( is_callable( array( $this->mPage, $fname ) ) ) {
@@ -1832,8 +1869,7 @@ class Article extends Page {
* @return array
*/
public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
- global $wgUser;
- $user = is_null( $user ) ? $wgUser : $user;
+ $user = is_null( $user ) ? $this->getContext()->getUser() : $user;
return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
}
@@ -1846,8 +1882,7 @@ class Article extends Page {
* @return array
*/
public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
- global $wgUser;
- $guser = is_null( $guser ) ? $wgUser : $guser;
+ $guser = is_null( $guser ) ? $this->getContext()->getUser() : $guser;
return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
}