MediaWiki  master
HTMLSelectLanguageField.php
Go to the documentation of this file.
1 <?php
2 
7  public function __construct( $params ) {
8  parent::__construct( $params );
9 
10  if ( $this->mParent instanceof HTMLForm ) {
11  $config = $this->mParent->getConfig();
12  $languageCode = $config->get( 'LanguageCode' );
13  } else {
14  global $wgLanguageCode;
15  $languageCode = $wgLanguageCode;
16  }
17 
19 
20  // Make sure the site language is in the list;
21  // a custom language code might not have a defined nameā€¦
22  if ( !array_key_exists( $languageCode, $languages ) ) {
23  $languages[$languageCode] = $languageCode;
24  }
25 
26  ksort( $languages );
27 
28  foreach ( $languages as $code => $name ) {
29  $this->mParams['options'][$code . ' - ' . $name] = $code;
30  }
31 
32  if ( !array_key_exists( 'default', $params ) ) {
33  $this->mParams['default'] = $languageCode;
34  }
35  }
36 }
static fetchLanguageNames( $inLanguage=self::AS_AUTONYMS, $include='mw')
Get an array of language names, indexed by code.
Definition: Language.php:814
A select dropdown field.
Language select field.
$wgLanguageCode
Site language code.
switch( $options['output']) $languages
Definition: transstat.php:76