/**
* 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 = [];
$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' ) );
*
* 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
/**
* 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;
* - 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
* ):
* 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
* - 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
* 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 );
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()
*
* @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(),
/**
* 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
array_fill_keys( $this->config->get( 'ResourceLoaderLESSImportPaths' ), '' )
);
$parser->SetOption( 'relativeUrls', false );
- $parser->SetCacheDir( $this->config->get( 'CacheDirectory' ) ?: wfTempDir() );
return $parser;
}