25 parent::__construct( $params );
26 if ( !$this->mLabel ) {
27 $this->mLabel = $this->
msg(
'restrictionsfield-label' )->parse();
32 return parent::getHelpText() ?? $this->
msg(
'restrictionsfield-help' )->parse();
40 if ( !$request->getCheck( $this->mName ) ) {
44 $value = rtrim( $request->getText( $this->mName ),
"\r\n" );
45 $ips = $value ===
'' ? [] : explode(
"\n", $value );
47 return MWRestrictions::newFromArray( [
'IPAddresses' => $ips ] );
48 }
catch ( InvalidArgumentException $e ) {
57 return parent::getDefault() ?? MWRestrictions::newDefault();
73 isset( $this->mParams[
'required'] ) && $this->mParams[
'required'] !==
false
76 return $this->
msg(
'htmlform-required' );
79 if ( is_string( $value ) ) {
81 $status = Status::newGood();
82 foreach ( explode(
"\n", $value ) as $range ) {
83 if ( !IPUtils::isIPAddress( $range ) ) {
84 $status->fatal(
'restrictionsfield-badip', $range );
87 if ( $status->isOK() ) {
88 $status->fatal(
'unknown-error' );
90 return $status->getMessage();
93 if ( isset( $this->mValidationCallback ) ) {
94 return call_user_func( $this->mValidationCallback, $value, $alldata, $this->mParent );
106 $value = implode(
"\n", $value->toArray()[
'IPAddresses'] );
108 return parent::getInputHTML( $value );
117 $value = implode(
"\n", $value->toArray()[
'IPAddresses'] );
119 return parent::getInputOOUI( $value );
Class for updating an MWRestrictions value (which is, currently, basically just an IP address list).
loadDataFromRequest( $request)
validate( $value, $alldata)
getHelpText()
Determine the help text to display.
__construct(array $params)
A class to check request restrictions expressed as a JSON object.
toArray()
Return the restrictions as an array.