$dependencies = null, $group = null )
{
if ( is_array( $name ) ) {
- return Xml::encodeJsCall( 'mediaWiki.loader.register', array( $name ) );
+ return Xml::encodeJsCall( 'mw.loader.register', array( $name ) );
} else {
$version = (int) $version > 1 ? (int) $version : 1;
- return Xml::encodeJsCall( 'mediaWiki.loader.register',
+ return Xml::encodeJsCall( 'mw.loader.register',
array( $name, $version, $dependencies, $group ) );
}
}
* @param $configuration Array: List of configuration values keyed by variable name
*/
public static function makeConfigSetScript( array $configuration ) {
- return Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) );
+ return Xml::encodeJsCall( 'mw.config.set', array( $configuration ) );
}
/**
* @return array
*/
protected function getConfig( $context ) {
- global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
- $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
+ global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
+ $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
$wgVariantArticlePath, $wgActionPaths, $wgUseAjax,
- $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest,
+ $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest,
$wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgProto,
- $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
+ $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgLegacyJavaScriptGlobals;
// Pre-process information
$separatorTransTable = $wgContLang->separatorTransformTable();
'wgSiteName' => $wgSitename,
'wgFileExtensions' => array_values( $wgFileExtensions ),
'wgDBname' => $wgDBname,
- // This sucks, it is only needed on Special:Upload, but I could
+ // This sucks, it is only needed on Special:Upload, but I could
// not find a way to add vars only for a certain module
'wgFileCanRotate' => BitmapHandler::canRotate(),
'wgAvailableSkins' => Skin::getSkinNames(),
'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
'wgProto' => $wgProto,
- // mediawiki sets cookies to have this prefix by default
+ // MediaWiki sets cookies to have this prefix by default
'wgCookiePrefix' => $wgCookiePrefix,
'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
+ 'wgLegacyJavaScriptGlobals' => $wgLegacyJavaScriptGlobals,
);
if ( $wgUseAjax && $wgEnableMWSuggest ) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
/* Methods */
public function getScript( ResourceLoaderContext $context ) {
- global $IP, $wgLoadScript;
+ global $IP, $wgLoadScript, $wgLegacyJavaScriptGlobals;
$out = file_get_contents( "$IP/resources/startup.js" );
if ( $context->getOnly() === 'scripts' ) {
);
// Ensure uniform query order
ksort( $query );
-
+
// Startup function
$configuration = $this->getConfig( $context );
$registrations = self::getModuleRegistrations( $context );
- $out .= "var startUp = function() {\n" .
- "\t$registrations\n" .
- "\t" . Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ) .
+ $out .= "var startUp = function() {\n" .
+ "\tmw.config = new " . Xml::encodeJsCall( 'mw.Map', array( $wgLegacyJavaScriptGlobals ) ) . "\n" .
+ "\t$registrations\n" .
+ "\t" . Xml::encodeJsCall( 'mw.config.set', array( $configuration ) ) .
"};\n";
-
+
// Conditional script injection
$scriptTag = Html::linkedScript( $wgLoadScript . '?' . wfArrayToCGI( $query ) );
- $out .= "if ( isCompatible() ) {\n" .
- "\t" . Xml::encodeJsCall( 'document.write', array( $scriptTag ) ) .
- "}\n" .
+ $out .= "if ( isCompatible() ) {\n" .
+ "\t" . Xml::encodeJsCall( 'document.write', array( $scriptTag ) ) .
+ "}\n" .
"delete isCompatible;";
}