Revert r90232.
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderStartUpModule.php
index b63d4df..a7c15a2 100644 (file)
@@ -35,9 +35,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
        protected function getConfig( $context ) {
                global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
                        $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
-                       $wgVariantArticlePath, $wgActionPaths, $wgUseAjax,
+                       $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, 
                        $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest,
-                       $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgProto,
+                       $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
                        $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgLegacyJavaScriptGlobals;
 
                // Pre-process information
@@ -55,6 +55,17 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                );
                $mainPage = Title::newMainPage();
 
+               // Build wgNamespaceIds
+               // A complete key-value pair object mapping localized, canonical and aliases for namespaces
+               // to their numerical ids (case insensitive and with underscores)
+               $namespaceIds = $wgContLang->getNamespaceIds();
+               foreach( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
+                       $namespaceIds[$wgContLang->lc( $name )] = $index;
+               }
+
+               $serverBits = wfParseUrl( $wgServer );
+               $protocol = $serverBits ? $serverBits['scheme'] : 'http';
+
                // Build list of variables
                $vars = array(
                        'wgLoadScript' => $wgLoadScript,
@@ -71,7 +82,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgServer' => $wgServer,
                        'wgUserLanguage' => $context->getLanguage(),
                        'wgContentLanguage' => $wgContLang->getCode(),
-                       'wgVersion' => MW_VERSION,
+                       'wgVersion' => $wgVersion,
                        'wgEnableAPI' => $wgEnableAPI,
                        'wgEnableWriteAPI' => $wgEnableWriteAPI,
                        'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(),
@@ -81,7 +92,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgDigitTransformTable' => $compactDigitTransTable,
                        'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
                        'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
-                       'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
+                       'wgNamespaceIds' => $namespaceIds,
                        'wgSiteName' => $wgSitename,
                        'wgFileExtensions' => array_values( $wgFileExtensions ),
                        'wgDBname' => $wgDBname,
@@ -90,7 +101,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgFileCanRotate' => BitmapHandler::canRotate(),
                        'wgAvailableSkins' => Skin::getSkinNames(),
                        'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
-                       'wgProto' => $wgProto,
+                       'wgProto' => $protocol,
                        // MediaWiki sets cookies to have this prefix by default
                        'wgCookiePrefix' => $wgCookiePrefix,
                        'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
@@ -162,6 +173,10 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
 
        /* Methods */
 
+       /**
+        * @param $context ResourceLoaderContext
+        * @return string
+        */
        public function getScript( ResourceLoaderContext $context ) {
                global $IP, $wgLoadScript, $wgLegacyJavaScriptGlobals;
 
@@ -181,7 +196,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        }
                        // Build load query for StartupModules 
                        $query = array(
-                               'modules' => implode( '|',  $modules ),
+                               'modules' => ResourceLoader::makePackedModulesString( $modules ),
                                'only' => 'scripts',
                                'lang' => $context->getLanguage(),
                                'skin' => $context->getSkin(),
@@ -211,6 +226,10 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                return $out;
        }
 
+       /**
+        * @param $context ResourceLoaderContext
+        * @return array|mixed
+        */
        public function getModifiedTime( ResourceLoaderContext $context ) {
                global $IP, $wgCacheEpoch;
 
@@ -235,10 +254,13 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                }
                return $this->modifiedTime[$hash] = $time;
        }
-       
+
        /* Methods */
-       
+
+       /**
+        * @return string
+        */
        public function getGroup() {
                return 'startup';
        }
-}
+}
\ No newline at end of file