Merge "Check validity and availability of usernames during signup via AJAX"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index d51e06a..12c452a 100644 (file)
 /**
  * Dynamic JavaScript and CSS resource loading system.
  *
- * Most of the documention is on the MediaWiki documentation wiki starting at:
+ * Most of the documentation is on the MediaWiki documentation wiki starting at:
  *    https://www.mediawiki.org/wiki/ResourceLoader
  */
 class ResourceLoader {
 
-       /* Protected Static Members */
+       /**
+        * @var int
+        */
        protected static $filterCacheVersion = 7;
+       /**
+        * @var array
+        */
        protected static $requiredSourceProperties = array( 'loadScript' );
 
-       /** Array: List of module name/ResourceLoaderModule object pairs */
+       /**
+        * @var array Module name/ResourceLoaderModule object pairs
+        */
        protected $modules = array();
 
-       /** Associative array mapping module name to info associative array */
+       /**
+        * @var array Associative array mapping module name to info associative array
+        */
        protected $moduleInfos = array();
 
-       /** Associative array mapping framework ids to a list of names of test suite modules */
-       /** like array( 'qunit' => array( 'mediawiki.tests.qunit.suites', 'ext.foo.tests', .. ), .. ) */
+       /**
+        * @var array Associative array mapping framework ids to a list of names of test suite modules
+        *      like array( 'qunit' => array( 'mediawiki.tests.qunit.suites', 'ext.foo.tests', .. ), .. )
+        */
        protected $testModuleNames = array();
 
-       /** array( 'source-id' => array( 'loadScript' => 'http://.../load.php' ) ) **/
+       /**
+        * @var array e.g. array( 'source-id' => array( 'loadScript' => 'http://.../load.php' ) )
+        */
        protected $sources = array();
 
-       /** @var bool */
+       /**
+        * @var bool
+        */
        protected $hasErrors = false;
 
-       /* Protected Methods */
-
        /**
         * Load information stored in the database about modules.
         *
@@ -936,7 +949,11 @@ class ResourceLoader {
         * @return string
         */
        public static function makeMessageSetScript( $messages ) {
-               return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) );
+               return Xml::encodeJsCall(
+                       'mw.messages.set',
+                       array( (object)$messages ),
+                       ResourceLoader::inDebugMode()
+               );
        }
 
        /**
@@ -989,9 +1006,17 @@ class ResourceLoader {
         */
        public static function makeLoaderStateScript( $name, $state = null ) {
                if ( is_array( $name ) ) {
-                       return Xml::encodeJsCall( 'mw.loader.state', array( $name ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.state',
+                               array( $name ),
+                               ResourceLoader::inDebugMode()
+                       );
                } else {
-                       return Xml::encodeJsCall( 'mw.loader.state', array( $name, $state ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.state',
+                               array( $name, $state ),
+                               ResourceLoader::inDebugMode()
+                       );
                }
        }
 
@@ -1013,7 +1038,9 @@ class ResourceLoader {
                $script = str_replace( "\n", "\n\t", trim( $script ) );
                return Xml::encodeJsCall(
                        "( function ( name, version, dependencies, group, source ) {\n\t$script\n} )",
-                       array( $name, $version, $dependencies, $group, $source ) );
+                       array( $name, $version, $dependencies, $group, $source ),
+                       ResourceLoader::inDebugMode()
+               );
        }
 
        /**
@@ -1044,11 +1071,18 @@ class ResourceLoader {
                $dependencies = null, $group = null, $source = null
        ) {
                if ( is_array( $name ) ) {
-                       return Xml::encodeJsCall( 'mw.loader.register', array( $name ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.register',
+                               array( $name ),
+                               ResourceLoader::inDebugMode()
+                       );
                } else {
                        $version = (int)$version > 1 ? (int)$version : 1;
-                       return Xml::encodeJsCall( 'mw.loader.register',
-                               array( $name, $version, $dependencies, $group, $source ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.register',
+                               array( $name, $version, $dependencies, $group, $source ),
+                               ResourceLoader::inDebugMode()
+                       );
                }
        }
 
@@ -1068,9 +1102,17 @@ class ResourceLoader {
         */
        public static function makeLoaderSourcesScript( $id, $properties = null ) {
                if ( is_array( $id ) ) {
-                       return Xml::encodeJsCall( 'mw.loader.addSource', array( $id ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.addSource',
+                               array( $id ),
+                               ResourceLoader::inDebugMode()
+                       );
                } else {
-                       return Xml::encodeJsCall( 'mw.loader.addSource', array( $id, $properties ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.addSource',
+                               array( $id, $properties ),
+                               ResourceLoader::inDebugMode()
+                       );
                }
        }
 
@@ -1093,7 +1135,11 @@ class ResourceLoader {
         * @return string
         */
        public static function makeConfigSetScript( array $configuration ) {
-               return Xml::encodeJsCall( 'mw.config.set', array( $configuration ), ResourceLoader::inDebugMode() );
+               return Xml::encodeJsCall(
+                       'mw.config.set',
+                       array( $configuration ),
+                       ResourceLoader::inDebugMode()
+               );
        }
 
        /**