/** * JavsScript selector for language codes. * @return JsSelectToInput */ protected static function languageSelector() { if (is_callable(array('LanguageNames', 'getNames'))) { $lang = RequestContext::getMain()->getLanguage(); $languages = LanguageNames::getNames($lang->getCode(), LanguageNames::FALLBACK_NORMAL); } else { $languages = Language::fetchLanguageNames(); } ksort($languages); $selector = new XmlSelect('mw-language-selector', 'mw-language-selector'); foreach ($languages as $code => $name) { $selector->addOption("{$code} - {$name}", $code); } $jsSelect = new JsSelectToInput($selector); $jsSelect->setSourceId('mw-language-selector'); return $jsSelect; }
/** * JavsScript selector for language codes. * @return \JsSelectToInput */ protected static function languageSelector() { global $wgLang; if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) { $languages = LanguageNames::getNames( $wgLang->getCode(), LanguageNames::FALLBACK_NORMAL ); } else { $languages = Language::getLanguageNames( false ); } ksort( $languages ); $selector = new XmlSelect( 'mw-language-selector', 'mw-language-selector' ); foreach ( $languages as $code => $name ) { $selector->addOption( "$code - $name", $code ); } $jsSelect = new JsSelectToInput( $selector ); $jsSelect->setSourceId( 'mw-language-selector' ); return $jsSelect; }
/** * Constructs a JavaScript enhanced group selector. * @return JsSelectToInput */ protected function groupSelector() { $groups = MessageGroups::singleton()->getGroups(); foreach ( $groups as $key => $group ) { if ( !$group->exists() ) { unset( $groups[$key] ); continue; } } ksort( $groups ); $selector = new XmlSelect( 'mw-group-selector', 'mw-group-selector' ); foreach ( $groups as $code => $name ) { $selector->addOption( $name->getLabel(), $code ); } $jsSelect = new JsSelectToInput( $selector ); $jsSelect->setSourceId( 'mw-group-selector' ); return $jsSelect; }