From: Alexandre Emsenhuber Date: Sat, 30 Jul 2011 19:37:19 +0000 (+0000) Subject: * Made OutputPage extend ContextSource instead of duplicating its code; this also... X-Git-Tag: 1.31.0-rc.0~28528 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=c8e9747d3e827b5d63757fff52b1b9a98f6dea39;p=lhc%2Fweb%2Fwiklou.git * Made OutputPage extend ContextSource instead of duplicating its code; this also adds getLang() that was missing * Use getLang() instead of $wgLang --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6579b217cd..e1b4ff60ef 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -18,7 +18,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { * * @todo document */ -class OutputPage { +class OutputPage extends ContextSource { /// Should be private. Used with addMeta() which adds var $mMetatags = array(); @@ -196,8 +196,6 @@ class OutputPage { var $mFileVersion = null; - private $mContext; - /** * An array of stylesheet filenames (relative from skins path), with options * for CSS media, IE conditions, and RTL/LTR direction. @@ -226,11 +224,12 @@ class OutputPage { * a OutputPage tied to that context. */ function __construct( RequestContext $context = null ) { - if ( !isset($context) ) { + if ( $context === null ) { # Extensions should use `new RequestContext` instead of `new OutputPage` now. wfDeprecated( __METHOD__ ); + } else { + $this->setContext( $context ); } - $this->mContext = $context; } /** @@ -787,29 +786,6 @@ class OutputPage { return $this->mPagetitle; } - /** - * Get the RequestContext used in this instance - * - * @return RequestContext - */ - private function getContext() { - if ( !isset($this->mContext) ) { - wfDebug( __METHOD__ . " called and \$mContext is null. Using RequestContext::getMain(); for sanity\n" ); - $this->mContext = RequestContext::getMain(); - } - return $this->mContext; - } - - /** - * Get the WebRequest being used for this instance - * - * @return WebRequest - * @since 1.18 - */ - public function getRequest() { - return $this->getContext()->getRequest(); - } - /** * Set the Title object to use * @@ -819,34 +795,6 @@ class OutputPage { $this->getContext()->setTitle( $t ); } - /** - * Get the Title object used in this instance - * - * @return Title - */ - public function getTitle() { - return $this->getContext()->getTitle(); - } - - /** - * Get the User object used in this instance - * - * @return User - * @since 1.18 - */ - public function getUser() { - return $this->getContext()->getUser(); - } - - /** - * Get the Skin object used to render this instance - * - * @return Skin - * @since 1.18 - */ - public function getSkin() { - return $this->getContext()->getSkin(); - } /** * Replace the subtile with $str @@ -2262,15 +2210,15 @@ $templates * @return String: The doctype, opening , and head element. */ public function headElement( Skin $sk, $includeStyle = true ) { - global $wgLang, $wgContLang, $wgUseTrackbacks; - $userdir = $wgLang->getDir(); + global $wgContLang, $wgUseTrackbacks; + $userdir = $this->getLang()->getDir(); $sitedir = $wgContLang->getDir(); if ( $sk->commonPrintStylesheet() ) { $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' ); } - $ret = Html::htmlHeader( array( 'lang' => $wgLang->getCode(), 'dir' => $userdir ) ); + $ret = Html::htmlHeader( array( 'lang' => $this->getLang()->getCode(), 'dir' => $userdir ) ); if ( $this->getHTMLTitle() == '' ) { $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) ); @@ -3088,8 +3036,7 @@ $templates */ protected function styleLink( $style, $options ) { if( isset( $options['dir'] ) ) { - global $wgLang; - if( $wgLang->getDir() != $options['dir'] ) { + if( $this->getLang()->getDir() != $options['dir'] ) { return ''; } }