From dbcdc32293b6081d5fef37f6739b2887d2e26b65 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Thu, 9 Oct 2008 00:56:26 +0000 Subject: [PATCH] Make the {{ns:}} core parser function accept localized namespace names and aliases. Also change the output to use spaces instead of underscores so that it matches the output of {{NAMESPACE}} and related magic words. --- RELEASE-NOTES | 3 +++ includes/parser/CoreParserFunctions.php | 15 ++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 87523f46ae..dc897510e0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -158,6 +158,9 @@ The following extensions are migrated into MediaWiki 1.14: solutions such as CSS-based overlays and ImageMap. * (bug 368) Don't use caption for alt attribute; allow manual specification using new "alt=" parameter for images +* (bug 44) The {{ns:}} core parser function now also accepts localized namespace + names and aliases; also, its output now uses spaces instead of underscores to + match the behavior of the {{NAMESPACE}} magic word === Bug fixes in 1.14 === diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index c60b74cb7a..c49654467d 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -68,20 +68,13 @@ class CoreParserFunctions { static function ns( $parser, $part1 = '' ) { global $wgContLang; - $found = false; if ( intval( $part1 ) || $part1 == "0" ) { - $text = $wgContLang->getNsText( intval( $part1 ) ); - $found = true; + $index = intval( $part1 ); } else { - $param = str_replace( ' ', '_', strtolower( $part1 ) ); - $index = MWNamespace::getCanonicalIndex( strtolower( $param ) ); - if ( !is_null( $index ) ) { - $text = $wgContLang->getNsText( $index ); - $found = true; - } + $index = $wgContLang->getNsIndex( str_replace( ' ', '_', $part1 ) ); } - if ( $found ) { - return $text; + if ( $index !== false ) { + return $wgContLang->getFormattedNsText( $index ); } else { return array( 'found' => false ); } -- 2.20.1