MediaWiki  master
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 }
HTMLSelectLanguageField\__construct
__construct( $params)
Stable to call Initialise the object.Stable to call Associative Array. See HTMLForm doc for syntax....
Definition: HTMLSelectLanguageField.php:16
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:154
HTMLSelectField
A select dropdown field.
Definition: HTMLSelectField.php:8
HTMLSelectLanguageField
Language select field.
Definition: HTMLSelectLanguageField.php:10
$wgLanguageCode
$wgLanguageCode
Site language code.
Definition: DefaultSettings.php:3102
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition: HTMLForm.php:135