}
// FIXME Ewww, this shouldn't be adding any attributes not requested in $list :(
- public function getAttributes( array $list, array $mappings = null ) {
+ public function getAttributes( array $list ) {
$attribs = [
'type' => 'text',
'data-autocomplete' => FormatJson::encode( array_keys( $this->autocomplete ) ),
- ] + parent::getAttributes( $list, $mappings );
+ ] + parent::getAttributes( $list );
if ( $this->getOptions() ) {
$attribs['data-hide-if'] = FormatJson::encode(
'id' => $this->mID,
'flags' => $this->mFlags,
'useInputTag' => $this->isBadIE(),
- ] + $this->getAttributes( [ 'disabled', 'tabindex' ], [ 'tabindex' => 'tabIndex' ] ) );
+ ] + OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( [ 'disabled', 'tabindex' ] )
+ ) );
}
protected function needsLabel() {
$attr['id'] = $this->mID;
$attr['name'] = $this->mName;
- $attr += $this->getAttributes(
- [ 'disabled', 'tabindex' ],
- [ 'tabindex' => 'tabIndex' ]
+ $attr += OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( [ 'disabled', 'tabindex' ] )
);
if ( $this->mClass !== '' ) {
$rows = $this->mParams['rows'];
$columns = $this->mParams['columns'];
- $mappings = [];
-
- if ( $this->mParent instanceof OOUIHTMLForm ) {
- $mappings['tabindex'] = 'tabIndex';
- }
-
- $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ], $mappings );
+ $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ] );
// Build the column headers
$headerContents = Html::rawElement( 'td', [], ' ' );
return new OOUI\CheckboxInputWidget( [
'name' => "{$this->mName}[]",
'selected' => $checked,
- 'value' => $attribs['value'],
- ] + $attribs );
+ ] + OOUI\Element::configFromHtmlAttributes(
+ $attribs
+ ) );
} else {
$checkbox = Xml::check( "{$this->mName}[]", $checked, $attribs );
if ( $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
*/
class HTMLComboboxField extends HTMLTextField {
// FIXME Ewww, this shouldn't be adding any attributes not requested in $list :(
- public function getAttributes( array $list, array $mappings = null ) {
+ public function getAttributes( array $list ) {
$attribs = [
'type' => 'text',
'list' => $this->mName . '-datalist',
- ] + parent::getAttributes( $list, $mappings );
+ ] + parent::getAttributes( $list );
return $attribs;
}
function getInputOOUI( $value ) {
$disabled = false;
$allowedParams = [ 'tabindex' ];
- $attribs = $this->getAttributes( $allowedParams, [ 'tabindex' => 'tabIndex' ] );
+ $attribs = OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( $allowedParams )
+ );
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];
return Linker::tooltipAndAccesskeyAttribs( $this->mParams['tooltip'] );
}
- /**
- * Get a translated key if necessary.
- * @param array|null $mappings Array of mappings, 'original' => 'translated'
- * @param string $key
- * @return string
- */
- protected function getMappedKey( $mappings, $key ) {
- if ( !is_array( $mappings ) ) {
- return $key;
- }
-
- if ( !empty( $mappings[$key] ) ) {
- return $mappings[$key];
- }
-
- return $key;
- }
-
/**
* Returns the given attributes from the parameters
*
* @param array $list List of attributes to get
- * @param array $mappings Optional - Key/value map of attribute names to use
- * instead of the ones passed in.
* @return array Attributes
*/
- public function getAttributes( array $list, array $mappings = null ) {
+ public function getAttributes( array $list ) {
static $boolAttribs = [ 'disabled', 'required', 'autofocus', 'multiple', 'readonly' ];
$ret = [];
foreach ( $list as $key ) {
- $mappedKey = $this->getMappedKey( $mappings, $key );
-
if ( in_array( $key, $boolAttribs ) ) {
if ( !empty( $this->mParams[$key] ) ) {
- $ret[$mappedKey] = $mappedKey;
+ $ret[$key] = '';
}
} elseif ( isset( $this->mParams[$key] ) ) {
- $ret[$mappedKey] = $this->mParams[$key];
+ $ret[$key] = $this->mParams[$key];
}
}
'type' => $this->mButtonType,
'label' => $this->mButtonValue,
'flags' => $this->mButtonFlags,
- ] );
+ ] + OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( [ 'disabled', 'tabindex' ] )
+ ) );
}
/**
new OOUI\CheckboxInputWidget( [
'name' => "{$this->mName}[]",
'selected' => $checked,
- 'value' => $attribs['value'],
- ] + $attribs ),
+ ] + OOUI\Element::configFromHtmlAttributes(
+ $attribs
+ ) ),
[
'label' => $label,
'align' => 'inline',
'value' => $value,
'options' => $options,
'classes' => 'mw-htmlform-flatlist-item',
- ] + $this->getAttributes( [ 'disabled', 'tabindex' ], [ 'tabindex' => 'tabIndex' ] ) );
+ ] + OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( [ 'disabled', 'tabindex' ] )
+ ) );
}
function formatOptions( $options, $value ) {
function getInputOOUI( $value ) {
$disabled = false;
$allowedParams = [ 'tabindex' ];
- $attribs = $this->getAttributes( $allowedParams, [ 'tabindex' => 'tabIndex' ] );
+ $attribs = OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( $allowedParams )
+ );
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];
'autofocus',
];
- $attribs += $this->getAttributes( $allowedParams, [
- 'tabindex' => 'tabIndex',
- 'readonly' => 'readOnly',
- ] );
+ $attribs += OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( $allowedParams )
+ );
return new OOUI\TextInputWidget( [
'id' => $this->mID,
'type',
];
- $attribs += $this->getAttributes( $allowedParams, [
- 'maxlength' => 'maxLength',
- 'readonly' => 'readOnly',
- 'tabindex' => 'tabIndex',
- ] );
+ $attribs += OOUI\Element::configFromHtmlAttributes(
+ $this->getAttributes( $allowedParams )
+ );
$type = $this->getType( $attribs );