Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
HTMLSelectLanguageField.php
Go to the documentation of this file.
1<?php
2
3namespaceMediaWiki\HTMLForm\Field;
4
5useMediaWiki\HTMLForm\HTMLForm;
6useMediaWiki\MainConfigNames;
7useMediaWiki\MediaWikiServices;
8
14classHTMLSelectLanguageFieldextendsHTMLSelectField {
15
20publicfunction__construct( $params ) {
21 parent::__construct( $params );
22
23if ( $this->mParent instanceofHTMLForm ) {
24 $config = $this->mParent->getConfig();
25 $languageCode = $config->get(MainConfigNames::LanguageCode );
26 }else {
27 $languageCode =MediaWikiServices::getInstance()->getMainConfig()->get(
29 }
30
32 ->getLanguageNameUtils()
33 ->getLanguageNames();
34
35// Make sure the site language is in the list;
36// a custom language code might not have a defined name…
37if ( !array_key_exists( $languageCode, $languages ) ) {
38 $languages[$languageCode] = $languageCode;
39 }
40
41 ksort( $languages );
42
43foreach ( $languages as $code => $name ) {
44 $this->mParams['options'][$code .' - ' . $name] = $code;
45 }
46
47 $this->mParams['default'] ??= $languageCode;
48 }
49}
50
52class_alias( HTMLSelectLanguageField::class,'HTMLSelectLanguageField' );
MediaWiki\HTMLForm\Field\HTMLSelectField
A select dropdown field.
DefinitionHTMLSelectField.php:13
MediaWiki\HTMLForm\Field\HTMLSelectLanguageField
Language select field.
DefinitionHTMLSelectLanguageField.php:14
MediaWiki\HTMLForm\Field\HTMLSelectLanguageField\__construct
__construct( $params)
DefinitionHTMLSelectLanguageField.php:20
MediaWiki\HTMLForm\HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
DefinitionHTMLForm.php:195
MediaWiki\MainConfigNames
A class containing constants representing the names of configuration variables.
DefinitionMainConfigNames.php:22
MediaWiki\MainConfigNames\LanguageCode
const LanguageCode
Name constant for the LanguageCode setting, for use with Config::get()
DefinitionMainConfigNames.php:1802
MediaWiki\MediaWikiServices
Service locator for MediaWiki core services.
DefinitionMediaWikiServices.php:256
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
DefinitionMediaWikiServices.php:344
MediaWiki\HTMLForm\Field
DefinitionHTMLApiField.php:3

[8]ページ先頭

©2009-2025 Movatter.jp