19 $value = $request->getText( $this->mName, $this->
getDefault() );
21 $namespaces = explode(
"\n", $value );
23 $namespaces = array_values( array_filter( $namespaces,
function ( $namespace ) {
24 return trim( $namespace ) !==
'';
27 return implode(
"\n", $namespaces );
31 if ( !$this->mParams[
'exists'] || $value ===
'' ) {
35 if ( is_null( $value ) ) {
40 $namespaces = explode(
"\n", $value );
42 if ( isset( $this->mParams[
'max'] ) && ( count( $namespaces ) > $this->mParams[
'max'] ) ) {
43 return $this->
msg(
'htmlform-int-toohigh', $this->mParams[
'max'] );
46 foreach ( $namespaces as $namespace ) {
49 !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace )
51 return $this->
msg(
'htmlform-select-badoption' );
54 $result = parent::validate( $namespace, $alldata );
55 if ( $result !==
true ) {
64 $this->mParent->getOutput()->enableOOUI();
75 if ( isset( $this->mParams[
'disabled'] ) ) {
76 $params[
'disabled'] = $this->mParams[
'disabled'];
79 if ( isset( $this->mParams[
'default'] ) ) {
80 $params[
'default'] = $this->mParams[
'default'];
83 if ( isset( $this->mParams[
'placeholder'] ) ) {
84 $params[
'placeholder'] = $this->mParams[
'placeholder'];
86 $params[
'placeholder'] = $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 ( !is_null( $value ) ) {
99 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
103 $params[
'infusable'] =
true;
104 $params[
'classes'] = [
'mw-htmlform-field-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.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
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.