17 parent::__construct( $params );
18 if ( !$this->mLabel ) {
19 $this->mLabel = $this->
msg(
'restrictionsfield-label' )->parse();
24 $helpText = parent::getHelpText();
25 if ( $helpText ===
null ) {
26 $helpText = $this->
msg(
'restrictionsfield-help' )->parse();
36 if ( !$request->getCheck( $this->mName ) ) {
40 $value = rtrim( $request->getText( $this->mName ),
"\r\n" );
41 $ips = $value ===
'' ? [] : explode(
"\n", $value );
44 }
catch ( InvalidArgumentException $e ) {
53 $default = parent::getDefault();
54 if ( $default ===
null ) {
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 ( !\IP::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.
static newFromArray(array $restrictions)
toArray()
Return the restrictions as an array.