24 parent::__construct( $params );
25 if ( !$this->mLabel ) {
26 $this->mLabel = $this->
msg(
'restrictionsfield-label' )->parse();
31 $helpText = parent::getHelpText();
32 if ( $helpText ===
null ) {
33 $helpText = $this->
msg(
'restrictionsfield-help' )->parse();
43 if ( !$request->getCheck( $this->mName ) ) {
47 $value = rtrim( $request->getText( $this->mName ),
"\r\n" );
48 $ips = $value ===
'' ? [] : explode(
"\n", $value );
51 }
catch ( InvalidArgumentException $e ) {
60 $default = parent::getDefault();
61 if ( $default ===
null ) {
80 isset( $this->mParams[
'required'] ) && $this->mParams[
'required'] !==
false
83 return $this->
msg(
'htmlform-required' );
86 if ( is_string( $value ) ) {
88 $status = Status::newGood();
89 foreach ( explode(
"\n", $value ) as $range ) {
90 if ( !IPUtils::isIPAddress( $range ) ) {
91 $status->fatal(
'restrictionsfield-badip', $range );
94 if ( $status->isOK() ) {
95 $status->fatal(
'unknown-error' );
97 return $status->getMessage();
100 if ( isset( $this->mValidationCallback ) ) {
101 return call_user_func( $this->mValidationCallback, $value, $alldata, $this->mParent );
113 $value = implode(
"\n", $value->toArray()[
'IPAddresses'] );
115 return parent::getInputHTML( $value );
124 $value = implode(
"\n", $value->toArray()[
'IPAddresses'] );
126 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 Stable to override.
__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.