Merge "Pingback: Tweak docs a tiny bit to point to mw.org better"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderWikiModule.php
index e3ada8e..82051b1 100644 (file)
@@ -61,9 +61,6 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
        // Group of module
        protected $group;
 
-       // Whether to enable variable expansion (e.g. "{skin}")
-       protected $allowVariables = false;
-
        /**
         * @param array $options For back-compat, this can be omitted in favour of overwriting getPages.
         */
@@ -79,7 +76,6 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                                case 'scripts':
                                case 'group':
                                case 'targets':
-                               case 'allowVariables':
                                        $this->{$member} = $option;
                                        break;
                        }
@@ -109,30 +105,19 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                // Filter out pages from origins not allowed by the current wiki configuration.
                if ( $config->get( 'UseSiteJs' ) ) {
                        foreach ( $this->scripts as $script ) {
-                               $page = $this->expandVariables( $context, $script );
-                               $pages[$page] = [ 'type' => 'script' ];
+                               $pages[$script] = [ 'type' => 'script' ];
                        }
                }
 
                if ( $config->get( 'UseSiteCss' ) ) {
                        foreach ( $this->styles as $style ) {
-                               $page = $this->expandVariables( $context, $style );
-                               $pages[$page] = [ 'type' => 'style' ];
+                               $pages[$style] = [ 'type' => 'style' ];
                        }
                }
 
                return $pages;
        }
 
-       private function expandVariables( ResourceLoaderContext $context, $pageName ) {
-               if ( !$this->allowVariables ) {
-                       return $pageName;
-               }
-               return strtr( $pageName, [
-                       '{skin}' => $context->getSkin()
-               ] );
-       }
-
        /**
         * Get group name
         *
@@ -336,7 +321,21 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                return $this->titleInfo[$key];
        }
 
+       /**
+        * @return string
+        */
        public function getPosition() {
                return $this->position;
        }
+
+       /**
+        * @since 1.28
+        * @return string
+        */
+       public function getType() {
+               // Check both because subclasses don't always pass pages via the constructor,
+               // they may also override getPages() instead, in which case we should keep
+               // defaulting to LOAD_GENERAL and allow them to override getType() separately.
+               return ( $this->styles && !$this->scripts ) ? self::LOAD_STYLES : self::LOAD_GENERAL;
+       }
 }