http://www.mediawiki.org/wiki/Special:Code/MediaWiki/93557
Revision: 93557 Author: ialex Date: 2011-07-30 19:37:19 +0000 (Sat, 30 Jul 2011) Log Message: ----------- * Made OutputPage extend ContextSource instead of duplicating its code; this also adds getLang() that was missing * Use getLang() instead of $wgLang Modified Paths: -------------- trunk/phase3/includes/OutputPage.php Modified: trunk/phase3/includes/OutputPage.php =================================================================== --- trunk/phase3/includes/OutputPage.php 2011-07-30 19:21:31 UTC (rev 93556) +++ trunk/phase3/includes/OutputPage.php 2011-07-30 19:37:19 UTC (rev 93557) @@ -18,7 +18,7 @@ * * @todo document */ -class OutputPage { +class OutputPage extends ContextSource { /// Should be private. Used with addMeta() which adds <meta> var $mMetatags = array(); @@ -196,8 +196,6 @@ 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 @@ * 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; } /** @@ -788,29 +787,6 @@ } /** - * 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 * * @param $t Title object @@ -819,36 +795,8 @@ $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 * * @param $str String: new value of the subtitle @@ -2262,15 +2210,15 @@ * @return String: The doctype, opening <html>, 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 @@ */ protected function styleLink( $style, $options ) { if( isset( $options['dir'] ) ) { - global $wgLang; - if( $wgLang->getDir() != $options['dir'] ) { + if( $this->getLang()->getDir() != $options['dir'] ) { return ''; } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs