23 $value = $request->getText( $this->mName, $this->
getDefault() ??
'' );
25 $namespaces = explode(
"\n", $value );
27 $namespaces = array_values( array_filter( $namespaces,
static function ( $namespace ) {
28 return trim( $namespace ) !==
'';
31 return implode(
"\n", $namespaces );
36 if ( !$this->mParams[
'exists'] || $value ===
'' ) {
40 if ( $value ===
null ) {
45 $namespaces = explode(
"\n", $value );
47 if ( isset( $this->mParams[
'max'] ) && ( count( $namespaces ) > $this->mParams[
'max'] ) ) {
48 return $this->
msg(
'htmlform-multiselect-toomany', $this->mParams[
'max'] );
51 foreach ( $namespaces as $namespace ) {
56 return $this->
msg(
'htmlform-select-badoption' );
59 $result = parent::validate( $namespace, $alldata );
60 if ( $result !==
true ) {
70 $this->mParent->getOutput()->enableOOUI();
76 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.TagMultiselectWidget.styles' );
84 if ( isset( $this->mParams[
'disabled'] ) ) {
85 $params[
'disabled'] = $this->mParams[
'disabled'];
88 if ( isset( $this->mParams[
'default'] ) ) {
89 $params[
'default'] = $this->mParams[
'default'];
92 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
93 $this->
msg(
'mw-widgets-titlesmultiselect-placeholder' )->plain();
95 if ( isset( $this->mParams[
'max'] ) ) {
96 $params[
'tagLimit'] = $this->mParams[
'max'];
99 if ( isset( $this->mParams[
'input'] ) ) {
100 $params[
'input'] = $this->mParams[
'input'];
103 if ( isset( $this->mParams[
'allowEditTags'] ) ) {
104 $params[
'allowEditTags'] = $this->mParams[
'allowEditTags'];
107 if ( $value !==
null ) {
109 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
113 $params[
'infusable'] =
true;
114 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
116 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
128 return [
'mediawiki.widgets.NamespacesMultiselectWidget' ];
136 return $textAreaField->getInputCodex( $value, $hasErrors );
142class_alias( HTMLNamespacesMultiselectField::class,
'HTMLNamespacesMultiselectField' );