25 parent::__construct( $params );
26 if ( !$this->mLabel ) {
27 $this->mLabel = $this->
msg(
'restrictionsfield-label' )->parse();
32 $helpText = parent::getHelpText();
33 if ( $helpText ===
null ) {
34 $helpText = $this->
msg(
'restrictionsfield-help' )->parse();
44 if ( !$request->getCheck( $this->mName ) ) {
48 $value = rtrim( $request->getText( $this->mName ),
"\r\n" );
49 $ips = $value ===
'' ? [] : explode(
"\n", $value );
51 return MWRestrictions::newFromArray( [
'IPAddresses' => $ips ] );
52 }
catch ( InvalidArgumentException $e ) {
61 $default = parent::getDefault();
62 if ( $default ===
null ) {
63 $default = MWRestrictions::newDefault();
81 isset( $this->mParams[
'required'] ) && $this->mParams[
'required'] !==
false
84 return $this->
msg(
'htmlform-required' );
87 if ( is_string( $value ) ) {
89 $status = Status::newGood();
90 foreach ( explode(
"\n", $value ) as $range ) {
91 if ( !IPUtils::isIPAddress( $range ) ) {
92 $status->fatal(
'restrictionsfield-badip', $range );
95 if ( $status->isOK() ) {
96 $status->fatal(
'unknown-error' );
98 return $status->getMessage();
101 if ( isset( $this->mValidationCallback ) ) {
102 return call_user_func( $this->mValidationCallback, $value, $alldata, $this->mParent );
114 $value = implode(
"\n", $value->toArray()[
'IPAddresses'] );
116 return parent::getInputHTML( $value );
125 $value = implode(
"\n", $value->toArray()[
'IPAddresses'] );
127 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.