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