'validation-callback' => [ __CLASS__, 'validateTargetField' ],
],
'Expiry' => [
- 'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
+ 'type' => 'expiry',
'label-message' => 'ipbexpiry',
'required' => true,
'options' => $suggestedDurations,
- 'other' => $this->msg( 'ipbother' )->text(),
'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
],
'Reason' => [
* @todo Should be in Block.php?
* @param string $par Subpage parameter passed to setup, or data value from
* the HTMLForm
- * @param WebRequest $request Optionally try and get data from a request too
+ * @param WebRequest|null $request Optionally try and get data from a request too
* @return array [ User|string|null, Block::TYPE_ constant|null ]
*/
public static function getTargetAndType( $par, WebRequest $request = null ) {
if ( !$status->isOK() ) {
$errors = $status->getErrorsArray();
- return call_user_func_array( [ $form, 'msg' ], $errors[0] );
+ return $form->msg( ...$errors[0] );
} else {
return true;
}
$a[$show] = $value;
}
+ if ( $a ) {
+ // if options exist, add other to the end instead of the begining (which
+ // is what happens by default).
+ $a[ wfMessage( 'ipbother' )->text() ] = 'other';
+ }
+
return $a;
}
/**
* Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
* ("24 May 2034", etc), into an absolute timestamp we can put into the database.
+ *
+ * @todo strtotime() only accepts English strings. This means the expiry input
+ * can only be specified in English.
+ * @see https://secure.php.net/manual/en/function.strtotime.php
+ *
* @param string $expiry Whatever was typed into the form
- * @return string Timestamp or 'infinity'
+ * @return string|bool Timestamp or 'infinity' or false on error.
*/
public static function parseExpiryInput( $expiry ) {
if ( wfIsInfinity( $expiry ) ) {
- $expiry = 'infinity';
- } else {
- $expiry = strtotime( $expiry );
+ return 'infinity';
+ }
- if ( $expiry < 0 || $expiry === false ) {
- return false;
- }
+ $expiry = strtotime( $expiry );
- $expiry = wfTimestamp( TS_MW, $expiry );
+ if ( $expiry < 0 || $expiry === false ) {
+ return false;
}
- return $expiry;
+ return wfTimestamp( TS_MW, $expiry );
}
/**
/**
* Process the form on POST submission.
* @param array $data
- * @param HTMLForm $form
+ * @param HTMLForm|null $form
* @return bool|array True for success, false for didn't-try, array of errors on failure
*/
public function onSubmit( array $data, HTMLForm $form = null ) {