<?php
+/**
+ * Methods to generate XML.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
/**
* Module of static functions for generating XML
*/
-
class Xml {
/**
* Format an XML element with given attributes and, optionally, text content.
*
* @param string $selected The language code of the selected language
* @param boolean $customisedOnly If true only languages which have some content are listed
- * @param string $language The ISO code of the language to display the select list in (optional)
+ * @param string $inLanguage The ISO code of the language to display the select list in (optional)
* @return array containing 2 items: label HTML and select list HTML
*/
- public static function languageSelector( $selected, $customisedOnly = true, $language = null ) {
+ public static function languageSelector( $selected, $customisedOnly = true, $inLanguage = null ) {
global $wgLanguageCode;
- // If a specific language was requested and CLDR is installed, use it
- if ( $language && is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
- if ( $customisedOnly ) {
- $listType = LanguageNames::LIST_MW_SUPPORTED; // Only pull names that have localisation in MediaWiki
- } else {
- $listType = LanguageNames::LIST_MW; // Pull all languages that are in Names.php
- }
- // Retrieve the list of languages in the requested language (via CLDR)
- $languages = LanguageNames::getNames(
- $language, // Code of the requested language
- LanguageNames::FALLBACK_NORMAL, // Use fallback chain
- $listType
- );
- } else {
- $languages = Language::getLanguageNames( $customisedOnly );
- }
-
+ $languages = Language::fetchLanguageNames( $inLanguage, $customisedOnly ? 'mwfile' : 'mw' );
+
// Make sure the site language is in the list; a custom language code might not have a
// defined name...
if( !array_key_exists( $wgLanguageCode, $languages ) ) {
$languages[$wgLanguageCode] = $wgLanguageCode;
}
-
+
ksort( $languages );
/**