Maintenance for Gadgets extension.

* Use Message class.
* Redice globals usage.
* Update .gitignore.

Change-Id: I087c8209b1a7ccf63171a2c14c8809eed90a297b
This commit is contained in:
Siebrand Mazeland 2012-08-17 11:28:09 +02:00
parent eced649f3f
commit bf416b175a
3 changed files with 8 additions and 8 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
*~
*.kate-swp
.*.swp
.idea

View file

@ -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 ) );
}
/**

View file

@ -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() );