Got rid of some global $wgContLang usage in SpecialAllpages
authorDaniel Werner <daniel.werner@wikimedia.de>
Thu, 14 Mar 2013 17:02:17 +0000 (18:02 +0100)
committerMarius Hoch <hoo@online.de>
Wed, 17 Apr 2013 19:32:31 +0000 (21:32 +0200)
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

includes/specials/SpecialAllpages.php
languages/Language.php

index 1e1a56a..8c93520 100644 (file)
@@ -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 ) {
index 416b1cf..73bcb95 100644 (file)
@@ -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() {