(bug 29441) Expose CapitalLinks config in JS to allow modules to properly handle...
authorKrinkle <krinkle@users.mediawiki.org>
Thu, 16 Jun 2011 21:20:05 +0000 (21:20 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Thu, 16 Jun 2011 21:20:05 +0000 (21:20 +0000)
This brings us one step closer towards:
(bug 29397) Implement mw.Title module in core

includes/resourceloader/ResourceLoaderStartUpModule.php

index a7c15a2..8ce592e 100644 (file)
@@ -55,14 +55,21 @@ 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)
+               /**
+                * Namespace related preparation
+                * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
+                * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
+                */
                $namespaceIds = $wgContLang->getNamespaceIds();
+               $caseSensitiveNamespaces = array();
                foreach( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
                        $namespaceIds[$wgContLang->lc( $name )] = $index;
+                       if ( !MWNamespace::isCapitalized( $index ) ) {
+                               $caseSensitiveNamespaces[] = $index;
+                       }
                }
 
+
                $serverBits = wfParseUrl( $wgServer );
                $protocol = $serverBits ? $serverBits['scheme'] : 'http';
 
@@ -106,6 +113,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgCookiePrefix' => $wgCookiePrefix,
                        'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
                        'wgLegacyJavaScriptGlobals' => $wgLegacyJavaScriptGlobals,
+                       'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
                );
                if ( $wgUseAjax && $wgEnableMWSuggest ) {
                        $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
@@ -263,4 +271,4 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
        public function getGroup() {
                return 'startup';
        }
-}
\ No newline at end of file
+}