reapply r21363, hopefully without stupid notices this time
authorIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 19 Apr 2007 18:47:04 +0000 (18:47 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 19 Apr 2007 18:47:04 +0000 (18:47 +0000)
includes/Title.php
languages/Language.php

index d7b29ec..531944a 100644 (file)
@@ -1645,12 +1645,7 @@ class Title {
                        $m = array();
                        if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $dbkey, $m ) ) {
                                $p = $m[1];
-                               $lowerNs = $wgContLang->lc( $p );
-                               if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) {
-                                       # Canonical namespace
-                                       $dbkey = $m[2];
-                                       $this->mNamespace = $ns;
-                               } elseif ( $ns = $wgContLang->getNsIndex( $lowerNs )) {
+                               if ( $ns = $wgContLang->getNsIndex( $p )) {
                                        # Ordinary namespace
                                        $dbkey = $m[2];
                                        $this->mNamespace = $ns;
index 4f21791..1eb09b6 100644 (file)
@@ -228,7 +228,22 @@ class Language {
        }
 
        /**
-        * Get a namespace key by value, case insensetive.
+        * Get a namespace key by value, case insensitive.
+        * Only matches namespace names for the current language, not the
+        * canonical ones defined in Namespace.php.
+        *
+        * @param string $text
+        * @return mixed An integer if $text is a valid value otherwise false
+        */
+       function getLocalNsIndex( $text ) {
+               $this->load();
+               $lctext = $this->lc($text);
+               return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
+       }
+
+       /**
+        * Get a namespace key by value, case insensitive.  Canonical namespace
+        * names override custom ones defined for the current language.
         *
         * @param string $text
         * @return mixed An integer if $text is a valid value otherwise false
@@ -236,6 +251,7 @@ class Language {
        function getNsIndex( $text ) {
                $this->load();
                $lctext = $this->lc($text);
+               if( ( $ns = Namespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
                return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
        }