40 $value = $request->getText( $this->mName, $this->
getDefault() ??
'' );
42 $titlesArray = explode(
"\n", $value );
44 $titlesArray = array_values( array_filter( $titlesArray,
static function ( $title ) {
45 return trim( $title ) !==
'';
48 return implode(
"\n", $titlesArray );
52 if ( !$this->mParams[
'exists'] ) {
56 if ( $value ===
null ) {
61 $titlesArray = explode(
"\n", $value );
63 if ( isset( $this->mParams[
'max'] ) && ( count( $titlesArray ) > $this->mParams[
'max'] ) ) {
64 return $this->
msg(
'htmlform-multiselect-toomany', $this->mParams[
'max'] );
67 foreach ( $titlesArray as $title ) {
68 $result = parent::validate( $title, $alldata );
69 if ( $result !==
true ) {
78 $this->mParent->getOutput()->enableOOUI();
83 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.TagMultiselectWidget.styles' );
91 if ( isset( $this->mParams[
'disabled'] ) ) {
92 $params[
'disabled'] = $this->mParams[
'disabled'];
95 if ( isset( $this->mParams[
'default'] ) ) {
96 $params[
'default'] = $this->mParams[
'default'];
99 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
100 $this->
msg(
'mw-widgets-titlesmultiselect-placeholder' )->plain();
102 if ( isset( $this->mParams[
'max'] ) ) {
103 $params[
'tagLimit'] = $this->mParams[
'max'];
106 if ( isset( $this->mParams[
'showMissing'] ) ) {
107 $params[
'showMissing'] = $this->mParams[
'showMissing'];
109 if ( isset( $this->mParams[
'excludeDynamicNamespaces'] ) ) {
110 $params[
'excludeDynamicNamespaces'] = $this->mParams[
'excludeDynamicNamespaces'];
112 if ( isset( $this->mParams[
'allowEditTags'] ) ) {
113 $params[
'allowEditTags'] = $this->mParams[
'allowEditTags'];
116 if ( isset( $this->mParams[
'input'] ) ) {
117 $params[
'input'] = $this->mParams[
'input'];
120 if ( $value !==
null ) {
122 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
127 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
137 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
146 return [
'mediawiki.widgets.TitlesMultiselectWidget' ];
153 return $textAreaField->getInputCodex( $value, $hasErrors );
159class_alias( HTMLTitlesMultiselectField::class,
'HTMLTitlesMultiselectField' );
array $params
The job parameters.
Implements a text input field for page titles.