r76193 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76192‎ | r76193 | r76194 >
Date:15:13, 6 November 2010
Author:catrope
Status:deferred
Tags:
Comment:
Fix ResourceLoader support in UploadWizard, which was broken by r76182, possibly earlier.
* Fix for r76189: don't check $wgUploadWizardDisableResourceLoader in UploadWizard.php , check it in the hook instead. Otherwise, there's no opportunity to change it
* Move jQuery UI files to scripts. Having them in dependencies broke RL because it expects module names there, not file names. Also means UploadWizardDependencyLoader no longer merges dependencies into scripts
* Declare messages so RL exports them
* Have mw.Language.js check mw.msg() too. This is a dirty hack to accommodate for the fact that we're working with two competing i18n implementations, which should be unified at some point.
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardDependencyLoader.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardHooks.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardMessages.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/combined.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/combined.min.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/language/mw.Language.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -14,6 +14,11 @@
1515 public static $modules = array(
1616 'ext.uploadWizard' => array(
1717 'scripts' => array(
 18+ // jquery ui
 19+ // FIXME: These can be replaced with dependencies when pre-RL compat is dropped
 20+ 'resources/jquery.ui/ui/ui.core.js',
 21+ 'resources/jquery.ui/ui/ui.datepicker.js',
 22+ 'resources/jquery.ui/ui/ui.progressbar.js',
1823
1924 // jquery interface helpers
2025 'resources/jquery/jquery.tipsy.js',
@@ -116,14 +121,140 @@
117122 'resources/jquery.ui/themes/redmond/jquery-ui-1.7.1.custom.css'
118123 ),
119124 'messages' => array(
120 - // see UploadWizard.i18n.php
 125+ 'linktest',
 126+ 'pluraltest',
 127+ 'magictest',
 128+ 'namespacedtest',
 129+ 'extremelycomplextest',
 130+ 'internallinktest',
 131+ 'uploadwizard',
 132+ 'uploadwizard-desc',
 133+ 'mwe-upwiz-js-off',
 134+ 'mwe-loading-upwiz',
 135+ 'mwe-upwiz-code-unknown',
 136+ 'mwe-upwiz-step-tutorial',
 137+ 'mwe-upwiz-step-file',
 138+ 'mwe-upwiz-step-deeds',
 139+ 'mwe-upwiz-step-details',
 140+ 'mwe-upwiz-step-thanks',
 141+ 'mwe-upwiz-api-error-code',
 142+ 'mwe-upwiz-tutorial-error',
 143+ 'mwe-upwiz-intro',
 144+ 'mwe-upwiz-add-file-n',
 145+ 'mwe-upwiz-add-file-0',
 146+ 'mwe-upwiz-browse',
 147+ 'mwe-upwiz-transported',
 148+ 'mwe-upwiz-click-here',
 149+ 'mwe-upwiz-uploading',
 150+ 'mwe-upwiz-editing',
 151+ 'mwe-upwiz-remove-upload',
 152+ 'mwe-upwiz-remove-description',
 153+ 'mwe-upwiz-upload',
 154+ 'mwe-upwiz-upload-count',
 155+ 'mwe-upwiz-progressbar-uploading',
 156+ 'mwe-upwiz-finished',
 157+ 'mwe-upwiz-secs-remaining',
 158+ 'mwe-upwiz-mins-secs-remaining',
 159+ 'mwe-upwiz-hrs-mins-secs-remaining',
 160+ 'mwe-upwiz-deeds-intro',
 161+ 'mwe-upwiz-deeds-macro-prompt',
 162+ 'mwe-upwiz-deeds-custom-prompt',
 163+ 'mwe-upwiz-details-intro',
 164+ 'mwe-upwiz-source-ownwork',
 165+ 'mwe-upwiz-source-ownwork-assert',
 166+ 'mwe-upwiz-source-ownwork-assert-custom',
 167+ 'mwe-upwiz-source-ownwork-assert-note',
 168+ 'mwe-upwiz-source-permission',
 169+ 'mwe-upwiz-source-thirdparty',
 170+ 'mwe-upwiz-source-thirdparty-intro',
 171+ 'mwe-upwiz-source-thirdparty-custom-multiple-intro',
 172+ 'mwe-upwiz-source-thirdparty-license',
 173+ 'mwe-upwiz-source-thirdparty-accept',
 174+ 'mwe-upwiz-source-custom',
 175+ 'mwe-upwiz-more-options',
 176+ 'mwe-upwiz-fewer-options',
 177+ 'mwe-upwiz-desc',
 178+ 'mwe-upwiz-desc-add-n',
 179+ 'mwe-upwiz-desc-add-0',
 180+ 'mwe-upwiz-title',
 181+ 'mwe-upwiz-categories-intro',
 182+ 'mwe-upwiz-categories-another',
 183+ 'mwe-upwiz-previously-uploaded',
 184+ 'mwe-upwiz-about-this-work',
 185+ 'mwe-upwiz-media-type',
 186+ 'mwe-upwiz-date-created',
 187+ 'mwe-upwiz-location',
 188+ 'mwe-upwiz-copyright-info',
 189+ 'mwe-upwiz-author',
 190+ 'mwe-upwiz-license',
 191+ 'mwe-upwiz-about-format',
 192+ 'mwe-upwiz-autoconverted',
 193+ 'mwe-upwiz-filename-tag',
 194+ 'mwe-upwiz-other',
 195+ 'mwe-upwiz-other-prefill',
 196+ 'mwe-upwiz-showall',
 197+ 'mwe-upwiz-source',
 198+ 'mwe-upwiz-macro-edit-intro',
 199+ 'mwe-upwiz-macro-edit',
 200+ 'mwe-upwiz-thanks-intro',
 201+ 'mwe-upwiz-thanks-explain',
 202+ 'mwe-upwiz-thanks-link',
 203+ 'mwe-upwiz-thanks-wikitext',
 204+ 'mwe-upwiz-thanks-url',
 205+ 'mwe-upwiz-upload-error-bad-filename-extension',
 206+ 'mwe-upwiz-upload-error-duplicate',
 207+ 'mwe-upwiz-upload-error-stashed-anyway',
 208+ 'mwe-upwiz-ok',
 209+ 'mwe-upwiz-cancel',
 210+ 'mwe-upwiz-change',
 211+ 'mwe-upwiz-fileexists-replace',
 212+ 'mwe-upwiz-fileexists',
 213+ 'mwe-upwiz-thumbnail-more',
 214+ 'mwe-upwiz-overwrite',
 215+ 'mwe-copyright-macro',
 216+ 'mwe-copyright-custom',
 217+ 'mwe-upwiz-next',
 218+ 'mwe-upwiz-next-file',
 219+ 'mwe-upwiz-next-deeds',
 220+ 'mwe-upwiz-next-details',
 221+ 'mwe-upwiz-home',
 222+ 'mwe-upwiz-upload-another',
 223+ 'mwe-prevent-close',
 224+ 'mwe-upwiz-files-complete',
 225+ 'mwe-upwiz-tooltip-author',
 226+ 'mwe-upwiz-tooltip-source',
 227+ 'mwe-upwiz-tooltip-sign',
 228+ 'mwe-upwiz-tooltip-title',
 229+ 'mwe-upwiz-tooltip-description',
 230+ 'mwe-upwiz-tooltip-other',
 231+ 'mwe-upwiz-tooltip-more-info',
 232+ 'mwe-upwiz-file-need-file',
 233+ 'mwe-upwiz-file-need-start',
 234+ 'mwe-upwiz-file-need-complete',
 235+ 'mwe-upwiz-deeds-need-deed',
 236+ 'mwe-upwiz-deeds-need-license',
 237+ 'mwe-upwiz-license-incompatible-pd',
 238+ 'mwe-upwiz-license-incompatible-cc',
 239+ 'mwe-upwiz-license-show-all',
 240+ 'mwe-upwiz-license-show-recommended',
 241+ 'mwe-upwiz-error-signature-blank',
 242+ 'mwe-upwiz-error-signature-too-long',
 243+ 'mwe-upwiz-error-signature-too-short',
 244+ 'mwe-upwiz-error-signature-bad-chars',
 245+ 'mwe-upwiz-error-blank',
 246+ 'mwe-upwiz-error-too-long',
 247+ 'mwe-upwiz-error-too-short',
 248+ 'mwe-upwiz-error-bad-chars',
 249+ 'mwe-upwiz-error-date',
 250+ 'mwe-upwiz-license-cc-by-sa-3.0',
 251+ 'mwe-upwiz-license-cc-by-3.0',
 252+ 'mwe-upwiz-license-cc-zero',
 253+ 'mwe-upwiz-license-gfdl',
 254+ 'mwe-upwiz-license-pd-us',
 255+ 'mwe-upwiz-categories',
 256+ 'mwe-upwiz-categories-add',
 257+ 'mwe-upwiz-category-remove',
121258 ),
122 - // in ResourceLoader, these will probably have names rather than explicit script paths, or be automatically loaded
123 - 'dependencies' => array(
124 - 'resources/jquery.ui/ui/ui.core.js',
125 - 'resources/jquery.ui/ui/ui.datepicker.js',
126 - 'resources/jquery.ui/ui/ui.progressbar.js'
127 - ),
128259 'group' => 'ext.uploadWizard'
129260 ),
130261 'ext.uploadWizard.tests' => array(
@@ -139,7 +270,11 @@
140271 * Adds modules to ResourceLoader
141272 */
142273 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
143 - global $wgExtensionAssetsPath;
 274+ global $wgExtensionAssetsPath, $wgUploadWizardDisableResourceLoader;
 275+ if ( $wgUploadWizardDisableResourceLoader ) {
 276+ return true;
 277+ }
 278+
144279 $localpath = dirname( __FILE__ );
145280 $remotepath = "$wgExtensionAssetsPath/UploadWizard";
146281 foreach ( self::$modules as $name => $resources ) {
Index: trunk/extensions/UploadWizard/UploadWizardDependencyLoader.php
@@ -36,7 +36,7 @@
3737 public function __construct( $langCode = null ) {
3838 $module = UploadWizardHooks::$modules['ext.uploadWizard'];
3939
40 - $this->scripts = array_merge( $module['dependencies'], $module['scripts'] );
 40+ $this->scripts = $module['scripts'];
4141
4242 $this->inlineScripts = array();
4343 if ( $langCode !== null ) {
Index: trunk/extensions/UploadWizard/UploadWizardMessages.php
@@ -19,8 +19,6 @@
2020 * @param String $langCode Name of scriptText module ( that hosts messages )
2121 * @return string
2222 */
23 -
24 -
2523 public static function getMessagesJs( $moduleName, $language ) {
2624 global $wgOut;
2725
Index: trunk/extensions/UploadWizard/resources/language/mw.Language.js
@@ -25,7 +25,7 @@
2626
2727 /**
2828 * mw.addMessages function
29 - * Loads a set of json messages into the messegeCache object.
 29+ * Loads a set of json messages into the messageCache object.
3030 *
3131 * @param {JSON} msgSet The set of msgs to be loaded
3232 */
@@ -52,8 +52,14 @@
5353 mw.getMsg = function( messageKey , args ) {
5454
5555 // Check for missing message key
56 - if ( ! messageCache[ messageKey ] ){
57 - return '[' + messageKey + ']';
 56+ if ( ! messageCache[ messageKey ] ) {
 57+ // Try the ResourceLoader's message store
 58+ // FIXME: The two message stores should be unified in the future
 59+ var rlMsg = mediaWiki.msg( messageKey );
 60+ if ( rlMsg == ( '<' + messageKey + '>' ) ) {
 61+ return '[' + messageKey + ']';
 62+ }
 63+ messageCache[ messageKey ] = rlMsg;
5864 }
5965 // Check if we need to do args replacements:
6066 if( typeof args != 'undefined' ) {
Index: trunk/extensions/UploadWizard/resources/combined.js
@@ -5531,7 +5531,7 @@
55325532
55335533 /**
55345534 * mw.addMessages function
5535 - * Loads a set of json messages into the messegeCache object.
 5535+ * Loads a set of json messages into the messageCache object.
55365536 *
55375537 * @param {JSON} msgSet The set of msgs to be loaded
55385538 */
@@ -5558,8 +5558,14 @@
55595559 mw.getMsg = function( messageKey , args ) {
55605560
55615561 // Check for missing message key
5562 - if ( ! messageCache[ messageKey ] ){
5563 - return '[' + messageKey + ']';
 5562+ if ( ! messageCache[ messageKey ] ) {
 5563+ // Try the ResourceLoader's message store
 5564+ // FIXME: The two message stores should be unified in the future
 5565+ var rlMsg = mediaWiki.msg( messageKey );
 5566+ if ( rlMsg == ( '<' + messageKey + '>' ) ) {
 5567+ return '[' + messageKey + ']';
 5568+ }
 5569+ messageCache[ messageKey ] = rlMsg;
55645570 }
55655571 // Check if we need to do args replacements:
55665572 if( typeof args != 'undefined' ) {
Index: trunk/extensions/UploadWizard/resources/combined.min.js
@@ -5559,8 +5559,14 @@
55605560
55615561
55625562 if(!messageCache[messageKey]){
 5563+
 5564+
 5565+var rlMsg=mediaWiki.msg(messageKey);
 5566+if(rlMsg==('<'+messageKey+'>')){
55635567 return'['+messageKey+']';
55645568 }
 5569+messageCache[messageKey]=rlMsg;
 5570+}
55655571
55665572 if(typeof args!='undefined'){
55675573
Index: trunk/extensions/UploadWizard/UploadWizard.php
@@ -58,6 +58,4 @@
5959 $wgUploadWizardDisableResourceLoader = true;
6060
6161 // for ResourceLoader
62 -if ( !$wgUploadWizardDisableResourceLoader && class_exists( 'ResourceLoader' ) ) {
63 - $wgHooks['ResourceLoaderRegisterModules'][] = 'UploadWizardHooks::resourceLoaderRegisterModules';
64 -}
 62+$wgHooks['ResourceLoaderRegisterModules'][] = 'UploadWizardHooks::resourceLoaderRegisterModules';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r76182reasonable optimization & minification for resources without ResourceLoaderneilk08:25, 6 November 2010
r76189Fix r76182 in various ways. Also addresses CR on r75954...catrope13:10, 6 November 2010

Status & tagging log