$wgEnableAPI, $wgEnableWriteAPI, $wgDBname,
$wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
$wgCookiePrefix, $wgResourceLoaderMaxQueryLength,
- $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion;
+ $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion,
+ $wgSearchType;
$mainPage = Title::newMainPage();
'wgScriptPath' => $wgScriptPath,
'wgScriptExtension' => $wgScriptExtension,
'wgScript' => $wgScript,
+ 'wgSearchType' => $wgSearchType,
'wgVariantArticlePath' => $wgVariantArticlePath,
// Force object to avoid "empty" associative array from
// becoming [] instead of {} in JS (bug 34604)
// seem to do that, and custom implementations might forget. Coerce it to TS_UNIX
$moduleMtime = wfTimestamp( TS_UNIX, $module->getModifiedTime( $context ) );
$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( $deps ) && $group === null && $source === 'local' ) {
+ // Modules without dependencies, a group or a foreign source pass two arguments (name, timestamp) to
+ // mw.loader.register()
$registrations[] = array( $name, $mtime );
- }
- // Modules with dependencies but no group or foreign source pass three arguments
- // (name, timestamp, dependencies) to mw.loader.register()
- elseif ( $group === null && $source === 'local' ) {
+ } elseif ( $group === null && $source === 'local' ) {
+ // Modules with dependencies but no group or foreign source pass three arguments
+ // (name, timestamp, dependencies) to mw.loader.register()
$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 ( $source === 'local' ) {
+ } elseif ( $source === 'local' ) {
+ // Modules with a group but no foreign source pass four arguments (name, timestamp, dependencies, group)
+ // to mw.loader.register()
$registrations[] = array( $name, $mtime, $deps, $group );
- }
- // Modules with a foreign source pass five arguments (name, timestamp, dependencies, group, source)
- // to mw.loader.register()
- else {
+ } else {
+ // Modules with a foreign source pass five arguments (name, timestamp, dependencies, group, source)
+ // to mw.loader.register()
$registrations[] = array( $name, $mtime, $deps, $group, $source );
}
}
return true;
}
+ /**
+ * Get the load URL of the startup modules.
+ *
+ * This is a helper for getScript(), but can also be called standalone, such
+ * as when generating an AppCache manifest.
+ *
+ * @param $context ResourceLoaderContext
+ * @return string
+ */
+ public static function getStartupModulesUrl( ResourceLoaderContext $context ) {
+ // The core modules:
+ $moduleNames = array( 'jquery', 'mediawiki' );
+ wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$moduleNames ) );
+
+ // Get the latest version
+ $loader = $context->getResourceLoader();
+ $version = 0;
+ foreach ( $moduleNames as $moduleName ) {
+ $version = max( $version,
+ $loader->getModule( $moduleName )->getModifiedTime( $context )
+ );
+ }
+
+ $query = array(
+ 'modules' => ResourceLoader::makePackedModulesString( $moduleNames ),
+ 'only' => 'scripts',
+ 'lang' => $context->getLanguage(),
+ 'skin' => $context->getSkin(),
+ 'debug' => $context->getDebug() ? 'true' : 'false',
+ 'version' => wfTimestamp( TS_ISO_8601_BASIC, $version )
+ );
+ // Ensure uniform query order
+ ksort( $query );
+ return wfAppendQuery( wfScript( 'load' ), $query );
+ }
+
/**
* @param $context ResourceLoaderContext
* @return string
$out = file_get_contents( "$IP/resources/startup.js" );
if ( $context->getOnly() === 'scripts' ) {
- // The core modules:
- $moduleNames = array( 'jquery', 'mediawiki' );
- wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$moduleNames ) );
-
- // Get the latest version
- $loader = $context->getResourceLoader();
- $version = 0;
- foreach ( $moduleNames as $moduleName ) {
- $version = max( $version,
- $loader->getModule( $moduleName )->getModifiedTime( $context )
- );
- }
- // Build load query for StartupModules
- $query = array(
- 'modules' => ResourceLoader::makePackedModulesString( $moduleNames ),
- 'only' => 'scripts',
- 'lang' => $context->getLanguage(),
- 'skin' => $context->getSkin(),
- 'debug' => $context->getDebug() ? 'true' : 'false',
- 'version' => wfTimestamp( TS_ISO_8601_BASIC, $version )
- );
- // Ensure uniform query order
- ksort( $query );
-
// Startup function
$configuration = $this->getConfig( $context );
$registrations = self::getModuleRegistrations( $context );
"};\n";
// Conditional script injection
- $scriptTag = Html::linkedScript( wfAppendQuery( wfScript( 'load' ), $query ) );
+ $scriptTag = Html::linkedScript( self::getStartupModulesUrl( $context ) );
$out .= "if ( isCompatible() ) {\n" .
"\t" . Xml::encodeJsCall( 'document.write', array( $scriptTag ) ) .
"}\n" .