Make mw.user.options and mw.user.tokens work in debug mode in IE. Now that mw.user...
authorRoan Kattouw <catrope@users.mediawiki.org>
Thu, 28 Jul 2011 05:48:57 +0000 (05:48 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Thu, 28 Jul 2011 05:48:57 +0000 (05:48 +0000)
* Make ResourceLoaderUserOptionsModule and ResourceLoaderUserTokensModule depend on mw.user
* Load mw.user.{tokens,options,groups} load as TYPE_COMBINED instead of TYPE_SCRIPT. The latter wouldn't wrap the code in mw.loader.implement()
** ...but make sure 'user' (user scripts) is excluded, that one needs to not be wrapped in a closure
* Make TYPE_COMBINED actually work in makeResourceLoaderLink()
* Add a comment in makeModuleResponse() to explain what the weird is_array( $scripts ) stuff is all about
* Add FIXME about how mw.user.options should split off the CSS part into a separate module

includes/OutputPage.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderUserOptionsModule.php
includes/resourceloader/ResourceLoaderUserTokensModule.php

index 067158b..8a90c1d 100644 (file)
@@ -2403,8 +2403,10 @@ $templates
                        'lang' => $this->getContext()->getLang()->getCode(),
                        'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false',
                        'skin' => $this->getSkin()->getSkinName(),
-                       'only' => $only,
                );
+               if ( $only !== ResourceLoaderModule::TYPE_COMBINED ) {
+                       $baseQuery['only'] = $only;
+               }
                // Propagate printable and handheld parameters if present
                if ( $this->isPrintable() ) {
                        $baseQuery['printable'] = 1;
@@ -2622,11 +2624,14 @@ $templates
                                $scripts .= Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n";
                        } else {
                                # @todo FIXME: This means that User:Me/Common.js doesn't load when previewing
-                               # User:Me/Vector.js, and vice versa (bug26283)
-                               $userScripts[] = 'user';
+                               # User:Me/Vector.js, and vice versa (bug 26283)
+                               
+                               // We can't do $userScripts[] = 'user'; because the user module would end up
+                               // being wrapped in a closure, so load it raw like 'site'
+                               $scripts .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_SCRIPTS );
                        }
                }
-               $scripts .= $this->makeResourceLoaderLink( $userScripts, ResourceLoaderModule::TYPE_SCRIPTS );
+               $scripts .= $this->makeResourceLoaderLink( $userScripts, ResourceLoaderModule::TYPE_COMBINED );
 
                return $scripts;
        }
index af75a9f..1d226bd 100644 (file)
@@ -549,8 +549,10 @@ class ResourceLoader {
                                switch ( $context->getOnly() ) {
                                        case 'scripts':
                                                if ( is_string( $scripts ) ) {
+                                                       // Load scripts raw...
                                                        $out .= $scripts;
                                                } elseif ( is_array( $scripts ) ) {
+                                                       // ...except when $scripts is an array of URLs
                                                        $out .= self::makeLoaderImplementScript( $name, $scripts, array(), array() );
                                                }
                                                break;
index 7b600ea..e7f2905 100644 (file)
@@ -84,6 +84,8 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule {
         * @return array
         */
        public function getStyles( ResourceLoaderContext $context ) {
+               // FIXME: This stuff should really be in its own module, because it gets double-loaded otherwise
+               // (once through a <link>, once when embedded as JS)
                global $wgAllowUserCssPrefs;
 
                if ( $wgAllowUserCssPrefs ) {
@@ -129,4 +131,8 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule {
        public function getGroup() {
                return 'private';
        }
+       
+       public function getDependencies() {
+               return array( 'mediawiki.user' );
+       }
 }
index 9403534..e54e5dc 100644 (file)
@@ -60,4 +60,8 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
        public function getGroup() {
                return 'private';
        }
+       
+       public function getDependencies() {
+               return array( 'mediawiki.user' );
+       }
 }