r97366 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97365‎ | r97366 | r97367 >
Date:02:46, 17 September 2011
Author:krinkle
Status:ok
Tags:
Comment:
[ResourceLoader2] Set default options for gadgets that are enabled by default, otherwise they can't be disabled from the preferences (bug 30941)
* Uses the new hook in User:getDefaultOptions (bug 30940; r97365)
* We need to make a similar fix to trunk (and then back port to 1.18)
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
@@ -98,6 +98,7 @@
9999 $wgHooks['MakeGlobalVariablesScript'][] = 'GadgetHooks::makeGlobalVariablesScript';
100100 $wgHooks['CanonicalNamespaces'][] = 'GadgetHooks::canonicalNamespaces';
101101 $wgHooks['GetPreferences'][] = 'GadgetHooks::getPreferences';
 102+$wgHooks['UserGetDefaultOptions'][] = 'GadgetHooks::userGetDefaultOptions';
102103 $wgHooks['LoadExtensionSchemaUpdates'][] = 'GadgetHooks::loadExtensionSchemaUpdates';
103104 $wgHooks['ResourceLoaderRegisterModules'][] = 'GadgetHooks::registerModules';
104105 $wgHooks['TitleIsCssOrJsPage'][] = 'GadgetHooks::titleIsCssOrJsPage';
Index: branches/RL2/extensions/Gadgets/GadgetHooks.php
@@ -189,6 +189,22 @@
190190 }
191191
192192 /**
 193+ * UserGetDefaultOptions hook handler
 194+ * @param $defaultOptions Array of default preference keys and values
 195+ */
 196+ public static function userGetDefaultOptions( &$defaultOptions ) {
 197+ $repo = LocalGadgetRepo::singleton();
 198+ $gadgetIds = $repo->getGadgetIds();
 199+ foreach ( $gadgetIds as $gadgetId ) {
 200+ $gadget = $repo->getGadget( $gadgetId );
 201+ if ( $gadget->isEnabledByDefault() ) {
 202+ $defaultOptions['gadget-' . $gadget->getId()] = 1;
 203+ }
 204+ }
 205+ return true;
 206+ }
 207+
 208+ /**
193209 * GetPreferences hook handler.
194210 * @param $user User
195211 * @param $preferences Array: Preference descriptions

Follow-up revisions

RevisionCommit summaryAuthorDate
r97367[ResourceLoader] Set default options for gadgets that are enabled by default,...krinkle03:03, 17 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97365(bug 30940) Add a hook in User:getDefaultOptions....krinkle02:42, 17 September 2011

Status & tagging log