25 $value = $request->getText( $this->mName, $this->
getDefault() ??
'' );
27 $usersArray = explode(
"\n", $value );
29 $usersArray = array_values( array_filter( $usersArray,
static function ( $username ) {
30 return trim( $username ) !==
'';
34 $normalizedUsers = [];
37 foreach ( $usersArray as $user ) {
38 $canonicalUser =
false;
39 if ( IPUtils::isIPAddress( $user ) ) {
40 $parsedIPRange = IPUtils::parseRange( $user );
41 if ( !in_array( $parsedIPRange, $listOfIps ) ) {
42 $canonicalUser = IPUtils::sanitizeRange( $user );
43 $listOfIps[] = $parsedIPRange;
46 $canonicalUser = $userNameUtils->getCanonical(
47 $user, UserRigorOptions::RIGOR_NONE );
49 if ( $canonicalUser !==
false ) {
50 $normalizedUsers[] = $canonicalUser;
54 $uniqueUsers = array_unique( $normalizedUsers );
57 return implode(
"\n", $uniqueUsers );
61 if ( !$this->mParams[
'exists'] ) {
65 if ( $value ===
null ) {
70 $usersArray = explode(
"\n", $value );
72 if ( isset( $this->mParams[
'max'] ) && ( count( $usersArray ) > $this->mParams[
'max'] ) ) {
73 return $this->
msg(
'htmlform-multiselect-toomany', $this->mParams[
'max'] );
76 foreach ( $usersArray as $username ) {
77 $result = parent::validate( $username, $alldata );
78 if ( $result !==
true ) {
87 $this->mParent->getOutput()->enableOOUI();
92 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.TagMultiselectWidget.styles' );
96 if ( isset( $this->mParams[
'id'] ) ) {
97 $params[
'id'] = $this->mParams[
'id'];
100 if ( isset( $this->mParams[
'disabled'] ) ) {
101 $params[
'disabled'] = $this->mParams[
'disabled'];
104 if ( isset( $this->mParams[
'default'] ) ) {
105 $params[
'default'] = $this->mParams[
'default'];
108 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
109 $this->
msg(
'mw-widgets-usersmultiselect-placeholder' )->plain();
111 if ( isset( $this->mParams[
'max'] ) ) {
112 $params[
'tagLimit'] = $this->mParams[
'max'];
115 if ( isset( $this->mParams[
'ipallowed'] ) ) {
116 $params[
'ipAllowed'] = $this->mParams[
'ipallowed'];
119 if ( isset( $this->mParams[
'iprange'] ) ) {
120 $params[
'ipRangeAllowed'] = $this->mParams[
'iprange'];
123 if ( isset( $this->mParams[
'iprangelimits'] ) ) {
124 $params[
'ipRangeLimits'] = $this->mParams[
'iprangelimits'];
127 if ( isset( $this->mParams[
'excludenamed'] ) ) {
128 $params[
'excludeNamed'] = $this->mParams[
'excludenamed'];
131 if ( isset( $this->mParams[
'excludetemp'] ) ) {
132 $params[
'excludeTemp'] = $this->mParams[
'excludetemp'];
135 if ( isset( $this->mParams[
'input'] ) ) {
136 $params[
'input'] = $this->mParams[
'input'];
139 if ( $value !==
null ) {
141 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
146 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
156 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
165 return [
'mediawiki.widgets.UsersMultiselectWidget' ];
171class_alias( HTMLUsersMultiselectField::class,
'HTMLUsersMultiselectField' );
array $params
The job parameters.
Implements a text input field for user names.