36 parent::__construct( $params );
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 $params[
'disabled'] = $this->
isDisabledNoJs( $this->mParent->mFieldData );
97 if ( isset( $this->mParams[
'default'] ) ) {
98 $params[
'default'] = $this->mParams[
'default'];
101 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
102 $this->
msg(
'mw-widgets-titlesmultiselect-placeholder' )->plain();
104 if ( isset( $this->mParams[
'max'] ) ) {
105 $params[
'tagLimit'] = $this->mParams[
'max'];
108 if ( isset( $this->mParams[
'showMissing'] ) ) {
109 $params[
'showMissing'] = $this->mParams[
'showMissing'];
111 if ( $this->mParams[
'namespace'] !==
false ) {
112 $params[
'namespace'] = $this->mParams[
'namespace'];
114 $params[
'relative'] = $this->mParams[
'relative'];
115 if ( isset( $this->mParams[
'allowEditTags'] ) ) {
116 $params[
'allowEditTags'] = $this->mParams[
'allowEditTags'];
119 if ( isset( $this->mParams[
'input'] ) ) {
120 $params[
'input'] = $this->mParams[
'input'];
123 if ( isset( $this->mParams[
'creatable'] ) ) {
124 $params[
'creatable'] = $this->mParams[
'creatable'];
127 if ( $value !==
null ) {
129 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
133 $params[
'infusable'] =
true;
134 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
144 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
155 return [
'mediawiki.widgets.TitlesMultiselectWidget' ];
163 return $textAreaField->getInputCodex( $value, $hasErrors );
169class_alias( HTMLTitlesMultiselectField::class,
'HTMLTitlesMultiselectField' );
Implements a text input field for page titles.