X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fresourceloader%2FResourceLoader.php;h=6426feacaf4c2aabcaa8bf66748ad521b46eef36;hb=d02d091047dead4bb6a51ab9b52768e19a4708a5;hp=ccf764bc18918179f9d13216d838ca3b8a8f07cd;hpb=41269d28db317de86e4fafe35f781432bd2d4dc0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index ccf764bc18..6426feacaf 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -60,13 +60,13 @@ class ResourceLoader implements LoggerAwareInterface { /** * 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', .. ), .. ) + * like [ 'qunit' => [ 'mediawiki.tests.qunit.suites', 'ext.foo.tests', ... ], ... ] * @var array */ protected $testModuleNames = []; /** - * E.g. array( 'source-id' => 'http://.../load.php' ) + * E.g. [ 'source-id' => 'http://.../load.php' ] * @var array */ protected $sources = []; @@ -241,7 +241,7 @@ class ResourceLoader implements LoggerAwareInterface { $this->config = $config; // Add 'local' source first - $this->addSource( 'local', wfScript( 'load' ) ); + $this->addSource( 'local', $config->get( 'LoadScript' ) ); // Add other sources $this->addSource( $config->get( 'ResourceLoaderSources' ) ); @@ -433,7 +433,7 @@ class ResourceLoader implements LoggerAwareInterface { * * Source IDs are typically the same as the Wiki ID or database name (e.g. lowercase a-z). * - * @param array|string $id Source ID (string), or array( id1 => loadUrl, id2 => loadUrl, ... ) + * @param array|string $id Source ID (string), or [ id1 => loadUrl, id2 => loadUrl, ... ] * @param string|array $loadUrl load.php url (string), or array with loadUrl key for * backwards-compatibility. * @throws MWException @@ -573,7 +573,7 @@ class ResourceLoader implements LoggerAwareInterface { /** * Get the list of sources. * - * @return array Like array( id => load.php url, .. ) + * @return array Like [ id => load.php url, ... ] */ public function getSources() { return $this->sources; @@ -1173,7 +1173,7 @@ MESSAGE; * - ResourceLoader::makeLoaderStateScript( $name, $state ): * Set the state of a single module called $name to $state * - * - ResourceLoader::makeLoaderStateScript( array( $name => $state, ... ) ): + * - ResourceLoader::makeLoaderStateScript( [ $name => $state, ... ] ): * Set the state of modules with the given names to the given states * * @param string $name @@ -1264,14 +1264,14 @@ MESSAGE; * ): * Register a single module. * - * - ResourceLoader::makeLoaderRegisterScript( array( $name1, $name2 ) ): + * - ResourceLoader::makeLoaderRegisterScript( [ $name1, $name2 ] ): * Register modules with the given names. * - * - ResourceLoader::makeLoaderRegisterScript( array( - * array( $name1, $version1, $dependencies1, $group1, $source1, $skip1 ), - * array( $name2, $version2, $dependencies1, $group2, $source2, $skip2 ), + * - ResourceLoader::makeLoaderRegisterScript( [ + * [ $name1, $version1, $dependencies1, $group1, $source1, $skip1 ], + * [ $name2, $version2, $dependencies1, $group2, $source2, $skip2 ], * ... - * ) ): + * ] ): * Registers modules with the given names and parameters. * * @param string $name Module name @@ -1329,7 +1329,7 @@ MESSAGE; * - ResourceLoader::makeLoaderSourcesScript( $id, $properties ): * Register a single source * - * - ResourceLoader::makeLoaderSourcesScript( array( $id1 => $loadUrl, $id2 => $loadUrl, ... ) ); + * - ResourceLoader::makeLoaderSourcesScript( [ $id1 => $loadUrl, $id2 => $loadUrl, ... ] ); * Register sources with the given IDs and properties. * * @param string $id Source ID @@ -1388,26 +1388,27 @@ MESSAGE; * the given value. * * @param array $configuration List of configuration values keyed by variable name + * @param bool $pretty Pretty-print with extra whitespace * @return string */ - public static function makeConfigSetScript( array $configuration ) { + public static function makeConfigSetScript( array $configuration, $pretty = null ) { return Xml::encodeJsCall( 'mw.config.set', [ $configuration ], - ResourceLoader::inDebugMode() + ( $pretty === null ) ? ResourceLoader::inDebugMode() : $pretty ); } /** * Convert an array of module names to a packed query string. * - * For example, array( 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ) + * For example, [ 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ] * becomes 'foo.bar,baz|bar.baz,quux' * @param array $modules List of module names (strings) * @return string Packed query string */ public static function makePackedModulesString( $modules ) { - $groups = []; // array( prefix => array( suffixes ) ) + $groups = []; // [ prefix => [ suffixes ] ] foreach ( $modules as $module ) { $pos = strrpos( $module, '.' ); $prefix = $pos === false ? '' : substr( $module, 0, $pos ); @@ -1468,34 +1469,6 @@ MESSAGE; return wfAppendQuery( $script, $query ); } - /** - * Build a load.php URL - * @deprecated since 1.24 Use createLoaderURL() instead - * @param array $modules Array of module names (strings) - * @param string $lang Language code - * @param string $skin Skin name - * @param string|null $user User name. If null, the &user= parameter is omitted - * @param string|null $version Versioning timestamp - * @param bool $debug Whether the request should be in debug mode - * @param string|null $only &only= parameter - * @param bool $printable Printable mode - * @param bool $handheld Handheld mode - * @param array $extraQuery Extra query parameters to add - * @return string URL to load.php. May be protocol-relative if $wgLoadScript is, too. - */ - public static function makeLoaderURL( $modules, $lang, $skin, $user = null, - $version = null, $debug = false, $only = null, $printable = false, - $handheld = false, $extraQuery = [] - ) { - global $wgLoadScript; - - $query = self::makeLoaderQuery( $modules, $lang, $skin, $user, $version, $debug, - $only, $printable, $handheld, $extraQuery - ); - - return wfAppendQuery( $wgLoadScript, $query ); - } - /** * Helper for createLoaderURL() * @@ -1505,7 +1478,7 @@ MESSAGE; * @param array $extraQuery * @return array */ - public static function createLoaderQuery( ResourceLoaderContext $context, $extraQuery = [] ) { + protected static function createLoaderQuery( ResourceLoaderContext $context, $extraQuery = [] ) { return self::makeLoaderQuery( $context->getModules(), $context->getLanguage(), @@ -1522,7 +1495,7 @@ MESSAGE; /** * Build a query array (array representation of query string) for load.php. Helper - * function for makeLoaderURL(). + * function for createLoaderURL(). * * @param array $modules * @param string $lang @@ -1605,7 +1578,6 @@ MESSAGE; array_fill_keys( $this->config->get( 'ResourceLoaderLESSImportPaths' ), '' ) ); $parser->SetOption( 'relativeUrls', false ); - $parser->SetCacheDir( $this->config->get( 'CacheDirectory' ) ?: wfTempDir() ); return $parser; }