From: Daniel Werner Date: Thu, 14 Mar 2013 17:02:17 +0000 (+0100) Subject: Got rid of some global $wgContLang usage in SpecialAllpages X-Git-Tag: 1.31.0-rc.0~19967^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=751ffdb09695eb9c8160e61b5da4cfb993253cf5;p=lhc%2Fweb%2Fwiklou.git Got rid of some global $wgContLang usage in SpecialAllpages Using $this->getContext()->getLanguage() instead now. In SpecialAllpages::showline the global is still being used and a comment added. It could be argued about whether the content language or the user language should be used in that place. Also added some missing documentation to Language::getNamespaces. Change-Id: If511e2d9edb0f0092f3ca0ceadabd7fdb72f6c06 --- diff --git a/includes/specials/SpecialAllpages.php b/includes/specials/SpecialAllpages.php index 1e1a56a0d6..8c935204ae 100644 --- a/includes/specials/SpecialAllpages.php +++ b/includes/specials/SpecialAllpages.php @@ -71,7 +71,6 @@ class SpecialAllpages extends IncludableSpecialPage { * @param string $par becomes "FOO" when called like Special:Allpages/FOO (default NULL) */ function execute( $par ) { - global $wgContLang; $request = $this->getRequest(); $out = $this->getOutput(); @@ -85,7 +84,7 @@ class SpecialAllpages extends IncludableSpecialPage { $namespace = $request->getInt( 'namespace' ); $hideredirects = $request->getBool( 'hideredirects', false ); - $namespaces = $wgContLang->getNamespaces(); + $namespaces = $this->getContext()->getLanguage()->getNamespaces(); $out->setPageTitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) ) ? @@ -305,6 +304,7 @@ class SpecialAllpages extends IncludableSpecialPage { * @return string */ function showline( $inpoint, $outpoint, $namespace = NS_MAIN, $hideRedirects = false ) { + // Use content language since page titles are considered to use content language global $wgContLang; $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) ); $outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) ); @@ -341,12 +341,11 @@ class SpecialAllpages extends IncludableSpecialPage { * @param bool $hideredirects dont show redirects (default FALSE) */ function showChunk( $namespace = NS_MAIN, $from = false, $to = false, $hideredirects = false ) { - global $wgContLang; $output = $this->getOutput(); $fromList = $this->getNamespaceKeyAndText( $namespace, $from ); $toList = $this->getNamespaceKeyAndText( $namespace, $to ); - $namespaces = $wgContLang->getNamespaces(); + $namespaces = $this->getContext()->getLanguage()->getNamespaces(); $n = 0; if ( !$fromList || !$toList ) { diff --git a/languages/Language.php b/languages/Language.php index 416b1cfb34..73bcb95b7a 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -482,6 +482,9 @@ class Language { } /** + * Returns an array of localised namespaces indexed by their numbers. If the namespace is not + * available in localised form, it will be included in English. + * * @return array */ public function getNamespaces() {