3 namespace MediaWiki\HTMLForm\Field
;
5 use MediaWiki\Html\Html
;
6 use MediaWiki\HTMLForm\HTMLFormField
;
9 * Wrapper for Html::namespaceSelector to use in HTMLForm
13 class HTMLSelectNamespace
extends HTMLFormField
{
15 /** @var string|null */
19 /** @var int[]|null */
26 public function __construct( $params ) {
27 parent
::__construct( $params );
29 $this->mAllValue
= array_key_exists( 'all', $params )
32 $this->mUserLang
= array_key_exists( 'in-user-lang', $params )
33 ?
$params['in-user-lang']
36 $this->mInclude
= array_key_exists( 'include', $params )
45 public function getInputHTML( $value ) {
46 return Html
::namespaceSelector(
49 'all' => $this->mAllValue
,
50 'in-user-lang' => $this->mUserLang
,
51 'include' => $this->mInclude
53 'name' => $this->mName
,
55 'class' => 'namespaceselector',
64 public function getInputOOUI( $value ) {
65 return new \MediaWiki\Widget\
NamespaceInputWidget( [
67 'name' => $this->mName
,
69 'includeAllValue' => $this->mAllValue
,
70 'userLang' => $this->mUserLang
,
71 'include' => $this->mInclude
,
79 public function getInputCodex( $value, $hasErrors ) {
81 'all' => $this->mAllValue
,
82 'in-user-lang' => $this->mUserLang
84 $select = new HTMLSelectField( [
85 'options' => array_flip( Html
::namespaceSelectorOptions( $optionParams ) )
87 return $select->getInputCodex( $value, $hasErrors );
94 protected function getOOUIModules() {
95 // FIXME: NamespaceInputWidget should be in its own module (probably?)
96 return [ 'mediawiki.widgets' ];
101 * @stable to override
103 protected function shouldInfuseOOUI() {
108 /** @deprecated class alias since 1.42 */
109 class_alias( HTMLSelectNamespace
::class, 'HTMLSelectNamespace' );