r94010 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94009‎ | r94010 | r94011 >
Date:08:33, 6 August 2011
Author:catrope
Status:deferred
Tags:
Comment:
Update ResourceLoaderRegisterModules hook to work with the new backend, and add TitleIsCssOrJsPage hook.
Modified paths:
  • /branches/RL2/extensions/Gadgets/GadgetHooks.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/Gadgets.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.php
@@ -83,6 +83,7 @@
8484 $wgHooks['GetPreferences'][] = 'GadgetHooks::getPreferences';
8585 $wgHooks['LoadExtensionSchemaUpdates'][] = 'GadgetHooks::loadExtensionSchemaUpdates';
8686 $wgHooks['ResourceLoaderRegisterModules'][] = 'GadgetHooks::registerModules';
 87+$wgHooks['TitleIsCssOrJsPage'][] = 'GadgetHooks::titleIsCssOrJsPage';
8788 $wgHooks['UnitTestsList'][] = 'GadgetHooks::unitTestsList';
8889
8990 $dir = dirname(__FILE__) . '/';
Index: branches/RL2/extensions/Gadgets/GadgetHooks.php
@@ -92,14 +92,16 @@
9393 * @param $resourceLoader ResourceLoader
9494 */
9595 public static function registerModules( &$resourceLoader ) {
96 - $gadgets = Gadget::loadList();
97 - if ( !$gadgets ) {
98 - return true;
99 - }
100 - foreach ( $gadgets as $g ) {
101 - $module = $g->getModule();
102 - if ( $module ) {
103 - $resourceLoader->register( $g->getModuleName(), $module );
 96+ global $wgGadgetRepositories;
 97+ foreach ( $wgGadgetRepositories as $params ) {
 98+ $repoClass = $params['class'];
 99+ unset( $params['class'] );
 100+ $repo = new $repoClass( $params );
 101+
 102+ $gadgets = $repo->getGadgetNames();
 103+ foreach ( $gadgets as $name ) {
 104+ $gadget = $repo->getGadget( $name );
 105+ $resourceLoader->register( $gadget->getModuleName(), $gadget->getModule() );
104106 }
105107 }
106108 return true;
@@ -193,4 +195,11 @@
194196 $list[NS_GADGET_TALK] = 'Gadget_talk';
195197 return true;
196198 }
 199+
 200+ public static function titleIsCssOrJsPage( $title, &$result ) {
 201+ if ( $title->getNamespace() == NS_GADGET ) {
 202+ $result = true;
 203+ }
 204+ return true;
 205+ }
197206 }

Status & tagging log