28 $usersArray = explode(
"\n", $value );
30 $usersArray = array_values( array_filter( $usersArray,
static function ( $username ) {
31 return trim( $username ) !==
'';
35 $normalizedUsers = [];
38 foreach ( $usersArray as $user ) {
39 $canonicalUser =
false;
40 if ( IPUtils::isIPAddress( $user ) ) {
41 $parsedIPRange = IPUtils::parseRange( $user );
42 if ( !in_array( $parsedIPRange, $listOfIps ) ) {
43 $canonicalUser = IPUtils::sanitizeRange( $user );
44 $listOfIps[] = $parsedIPRange;
47 $canonicalUser = $userNameUtils->getCanonical(
48 $user, UserRigorOptions::RIGOR_NONE );
50 if ( $canonicalUser !==
false ) {
51 $normalizedUsers[] = $canonicalUser;
55 $uniqueUsers = array_unique( $normalizedUsers );
58 return implode(
"\n", $uniqueUsers );
63 if ( !$this->mParams[
'exists'] ) {
67 if ( $value ===
null ) {
72 $usersArray = explode(
"\n", $value );
74 if ( isset( $this->mParams[
'max'] ) && ( count( $usersArray ) > $this->mParams[
'max'] ) ) {
75 return $this->
msg(
'htmlform-multiselect-toomany', $this->mParams[
'max'] );
78 foreach ( $usersArray as $username ) {
79 $result = parent::validate( $username, $alldata );
80 if ( $result !==
true ) {
90 $this->mParent->getOutput()->enableOOUI();
96 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.TagMultiselectWidget.styles' );
100 if ( isset( $this->mParams[
'id'] ) ) {
101 $params[
'id'] = $this->mParams[
'id'];
104 $params[
'disabled'] = $this->
isDisabledNoJs( $this->mParent->mFieldData );
106 if ( isset( $this->mParams[
'default'] ) ) {
107 $params[
'default'] = $this->mParams[
'default'];
110 $params[
'placeholder'] = $this->mParams[
'placeholder'] ??
111 $this->
msg(
'mw-widgets-usersmultiselect-placeholder' )->plain();
113 if ( isset( $this->mParams[
'max'] ) ) {
114 $params[
'tagLimit'] = $this->mParams[
'max'];
117 if ( isset( $this->mParams[
'ipallowed'] ) ) {
118 $params[
'ipAllowed'] = $this->mParams[
'ipallowed'];
121 if ( isset( $this->mParams[
'iprange'] ) ) {
122 $params[
'ipRangeAllowed'] = $this->mParams[
'iprange'];
125 if ( isset( $this->mParams[
'iprangelimits'] ) ) {
126 $params[
'ipRangeLimits'] = $this->mParams[
'iprangelimits'];
129 if ( isset( $this->mParams[
'excludenamed'] ) ) {
130 $params[
'excludeNamed'] = $this->mParams[
'excludenamed'];
133 if ( isset( $this->mParams[
'excludetemp'] ) ) {
134 $params[
'excludeTemp'] = $this->mParams[
'excludetemp'];
137 if ( isset( $this->mParams[
'input'] ) ) {
138 $params[
'input'] = $this->mParams[
'input'];
141 if ( $value !==
null ) {
143 $params[
'default'] = $value ===
'' ? [] : explode(
"\n", $value );
147 $params[
'infusable'] =
true;
148 $params[
'classes'] = [
'mw-htmlform-autoinfuse' ];
158 $widget->setAttributes( [
'data-mw-modules' => implode(
',', $this->
getOOUIModules() ) ] );
169 return [
'mediawiki.widgets.UsersMultiselectWidget' ];
175class_alias( HTMLUsersMultiselectField::class,
'HTMLUsersMultiselectField' );
Implements a text input field for user names.