This edition brought to you by: grep -ERIn $(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | tr "\n" '|' | sed 's/|$/\n/') includes/ I only corrected a fraction of the results provided by that command. I'm submitting the partial patch now so it doesn't bitrot. Bug: T305805 Change-Id: If1918c0b3d88cdf90403921e4310740e206d6962
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MainConfigNames;
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* Language select field.
|
|
*
|
|
* @stable to extend
|
|
*/
|
|
class HTMLSelectLanguageField extends HTMLSelectField {
|
|
|
|
/**
|
|
* @stable to call
|
|
* @inheritDoc
|
|
*/
|
|
public function __construct( $params ) {
|
|
parent::__construct( $params );
|
|
|
|
if ( $this->mParent instanceof HTMLForm ) {
|
|
$config = $this->mParent->getConfig();
|
|
$languageCode = $config->get( MainConfigNames::LanguageCode );
|
|
} else {
|
|
$languageCode = MediaWikiServices::getInstance()->getMainConfig()->get(
|
|
MainConfigNames::LanguageCode );
|
|
}
|
|
|
|
$languages = MediaWikiServices::getInstance()
|
|
->getLanguageNameUtils()
|
|
->getLanguageNames();
|
|
|
|
// Make sure the site language is in the list;
|
|
// a custom language code might not have a defined name…
|
|
if ( !array_key_exists( $languageCode, $languages ) ) {
|
|
$languages[$languageCode] = $languageCode;
|
|
}
|
|
|
|
ksort( $languages );
|
|
|
|
foreach ( $languages as $code => $name ) {
|
|
$this->mParams['options'][$code . ' - ' . $name] = $code;
|
|
}
|
|
|
|
if ( !array_key_exists( 'default', $params ) ) {
|
|
$this->mParams['default'] = $languageCode;
|
|
}
|
|
}
|
|
}
|