From bf416b175a4c4a0fd8cc0b96dbc582e2505c39e0 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 17 Aug 2012 11:28:09 +0200 Subject: [PATCH] Maintenance for Gadgets extension. * Use Message class. * Redice globals usage. * Update .gitignore. Change-Id: I087c8209b1a7ccf63171a2c14c8809eed90a297b --- .gitignore | 1 + ApiQueryGadgets.php | 6 +++--- Gadgets_body.php | 9 ++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 98b092a9..c798be9c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *~ *.kate-swp .*.swp +.idea diff --git a/ApiQueryGadgets.php b/ApiQueryGadgets.php index c6d90781..90e77a3b 100644 --- a/ApiQueryGadgets.php +++ b/ApiQueryGadgets.php @@ -107,11 +107,11 @@ class ApiQueryGadgets extends ApiQueryBase { * @return bool */ private function isNeeded( Gadget $gadget ) { - global $wgUser; + $user = $this->getUser(); return ( $this->neededIds === false || isset( $this->neededIds[$gadget->getName()] ) ) - && ( !$this->listAllowed || $gadget->isAllowed( $wgUser ) ) - && ( !$this->listEnabled || $gadget->isEnabled( $wgUser ) ); + && ( !$this->listAllowed || $gadget->isAllowed( $user ) ) + && ( !$this->listEnabled || $gadget->isEnabled( $user ) ); } /** diff --git a/Gadgets_body.php b/Gadgets_body.php index 4869d8c2..330a1541 100644 --- a/Gadgets_body.php +++ b/Gadgets_body.php @@ -87,7 +87,7 @@ class GadgetHooks { } if ( $section !== '' ) { - $section = wfMsgExt( "gadget-section-$section", 'parseinline' ); + $section = wfMessage( "gadget-section-$section" )->parse(); if ( count ( $available ) ) { $options[$section] = $available; @@ -103,7 +103,7 @@ class GadgetHooks { 'label' => ' ', 'default' => Xml::tags( 'tr', array(), Xml::tags( 'td', array( 'colspan' => 2 ), - wfMsgExt( 'gadgets-prefstext', 'parse' ) ) ), + wfMessage( 'gadgets-prefstext' )->parseAsBlock() ) ), 'section' => 'gadgets', 'raw' => 1, 'rawrow' => 1, @@ -152,8 +152,6 @@ class GadgetHooks { * @return bool */ public static function beforePageDisplay( $out ) { - global $wgUser; - wfProfileIn( __METHOD__ ); $gadgets = Gadget::loadList(); @@ -169,8 +167,9 @@ class GadgetHooks { /** * @var $gadget Gadget */ + $user = $out->getUser(); foreach ( $gadgets as $gadget ) { - if ( $gadget->isEnabled( $wgUser ) && $gadget->isAllowed( $wgUser ) ) { + if ( $gadget->isEnabled( $user ) && $gadget->isAllowed( $user ) ) { if ( $gadget->hasModule() ) { $out->addModuleStyles( $gadget->getModuleName() ); $out->addModules( $gadget->getModuleName() );