summaryrefslogtreecommitdiff
path: root/includes/resourceloader/ResourceLoaderStartUpModule.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /includes/resourceloader/ResourceLoaderStartUpModule.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'includes/resourceloader/ResourceLoaderStartUpModule.php')
-rw-r--r--includes/resourceloader/ResourceLoaderStartUpModule.php54
1 files changed, 28 insertions, 26 deletions
diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php
index 5dbce439..20ee83f9 100644
--- a/includes/resourceloader/ResourceLoaderStartUpModule.php
+++ b/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -1,5 +1,7 @@
<?php
/**
+ * Module for resource loader initialization.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -35,8 +37,8 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
protected function getConfig( $context ) {
global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
$wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
- $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion,
- $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest,
+ $wgVariantArticlePath, $wgActionPaths, $wgVersion,
+ $wgEnableAPI, $wgEnableWriteAPI, $wgDBname,
$wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
$wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
@@ -77,10 +79,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
'wgVersion' => $wgVersion,
'wgEnableAPI' => $wgEnableAPI,
'wgEnableWriteAPI' => $wgEnableWriteAPI,
- 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(),
- 'wgMonthNames' => $wgContLang->getMonthNamesArray(),
- 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(),
- 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
+ 'wgMainPageTitle' => $mainPage->getPrefixedText(),
'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
'wgNamespaceIds' => $namespaceIds,
'wgSiteName' => $wgSitename,
@@ -96,9 +95,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
);
- if ( $wgUseAjax && $wgEnableMWSuggest ) {
- $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
- }
wfRunHooks( 'ResourceLoaderGetConfigVars', array( &$vars ) );
@@ -125,12 +121,12 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
// Register modules
foreach ( $resourceLoader->getModuleNames() as $name ) {
$module = $resourceLoader->getModule( $name );
+ $deps = $module->getDependencies();
+ $group = $module->getGroup();
+ $source = $module->getSource();
// Support module loader scripts
$loader = $module->getLoaderScript();
if ( $loader !== false ) {
- $deps = $module->getDependencies();
- $group = $module->getGroup();
- $source = $module->getSource();
$version = wfTimestamp( TS_ISO_8601_BASIC,
$module->getModifiedTime( $context ) );
$out .= ResourceLoader::makeCustomLoaderScript( $name, $version, $deps, $group, $source, $loader );
@@ -143,26 +139,23 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
$mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
// Modules without dependencies, a group or a foreign source pass two arguments (name, timestamp) to
// mw.loader.register()
- if ( !count( $module->getDependencies() && $module->getGroup() === null && $module->getSource() === 'local' ) ) {
+ if ( !count( $deps ) && $group === null && $source === 'local' ) {
$registrations[] = array( $name, $mtime );
}
// Modules with dependencies but no group or foreign source pass three arguments
// (name, timestamp, dependencies) to mw.loader.register()
- elseif ( $module->getGroup() === null && $module->getSource() === 'local' ) {
- $registrations[] = array(
- $name, $mtime, $module->getDependencies() );
+ elseif ( $group === null && $source === 'local' ) {
+ $registrations[] = array( $name, $mtime, $deps );
}
// Modules with a group but no foreign source pass four arguments (name, timestamp, dependencies, group)
// to mw.loader.register()
- elseif ( $module->getSource() === 'local' ) {
- $registrations[] = array(
- $name, $mtime, $module->getDependencies(), $module->getGroup() );
+ elseif ( $source === 'local' ) {
+ $registrations[] = array( $name, $mtime, $deps, $group );
}
// Modules with a foreign source pass five arguments (name, timestamp, dependencies, group, source)
// to mw.loader.register()
else {
- $registrations[] = array(
- $name, $mtime, $module->getDependencies(), $module->getGroup(), $module->getSource() );
+ $registrations[] = array( $name, $mtime, $deps, $group, $source );
}
}
}
@@ -175,6 +168,13 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
/* Methods */
/**
+ * @return bool
+ */
+ public function isRaw() {
+ return true;
+ }
+
+ /**
* @param $context ResourceLoaderContext
* @return string
*/
@@ -185,19 +185,20 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
if ( $context->getOnly() === 'scripts' ) {
// The core modules:
- $modules = array( 'jquery', 'mediawiki' );
- wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$modules ) );
+ $moduleNames = array( 'jquery', 'mediawiki' );
+ wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$moduleNames ) );
// Get the latest version
+ $loader = $context->getResourceLoader();
$version = 0;
- foreach ( $modules as $moduleName ) {
+ foreach ( $moduleNames as $moduleName ) {
$version = max( $version,
- $context->getResourceLoader()->getModule( $moduleName )->getModifiedTime( $context )
+ $loader->getModule( $moduleName )->getModifiedTime( $context )
);
}
// Build load query for StartupModules
$query = array(
- 'modules' => ResourceLoader::makePackedModulesString( $modules ),
+ 'modules' => ResourceLoader::makePackedModulesString( $moduleNames ),
'only' => 'scripts',
'lang' => $context->getLanguage(),
'skin' => $context->getSkin(),
@@ -210,6 +211,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
// Startup function
$configuration = $this->getConfig( $context );
$registrations = self::getModuleRegistrations( $context );
+ $registrations = str_replace( "\n", "\n\t", trim( $registrations ) ); // fix indentation
$out .= "var startUp = function() {\n" .
"\tmw.config = new " . Xml::encodeJsCall( 'mw.Map', array( $wgLegacyJavaScriptGlobals ) ) . "\n" .
"\t$registrations\n" .