36 parent::__construct( $params );
41 $value = $request->getText( $this->mName, $this->
getDefault() ??
'' );
43 $titlesArray = explode(
"\n", $value );
45 $titlesArray = array_values( array_filter( $titlesArray,
static function ( $title ) {
46 return trim( $title ) !==
'';
49 return implode(
"\n", $titlesArray );
54 if ( !$this->mParams[
'exists'] ) {
58 if ( $value ===
null ) {
63 $titlesArray = explode(
"\n", $value );
65 if ( isset( $this->mParams[
'max'] ) && ( count( $titlesArray ) > $this->mParams[
'max'] ) ) {
66 return $this->
msg(
'htmlform-multiselect-toomany', $this->mParams[
'max'] );
69 foreach ( $titlesArray as $title ) {
70 $result = parent::validate( $title, $alldata );
71 if ( $result !==
true ) {
81 $this->mParent->getOutput()->enableOOUI();
87 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.TagMultiselectWidget.styles' );
95 if ( isset( $this->mParams[
'disabled'] ) ) {
96 $params[
'disabled'] = $this->mParams[
'disabled'];
99 if ( isset( $this->mParams[
'default'] ) ) {
100 $params[
'default'] = $this->mParams[
'default'];
103 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
104 $this->
msg(
'mw-widgets-titlesmultiselect-placeholder' )->plain();
106 if ( isset( $this->mParams[
'max'] ) ) {
107 $params[
'tagLimit'] = $this->mParams[
'max'];
110 if ( isset( $this->mParams[
'showMissing'] ) ) {
111 $params[
'showMissing'] = $this->mParams[
'showMissing'];
113 if ( $this->mParams[
'namespace'] !==
false ) {
114 $params[
'namespace'] = $this->mParams[
'namespace'];
116 $params[
'relative'] = $this->mParams[
'relative'];
117 if ( isset( $this->mParams[
'allowEditTags'] ) ) {
118 $params[
'allowEditTags'] = $this->mParams[
'allowEditTags'];
121 if ( isset( $this->mParams[
'input'] ) ) {
122 $params[
'input'] = $this->mParams[
'input'];
125 if ( isset( $this->mParams[
'creatable'] ) ) {
126 $params[
'creatable'] = $this->mParams[
'creatable'];
129 if ( $value !==
null ) {
131 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
135 $params[
'infusable'] =
true;
136 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
146 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
157 return [
'mediawiki.widgets.TitlesMultiselectWidget' ];
165 return $textAreaField->getInputCodex( $value, $hasErrors );
171class_alias( HTMLTitlesMultiselectField::class,
'HTMLTitlesMultiselectField' );
Implements a text input field for page titles.