Follow-up r112479
authorRobin Pepermans <robin@users.mediawiki.org>
Thu, 8 Mar 2012 19:30:30 +0000 (19:30 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Thu, 8 Mar 2012 19:30:30 +0000 (19:30 +0000)
* Add @since, fix indentation.
* Change default from 'all' to 'mw' as it's the most used (so default fetchLanguageNames() is equivalent to default getLanguageNames()).
* Add the include parameter also to fetchLanguageName() as it's needed in Parser: interlanguage links should only take into account mediawiki names. (Doesn't make a difference with how the functions are now, but could have been later.)

includes/parser/Parser.php
languages/Language.php

index de71d29..1be509c 100644 (file)
@@ -1901,11 +1901,9 @@ class Parser {
 
                        # Link not escaped by : , create the various objects
                        if ( $noforce ) {
-                               global $wgContLang;
-
                                # Interwikis
                                wfProfileIn( __METHOD__."-interwiki" );
-                               if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName( $iw ) ) {
+                               if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' ) ) {
                                        $this->mOutput->addLanguageLink( $nt->getFullText() );
                                        $s = rtrim( $s . $prefix );
                                        $s .= trim( $trail, "\n" ) == '' ? '': $prefix . $trail;
index 3a25dfc..854a9f1 100644 (file)
@@ -682,14 +682,15 @@ class Language {
        /**
         * Get an array of language names, indexed by code.
         * @param $inLanguage null|string: Code of language in which to return the names
-        *                                                                      Use null for autonyms (native names)
+        *              Use null for autonyms (native names)
         * @param $include string:
         *              'all' all available languages
         *              'mw' only if the language is defined in MediaWiki or wgExtraLanguageNames
         *              'mwfile' only if the language is in 'mw' *and* has a message file
         * @return array|bool: language code => language name, false if $include is wrong
+        * @since 1.20
         */
-       public static function fetchLanguageNames( $inLanguage = null, $include = 'all' ) {
+       public static function fetchLanguageNames( $inLanguage = null, $include = 'mw' ) {
                global $wgExtraLanguageNames;
                static $coreLanguageNames;
 
@@ -743,11 +744,12 @@ class Language {
        /**
         * @param $code string: The code of the language for which to get the name
         * @param $inLanguage null|string: Code of language in which to return the name (null for autonyms)
+        * @param $include string: 'all', 'mw' or 'mwfile'; see fetchLanguageNames()
         * @return string: Language name or empty
         * @since 1.20
         */
-       public static function fetchLanguageName( $code, $inLanguage = null ) {
-               $array = self::fetchLanguageNames( $inLanguage, 'all' );
+       public static function fetchLanguageName( $code, $inLanguage = null, $include = 'all' ) {
+               $array = self::fetchLanguageNames( $inLanguage, $include );
                return !array_key_exists( $code, $array ) ? '' : $array[$code];
        }