* OutputPage::getScript() was removed (deprecated since 1.24).
* OutputPage::out() was removed (deprecated since 1.22).
* OutputPage::setAllowedModules() was removed (deprecated since 1.24).
+* UserrightsPage::makeGroupNameListForLog() was removed (deprecated since 1.21).
=== Languages updated in 1.27 ===
$this->getOptions();
if ( $this->mOptions && !in_array( 'other', $this->mOptions, true ) ) {
if ( isset( $params['other-message'] ) ) {
- $msg = wfMessage( $params['other-message'] )->text();
+ $msg = $this->getMessage( $params['other-message'] )->text();
} elseif ( isset( $params['other'] ) ) {
$msg = $params['other'];
} else {
# Generate the label from a message, if possible
if ( isset( $info['buttonlabel-message'] ) ) {
- $msgInfo = $info['buttonlabel-message'];
-
- if ( is_array( $msgInfo ) ) {
- $msg = array_shift( $msgInfo );
- } else {
- $msg = $msgInfo;
- $msgInfo = [];
- }
-
- $this->buttonLabel = $this->msg( $msg, $msgInfo )->parse();
+ $this->buttonLabel = $this->getMessage( $info['buttonlabel-message'] )->parse();
} elseif ( isset( $info['buttonlabel'] ) ) {
if ( $info['buttonlabel'] === ' ' ) {
// Apparently some things set   directly and in an odd format
'id' => $this->mID,
'type' => $this->buttonType,
'name' => $this->mName,
- 'value' => $value,
+ 'value' => $this->getDefault(),
] + $this->getAttributes( [ 'disabled', 'tabindex' ] );
if ( $this->isBadIE() ) {
return Html::element( 'input', $attr );
} else {
- return Html::rawElement( 'button', $attr, $this->buttonLabel ?: htmlspecialchars( $value ) );
+ return Html::rawElement( 'button', $attr,
+ $this->buttonLabel ?: htmlspecialchars( $this->getDefault() ) );
}
}
public function getInputOOUI( $value ) {
return new OOUI\ButtonInputWidget( [
'name' => $this->mName,
- 'value' => $value,
+ 'value' => $this->getDefault(),
'label' => !$this->isBadIE() && $this->buttonLabel
? new OOUI\HtmlSnippet( $this->buttonLabel )
- : $value,
+ : $this->getDefault(),
'type' => $this->buttonType,
'classes' => [ 'mw-htmlform-submit', $this->mClass ],
'id' => $this->mID,
if ( empty( $this->mParams['message'] ) ) {
$msg = $this->msg( 'edittools' );
} else {
- $msg = $this->msg( $this->mParams['message'] );
+ $msg = $this->getMessage( $this->mParams['message'] );
if ( $msg->isDisabled() ) {
$msg = $this->msg( 'edittools' );
}
* Some field types support multi-level arrays.
* 'options-messages' -- associative array mapping message keys to values.
* Some field types support multi-level arrays.
- * 'options-message' -- message key to be parsed to extract the list of
+ * 'options-message' -- message key or object to be parsed to extract the list of
* options (like 'ipbreason-dropdown').
- * 'label-message' -- message key for a message to use as the label.
+ * 'label-message' -- message key or object for a message to use as the label.
* can be an array of msg key and then parameters to
* the message.
* 'label' -- alternatively, a raw text message. Overridden by
* label-message
* 'help' -- message text for a message to use as a help text.
- * 'help-message' -- message key for a message to use as a help text.
+ * 'help-message' -- message key or object for a message to use as a help text.
* can be an array of msg key and then parameters to
* the message.
* Overwrites 'help-messages' and 'help'.
- * 'help-messages' -- array of message key. As above, each item can
+ * 'help-messages' -- array of message keys/objects. As above, each item can
* be an array of msg key and then parameters.
* Overwrites 'help'.
* 'required' -- passed through to the object, indicating that it
protected $mSectionFooters = [];
protected $mPost = '';
protected $mId;
+ protected $mName;
protected $mTableId = '';
protected $mSubmitID;
if ( !empty( $this->mAutocomplete ) ) {
$attribs['autocomplete'] = $this->mAutocomplete;
}
+ if ( !empty ( $this->mName ) ) {
+ $attribs['name'] = $this->mName;
+ }
return $attribs;
}
return $this;
}
+ /**
+ * @param string$ name 'name' attribute for the form
+ * @return HTMLForm $this for chaining calls
+ */
+ public function setName( $name ) {
+ $this->mName = $name;
+
+ return $this;
+ }
+
/**
* Prompt the whole form to be wrapped in a "<fieldset>", with
* this text as its "<legend>" element.
return true;
case 'OR':
- foreach ( $params as $p ) {
+ foreach ( $params as $i => $p ) {
if ( !is_array( $p ) ) {
throw new MWException(
"Expected array, found " . gettype( $p ) . " at index $i"
return false;
case 'NOR':
- foreach ( $params as $p ) {
+ foreach ( $params as $i => $p ) {
if ( !is_array( $p ) ) {
throw new MWException(
"Expected array, found " . gettype( $p ) . " at index $i"
# Generate the label from a message, if possible
if ( isset( $params['label-message'] ) ) {
- $msgInfo = $params['label-message'];
-
- if ( is_array( $msgInfo ) ) {
- $msg = array_shift( $msgInfo );
- } else {
- $msg = $msgInfo;
- $msgInfo = [];
- }
-
- $this->mLabel = $this->msg( $msg, $msgInfo )->parse();
+ $this->mLabel = $this->getMessage( $params['label-message'] )->parse();
} elseif ( isset( $params['label'] ) ) {
if ( $params['label'] === ' ' ) {
// Apparently some things set   directly and in an odd format
}
if ( isset( $this->mParams['help-messages'] ) ) {
- foreach ( $this->mParams['help-messages'] as $name ) {
- $helpMessage = (array)$name;
- $msg = $this->msg( array_shift( $helpMessage ), $helpMessage );
+ foreach ( $this->mParams['help-messages'] as $msg ) {
+ $msg = $this->getMessage( $msg );
if ( $msg->exists() ) {
if ( is_null( $helptext ) ) {
$this->mOptions = self::forceToStringRecursive( $this->mParams['options'] );
} elseif ( array_key_exists( 'options-message', $this->mParams ) ) {
/** @todo This is copied from Xml::listDropDown(), deprecate/avoid duplication? */
- $message = $this->msg( $this->mParams['options-message'] )->inContentLanguage()->plain();
+ $message = $this->getMessage( $this->mParams['options-message'] )->inContentLanguage()->plain();
$optgroup = false;
$this->mOptions = [];
return Html::rawElement( 'span', [ 'class' => 'error' ], $errors );
}
}
+
+ /**
+ * Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a
+ * name + parameters array) into a Message.
+ * @param mixed $value
+ * @return Message
+ */
+ protected function getMessage( $value ) {
+ if ( $value instanceof Message ) {
+ return $value;
+ } elseif ( $value instanceof MessageSpecifier ) {
+ return Message::newFromKey( $value );
+ } elseif ( is_array( $value ) ) {
+ $msg = array_shift( $value );
+ return $this->msg( $msg, $value );
+ } else {
+ return $this->msg( $value, [] );
+ }
+ }
}
* 'table', 'div', or 'raw'.
* row-legend - If non-empty, each group of subfields will be enclosed in a
* fieldset. The value is the name of a message key to use as the legend.
- * create-button-message - Message key to use as the text of the button to
+ * create-button-message - Message to use as the text of the button to
* add an additional group of fields.
- * delete-button-message - Message key to use as the text of automatically-
+ * delete-button-message - Message to use as the text of automatically-
* generated 'delete' button. Ignored if 'delete' is included in 'fields'.
*
* In the generated HTML, the subfields will be named along the lines of
'name' => $name,
'id' => Sanitizer::escapeId( "{$this->mID}--$key--delete" ),
'cssclass' => 'mw-htmlform-cloner-delete-button',
- 'default' => $this->msg( $label )->text(),
+ 'default' => $this->getMessage( $label )->text(),
], $this->mParent );
$v = $field->getDefault();
'name' => $name,
'id' => Sanitizer::escapeId( "{$this->mID}--create" ),
'cssclass' => 'mw-htmlform-cloner-create-button',
- 'default' => $this->msg( $label )->text(),
+ 'default' => $this->getMessage( $label )->text(),
], $this->mParent );
$html .= $field->getInputHTML( $field->getDefault() );
if ( array_key_exists( 'other', $params ) ) {
// Do nothing
} elseif ( array_key_exists( 'other-message', $params ) ) {
- $params['other'] = wfMessage( $params['other-message'] )->plain();
+ $params['other'] = $this->getMessage( $params['other-message'] )->plain();
} else {
- $params['other'] = wfMessage( 'htmlform-selectorother-other' )->plain();
+ $params['other'] = $this->msg( 'htmlform-selectorother-other' )->plain();
}
parent::__construct( $params );
const DEFAULT_COLS = 80;
const DEFAULT_ROWS = 25;
+ protected $mPlaceholder = '';
+
+ /**
+ * @param array $params
+ * - cols, rows: textarea size
+ * - placeholder/placeholder-message: set HTML placeholder attribute
+ * - spellcheck: set HTML spellcheck attribute
+ */
+ public function __construct( $params ) {
+ parent::__construct( $params );
+
+ if ( isset( $params['placeholder-message'] ) ) {
+ $this->mPlaceholder = $this->getMessage( $params['placeholder-message'] )->parse();
+ } elseif ( isset( $params['placeholder'] ) ) {
+ $this->mPlaceholder = $params['placeholder'];
+ }
+ }
+
function getCols() {
return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
}
if ( $this->mClass !== '' ) {
$attribs['class'] = $this->mClass;
}
+ if ( $this->mPlaceholder !== '' ) {
+ $attribs['placeholder'] = $this->mPlaceholder;
+ }
$allowedParams = [
- 'placeholder',
'tabindex',
'disabled',
'readonly',
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];
}
+ if ( $this->mPlaceholder !== '' ) {
+ $attribs['placeholder'] = $this->mPlaceholder;
+ }
$allowedParams = [
- 'placeholder',
'tabindex',
'disabled',
'readonly',
<?php
class HTMLTextField extends HTMLFormField {
+ protected $mPlaceholder = '';
+
+ /**
+ * @param array $params
+ * - type: HTML textfield type
+ * - size: field size in characters (defaults to 45)
+ * - placeholder/placeholder-message: set HTML placeholder attribute
+ * - spellcheck: set HTML spellcheck attribute
+ * - persistent: upon unsuccessful requests, retain the value (defaults to true, except
+ * for password fields)
+ */
+ public function __construct( $params ) {
+ parent::__construct( $params );
+
+ if ( isset( $params['placeholder-message'] ) ) {
+ $this->mPlaceholder = $this->getMessage( $params['placeholder-message'] )->parse();
+ } elseif ( isset( $params['placeholder'] ) ) {
+ $this->mPlaceholder = $params['placeholder'];
+ }
+ }
+
function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
}
return null;
}
+ public function isPersistent() {
+ if ( isset( $this->mParams['persistent'] ) ) {
+ return $this->mParams['persistent'];
+ }
+ // don't put passwords into the HTML body, they could get cached or otherwise leaked
+ return !( isset( $this->mParams['type'] ) && $this->mParams['type'] === 'password' );
+ }
+
function getInputHTML( $value ) {
+ if ( !$this->isPersistent() ) {
+ $value = '';
+ }
+
$attribs = [
'id' => $this->mID,
'name' => $this->mName,
if ( $this->mClass !== '' ) {
$attribs['class'] = $this->mClass;
}
+ if ( $this->mPlaceholder !== '' ) {
+ $attribs['placeholder'] = $this->mPlaceholder;
+ }
# @todo Enforce pattern, step, required, readonly on the server side as
# well
'pattern',
'title',
'step',
- 'placeholder',
'list',
'maxlength',
'tabindex',
}
function getInputOOUI( $value ) {
+ if ( !$this->isPersistent() ) {
+ $value = '';
+ }
+
$attribs = $this->getTooltipAndAccessKey();
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];
}
+ if ( $this->mPlaceholder !== '' ) {
+ $attribs['placeholder'] = $this->mPlaceholder;
+ }
# @todo Enforce pattern, step, required, readonly on the server side as
# well
'flags',
'indicator',
'maxlength',
- 'placeholder',
'readonly',
'required',
'tabindex',
* Factory function for fatal errors
*
* @param string|MessageSpecifier $message Message key or object
- * @return Status
+ * @return StatusValue
*/
public static function newFatal( $message /*, parameters...*/ ) {
$params = func_get_args();
* Factory function for good results
*
* @param mixed $value
- * @return Status
+ * @return StatusValue
*/
public static function newGood( $value = null ) {
$result = new static();
*
* @param string|string[] $salt Token salt
* @param string $key Token key
- * @return MediaWiki\\Session\\SessionToken
+ * @return MediaWiki\\Session\\Token
*/
public function getToken( $salt = '', $key = 'default' ) {
$new = false;
return Status::newGood( $user );
}
- function makeGroupNameList( $ids ) {
- if ( empty( $ids ) ) {
- return $this->msg( 'rightsnone' )->inContentLanguage()->text();
- } else {
- return implode( ', ', $ids );
- }
- }
-
/**
- * Make a list of group names to be stored as parameter for log entries
+ * @since 1.15
*
- * @deprecated since 1.21; use LogFormatter instead.
* @param array $ids
+ *
* @return string
*/
- function makeGroupNameListForLog( $ids ) {
- wfDeprecated( __METHOD__, '1.21' );
-
+ public function makeGroupNameList( $ids ) {
if ( empty( $ids ) ) {
- return '';
+ return $this->msg( 'rightsnone' )->inContentLanguage()->text();
} else {
- return $this->makeGroupNameList( $ids );
+ return implode( ', ', $ids );
}
}
if ( $this->mDesiredDestName != $filename && $comparableName != $filename ) {
$warnings['badfilename'] = $filename;
- // Debugging for bug 62241
- wfDebugLog( 'upload', "Filename: '$filename', mDesiredDestName: "
- . "'$this->mDesiredDestName', comparableName: '$comparableName'" );
}
// Check whether the file extension is on the unwanted list
}
if ( $this->mFileSize == 0 ) {
- $warnings['emptyfile'] = true;
+ $warnings['empty-file'] = true;
}
$exists = self::getExistsWarning( $localFile );