MediaWiki REL1_37
HTMLSelectLanguageField.php
Go to the documentation of this file.
1<?php
2
4
11
16 public function __construct( $params ) {
17 parent::__construct( $params );
18
19 if ( $this->mParent instanceof HTMLForm ) {
20 $config = $this->mParent->getConfig();
21 $languageCode = $config->get( 'LanguageCode' );
22 } else {
23 global $wgLanguageCode;
24 $languageCode = $wgLanguageCode;
25 }
26
27 $languages = MediaWikiServices::getInstance()
28 ->getLanguageNameUtils()
29 ->getLanguageNames( null, 'mw' );
30
31 // Make sure the site language is in the list;
32 // a custom language code might not have a defined nameā€¦
33 if ( !array_key_exists( $languageCode, $languages ) ) {
34 $languages[$languageCode] = $languageCode;
35 }
36
37 ksort( $languages );
38
39 foreach ( $languages as $code => $name ) {
40 $this->mParams['options'][$code . ' - ' . $name] = $code;
41 }
42
43 if ( !array_key_exists( 'default', $params ) ) {
44 $this->mParams['default'] = $languageCode;
45 }
46 }
47}
$wgLanguageCode
Site language code.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:143
A select dropdown field.
MediaWikiServices is the service locator for the application scope of MediaWiki.