MediaWiki REL1_34
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
18 $languages = Language::fetchLanguageNames( null, 'mw' );
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}
$wgLanguageCode
Site language code.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:131
A select dropdown field.
__construct( $params)
Initialise the object.
switch( $options['output']) $languages
Definition transstat.php:76