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 $params[
'disabled'] = $this->
isDisabledNoJs( $this->mParent->mFieldData );
86 if ( isset( $this->mParams[
'default'] ) ) {
87 $params[
'default'] = $this->mParams[
'default'];
90 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
91 $this->
msg(
'mw-widgets-titlesmultiselect-placeholder' )->plain();
93 if ( isset( $this->mParams[
'max'] ) ) {
94 $params[
'tagLimit'] = $this->mParams[
'max'];
97 if ( isset( $this->mParams[
'input'] ) ) {
98 $params[
'input'] = $this->mParams[
'input'];
101 if ( isset( $this->mParams[
'allowEditTags'] ) ) {
102 $params[
'allowEditTags'] = $this->mParams[
'allowEditTags'];
105 if ( $value !==
null ) {
107 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
111 $params[
'infusable'] =
true;
112 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
114 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
126 return [
'mediawiki.widgets.NamespacesMultiselectWidget' ];
134 return $textAreaField->getInputCodex( $value, $hasErrors );
140class_alias( HTMLNamespacesMultiselectField::class,
'HTMLNamespacesMultiselectField' );