From: Bryan Tong Minh Date: Thu, 10 Feb 2011 16:14:56 +0000 (+0000) Subject: Add a context to SpecialPage, so that subclasses don't need globals anymore. Introduc... X-Git-Tag: 1.31.0-rc.0~32070 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=5f6862c89e5832c117613cf6232f08ab57436fdb;p=lhc%2Fweb%2Fwiklou.git Add a context to SpecialPage, so that subclasses don't need globals anymore. Introduces $mRequest, $mOutput and $mFullTitle, which can be used instead of $wgRequest, $wgOut and $wgTitle. Introduces msg(), which is a wrapper around wfMessage()->title(). --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 348100aad4..d220990ee5 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -73,6 +73,22 @@ class SpecialPage { * Query parameteres added by redirects */ var $mAddedRedirectParams = array(); + /** + * Current request + * @var WebRequest + */ + protected $mRequest; + /** + * Current output page + * @var OutputPage + */ + protected $mOutput; + /** + * Full title including $par + * @var Title + */ + protected $mFullTitle; + /** * List of special pages, followed by parameters. * If the only parameter is a string, that is the page name. @@ -539,6 +555,9 @@ class SpecialPage { wfProfileOut( __METHOD__ ); return false; } + + # Page exists, set the context + $page->setContext( $wgRequest, $wgOut ); # Check for redirect if ( !$including ) { @@ -951,6 +970,27 @@ class SpecialPage { ? $params : false; } + + /** + * Sets the context this SpecialPage is executed in + * + * @param $request WebRequest + * @param $output OutputPage + */ + protected function setContext( $request, $output ) { + $this->mRequest = $request; + $this->mOutput = $output; + $this->mFullTitle = $output->getTitle(); + } + /** + * Wrapper around wfMessage that sets the current context. Currently this + * is only the title. + * + * @see wfMessage + */ + public function msg( /* $args */ ) { + return call_user_func_array( 'wfMessage', func_get_args() )->title( $this->mFullTitle ); + } } /**