Merge "Convert article delete to use OOUI"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index 0d12840..8553116 100644 (file)
@@ -253,7 +253,6 @@ class ResourceLoader implements LoggerAwareInterface {
 
                // Register core modules
                $this->register( include "$IP/resources/Resources.php" );
-               $this->register( include "$IP/resources/ResourcesOOUI.php" );
                // Register extension modules
                $this->register( $config->get( 'ResourceModules' ) );
 
@@ -564,7 +563,8 @@ class ResourceLoader implements LoggerAwareInterface {
        }
 
        /**
-        * Return whether the definition of a module corresponds to a simple ResourceLoaderFileModule.
+        * Return whether the definition of a module corresponds to a simple ResourceLoaderFileModule
+        * or one of its subclasses.
         *
         * @param string $name Module name
         * @return bool
@@ -574,7 +574,14 @@ class ResourceLoader implements LoggerAwareInterface {
                        return false;
                }
                $info = $this->moduleInfos[$name];
-               if ( isset( $info['object'] ) || isset( $info['class'] ) ) {
+               if ( isset( $info['object'] ) ) {
+                       return false;
+               }
+               if (
+                       isset( $info['class'] ) &&
+                       $info['class'] !== 'ResourceLoaderFileModule' &&
+                       !is_subclass_of( $info['class'], 'ResourceLoaderFileModule' )
+               ) {
                        return false;
                }
                return true;
@@ -1093,7 +1100,12 @@ MESSAGE;
                                        $strContent = self::filter( $filter, $strContent );
                                }
 
-                               $out .= $strContent;
+                               if ( $context->getOnly() === 'scripts' ) {
+                                       // Use a linebreak between module scripts (T162719)
+                                       $out .= $this->ensureNewline( $strContent );
+                               } else {
+                                       $out .= $strContent;
+                               }
 
                        } catch ( Exception $e ) {
                                $this->outputErrorAndLog( $e, 'Generating module package failed: {exception}' );
@@ -1121,7 +1133,8 @@ MESSAGE;
                                if ( !$context->getDebug() ) {
                                        $stateScript = self::filter( 'minify-js', $stateScript );
                                }
-                               $out .= $stateScript;
+                               // Use a linebreak between module script and state script (T162719)
+                               $out = $this->ensureNewline( $out ) . $stateScript;
                        }
                } else {
                        if ( count( $states ) ) {
@@ -1133,6 +1146,19 @@ MESSAGE;
                return $out;
        }
 
+       /**
+        * Ensure the string is either empty or ends in a line break
+        * @param string $str
+        * @return string
+        */
+       private function ensureNewline( $str ) {
+               $end = substr( $str, -1 );
+               if ( $end === false || $end === "\n" ) {
+                       return $str;
+               }
+               return $str . "\n";
+       }
+
        /**
         * Get names of modules that use a certain message.
         *
@@ -1166,7 +1192,7 @@ MESSAGE;
         * @param array $templates Keys are name of templates and values are the source of
         *   the template.
         * @throws MWException
-        * @return string
+        * @return string JavaScript code
         */
        protected static function makeLoaderImplementScript(
                $name, $scripts, $styles, $messages, $templates
@@ -1196,7 +1222,7 @@ MESSAGE;
         *
         * @param mixed $messages Either an associative array mapping message key to value, or a
         *   JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object.
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeMessageSetScript( $messages ) {
                return Xml::encodeJsCall(
@@ -1252,7 +1278,7 @@ MESSAGE;
         *
         * @param string $name
         * @param string $state
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderStateScript( $name, $state = null ) {
                if ( is_array( $name ) ) {
@@ -1282,7 +1308,7 @@ MESSAGE;
         * @param string $group Group which the module is in.
         * @param string $source Source of the module, or 'local' if not foreign.
         * @param string $script JavaScript code
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeCustomLoaderScript( $name, $version, $dependencies,
                $group, $source, $script
@@ -1354,7 +1380,7 @@ MESSAGE;
         * @param string $group Group which the module is in
         * @param string $source Source of the module, or 'local' if not foreign
         * @param string $skip Script body of the skip function
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderRegisterScript( $name, $version = null,
                $dependencies = null, $group = null, $source = null, $skip = null
@@ -1408,7 +1434,7 @@ MESSAGE;
         *
         * @param string $id Source ID
         * @param string $loadUrl load.php url
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderSourcesScript( $id, $loadUrl = null ) {
                if ( is_array( $id ) ) {
@@ -1432,7 +1458,7 @@ MESSAGE;
         *
         * @deprecated since 1.25; use makeInlineScript instead
         * @param string $script JavaScript code
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderConditionalScript( $script ) {
                return '(window.RLQ=window.RLQ||[]).push(function(){' .
@@ -1462,7 +1488,7 @@ MESSAGE;
         * the given value.
         *
         * @param array $configuration List of configuration values keyed by variable name
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeConfigSetScript( array $configuration ) {
                return Xml::encodeJsCall(