20 $value = $request->getText( $this->mName, $this->
getDefault() ??
'' );
22 $namespaces = explode(
"\n", $value );
24 $namespaces = array_values( array_filter( $namespaces,
static function ( $namespace ) {
25 return trim( $namespace ) !==
'';
28 return implode(
"\n", $namespaces );
32 if ( !$this->mParams[
'exists'] || $value ===
'' ) {
36 if ( $value ===
null ) {
41 $namespaces = explode(
"\n", $value );
43 if ( isset( $this->mParams[
'max'] ) && ( count( $namespaces ) > $this->mParams[
'max'] ) ) {
44 return $this->
msg(
'htmlform-multiselect-toomany', $this->mParams[
'max'] );
47 foreach ( $namespaces as $namespace ) {
50 !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( (
int)$namespace )
52 return $this->
msg(
'htmlform-select-badoption' );
55 $result = parent::validate( $namespace, $alldata );
56 if ( $result !==
true ) {
65 $this->mParent->getOutput()->enableOOUI();
70 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.TagMultiselectWidget.styles' );
78 if ( isset( $this->mParams[
'disabled'] ) ) {
79 $params[
'disabled'] = $this->mParams[
'disabled'];
82 if ( isset( $this->mParams[
'default'] ) ) {
83 $params[
'default'] = $this->mParams[
'default'];
86 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
87 $this->
msg(
'mw-widgets-titlesmultiselect-placeholder' )->plain();
89 if ( isset( $this->mParams[
'max'] ) ) {
90 $params[
'tagLimit'] = $this->mParams[
'max'];
93 if ( isset( $this->mParams[
'input'] ) ) {
94 $params[
'input'] = $this->mParams[
'input'];
97 if ( $value !==
null ) {
99 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
103 $params[
'infusable'] =
true;
104 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
106 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
116 return [
'mediawiki.widgets.NamespacesMultiselectWidget' ];
Implements a tag multiselect input field for namespaces.
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
shouldInfuseOOUI()
Whether the field should be automatically infused.Note that all OOUI HTMLForm fields are infusable (y...
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
loadDataFromRequest( $request)
Get the value that this input has been set to from a posted form, or the input's default value if it ...
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
Wrapper for Html::namespaceSelector to use in HTMLForm.