34 parent::__construct( $params );
38 $value = $request->getText( $this->mName, $this->
getDefault() ??
'' );
40 $titlesArray = explode(
"\n", $value );
42 $titlesArray = array_values( array_filter( $titlesArray,
static function ( $title ) {
43 return trim( $title ) !==
'';
46 return implode(
"\n", $titlesArray );
50 if ( !$this->mParams[
'exists'] ) {
54 if ( $value ===
null ) {
59 $titlesArray = explode(
"\n", $value );
61 if ( isset( $this->mParams[
'max'] ) && ( count( $titlesArray ) > $this->mParams[
'max'] ) ) {
62 return $this->
msg(
'htmlform-multiselect-toomany', $this->mParams[
'max'] );
65 foreach ( $titlesArray as $title ) {
66 $result = parent::validate( $title, $alldata );
67 if ( $result !==
true ) {
76 $this->mParent->getOutput()->enableOOUI();
81 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.TagMultiselectWidget.styles' );
89 if ( isset( $this->mParams[
'disabled'] ) ) {
90 $params[
'disabled'] = $this->mParams[
'disabled'];
93 if ( isset( $this->mParams[
'default'] ) ) {
94 $params[
'default'] = $this->mParams[
'default'];
97 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
98 $this->
msg(
'mw-widgets-titlesmultiselect-placeholder' )->plain();
100 if ( isset( $this->mParams[
'max'] ) ) {
101 $params[
'tagLimit'] = $this->mParams[
'max'];
104 if ( isset( $this->mParams[
'showMissing'] ) ) {
105 $params[
'showMissing'] = $this->mParams[
'showMissing'];
107 if ( isset( $this->mParams[
'excludeDynamicNamespaces'] ) ) {
108 $params[
'excludeDynamicNamespaces'] = $this->mParams[
'excludeDynamicNamespaces'];
110 if ( isset( $this->mParams[
'allowEditTags'] ) ) {
111 $params[
'allowEditTags'] = $this->mParams[
'allowEditTags'];
114 if ( isset( $this->mParams[
'input'] ) ) {
115 $params[
'input'] = $this->mParams[
'input'];
118 if ( $value !==
null ) {
120 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
124 $params[
'infusable'] =
true;
125 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
135 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
144 return [
'mediawiki.widgets.TitlesMultiselectWidget' ];
Implements a text input field for page titles.
Implements a tag multiselect input field for titles.
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
loadDataFromRequest( $request)
Get the value that this input has been set to from a posted form, or the input's default value if it ...
shouldInfuseOOUI()
Whether the field should be automatically infused.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getInputWidget( $params)
Stability: stableto overrideWidget
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...