r93557 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93556‎ | r93557 | r93558 >
Date:19:37, 30 July 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* 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) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -18,7 +18,7 @@
1919 *
2020 * @todo document
2121 */
22 -class OutputPage {
 22+class OutputPage extends ContextSource {
2323 /// Should be private. Used with addMeta() which adds <meta>
2424 var $mMetatags = array();
2525
@@ -196,8 +196,6 @@
197197
198198 var $mFileVersion = null;
199199
200 - private $mContext;
201 -
202200 /**
203201 * An array of stylesheet filenames (relative from skins path), with options
204202 * for CSS media, IE conditions, and RTL/LTR direction.
@@ -226,11 +224,12 @@
227225 * a OutputPage tied to that context.
228226 */
229227 function __construct( RequestContext $context = null ) {
230 - if ( !isset($context) ) {
 228+ if ( $context === null ) {
231229 # Extensions should use `new RequestContext` instead of `new OutputPage` now.
232230 wfDeprecated( __METHOD__ );
 231+ } else {
 232+ $this->setContext( $context );
233233 }
234 - $this->mContext = $context;
235234 }
236235
237236 /**
@@ -788,29 +787,6 @@
789788 }
790789
791790 /**
792 - * Get the RequestContext used in this instance
793 - *
794 - * @return RequestContext
795 - */
796 - private function getContext() {
797 - if ( !isset($this->mContext) ) {
798 - wfDebug( __METHOD__ . " called and \$mContext is null. Using RequestContext::getMain(); for sanity\n" );
799 - $this->mContext = RequestContext::getMain();
800 - }
801 - return $this->mContext;
802 - }
803 -
804 - /**
805 - * Get the WebRequest being used for this instance
806 - *
807 - * @return WebRequest
808 - * @since 1.18
809 - */
810 - public function getRequest() {
811 - return $this->getContext()->getRequest();
812 - }
813 -
814 - /**
815791 * Set the Title object to use
816792 *
817793 * @param $t Title object
@@ -819,36 +795,8 @@
820796 $this->getContext()->setTitle( $t );
821797 }
822798
823 - /**
824 - * Get the Title object used in this instance
825 - *
826 - * @return Title
827 - */
828 - public function getTitle() {
829 - return $this->getContext()->getTitle();
830 - }
831799
832800 /**
833 - * Get the User object used in this instance
834 - *
835 - * @return User
836 - * @since 1.18
837 - */
838 - public function getUser() {
839 - return $this->getContext()->getUser();
840 - }
841 -
842 - /**
843 - * Get the Skin object used to render this instance
844 - *
845 - * @return Skin
846 - * @since 1.18
847 - */
848 - public function getSkin() {
849 - return $this->getContext()->getSkin();
850 - }
851 -
852 - /**
853801 * Replace the subtile with $str
854802 *
855803 * @param $str String: new value of the subtitle
@@ -2262,15 +2210,15 @@
22632211 * @return String: The doctype, opening <html>, and head element.
22642212 */
22652213 public function headElement( Skin $sk, $includeStyle = true ) {
2266 - global $wgLang, $wgContLang, $wgUseTrackbacks;
2267 - $userdir = $wgLang->getDir();
 2214+ global $wgContLang, $wgUseTrackbacks;
 2215+ $userdir = $this->getLang()->getDir();
22682216 $sitedir = $wgContLang->getDir();
22692217
22702218 if ( $sk->commonPrintStylesheet() ) {
22712219 $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' );
22722220 }
22732221
2274 - $ret = Html::htmlHeader( array( 'lang' => $wgLang->getCode(), 'dir' => $userdir ) );
 2222+ $ret = Html::htmlHeader( array( 'lang' => $this->getLang()->getCode(), 'dir' => $userdir ) );
22752223
22762224 if ( $this->getHTMLTitle() == '' ) {
22772225 $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
@@ -3088,8 +3036,7 @@
30893037 */
30903038 protected function styleLink( $style, $options ) {
30913039 if( isset( $options['dir'] ) ) {
3092 - global $wgLang;
3093 - if( $wgLang->getDir() != $options['dir'] ) {
 3040+ if( $this->getLang()->getDir() != $options['dir'] ) {
30943041 return '';
30953042 }
30963043 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r97624MFT r93557, revert r97588 in 1.18wmf1 AND REL1_18reedy13:23, 20 September 2011

Comments

#Comment by Siebrand (talk | contribs)   19:52, 30 July 2011

Nice!

Status & tagging log