MediaWiki  1.34.0
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 }
HTMLSelectLanguageField\__construct
__construct( $params)
Initialise the object.
Definition: HTMLSelectLanguageField.php:7
$languages
switch( $options['output']) $languages
Definition: transstat.php:76
HTMLSelectField
A select dropdown field.
Definition: HTMLSelectField.php:6
HTMLSelectLanguageField
Language select field.
Definition: HTMLSelectLanguageField.php:6
$wgLanguageCode
$wgLanguageCode
Site language code.
Definition: DefaultSettings.php:2948
Language\fetchLanguageNames
static fetchLanguageNames( $inLanguage=self::AS_AUTONYMS, $include='mw')
Get an array of language names, indexed by code.
Definition: Language.php:818
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition: HTMLForm.php:131