* - Optional CSS class used on tooltip container span. Defaults to mw-icon-question.
*/
class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
- static private $requiredParams = array(
+ static private $requiredParams = [
// Required by underlying HTMLFormField
'fieldname',
// Required by HTMLCheckMatrix
'rows',
'columns'
- );
+ ];
public function __construct( $params ) {
$missing = array_diff( self::$requiredParams, array_keys( $params ) );
// If all options are valid, array_intersect of the valid options
// and the provided options will return the provided options.
- $validOptions = array();
+ $validOptions = [];
foreach ( $rows as $rowTag ) {
foreach ( $columns as $columnTag ) {
$validOptions[] = $columnTag . '-' . $rowTag;
$rows = $this->mParams['rows'];
$columns = $this->mParams['columns'];
- $mappings = array();
-
- if ( $this->mParent instanceof OOUIHTMLForm ) {
- $mappings['tabindex'] = 'tabIndex';
- }
-
- $attribs = $this->getAttributes( array( 'disabled', 'tabindex' ), $mappings );
+ $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ] );
// Build the column headers
- $headerContents = Html::rawElement( 'td', array(), ' ' );
+ $headerContents = Html::rawElement( 'td', [], ' ' );
foreach ( $columns as $columnLabel => $columnTag ) {
- $headerContents .= Html::rawElement( 'td', array(), $columnLabel );
+ $headerContents .= Html::rawElement( 'td', [], $columnLabel );
}
- $tableContents .= Html::rawElement( 'tr', array(), "\n$headerContents\n" );
+ $tableContents .= Html::rawElement( 'tr', [], "\n$headerContents\n" );
$tooltipClass = 'mw-icon-question';
if ( isset( $this->mParams['tooltip-class'] ) ) {
foreach ( $rows as $rowLabel => $rowTag ) {
// Append tooltip if configured
if ( isset( $this->mParams['tooltips'][$rowLabel] ) ) {
- $tooltipAttribs = array(
+ $tooltipAttribs = [
'class' => "mw-htmlform-tooltip $tooltipClass",
'title' => $this->mParams['tooltips'][$rowLabel],
- );
+ ];
$rowLabel .= ' ' . Html::element( 'span', $tooltipAttribs, '' );
}
- $rowContents = Html::rawElement( 'td', array(), $rowLabel );
+ $rowContents = Html::rawElement( 'td', [], $rowLabel );
foreach ( $columns as $columnTag ) {
$thisTag = "$columnTag-$rowTag";
// Construct the checkbox
- $thisAttribs = array(
+ $thisAttribs = [
'id' => "{$this->mID}-$thisTag",
'value' => $thisTag,
- );
+ ];
$checked = in_array( $thisTag, (array)$value, true );
if ( $this->isTagForcedOff( $thisTag ) ) {
$checked = false;
$rowContents .= Html::rawElement(
'td',
- array(),
+ [],
$checkbox
);
}
- $tableContents .= Html::rawElement( 'tr', array(), "\n$rowContents\n" );
+ $tableContents .= Html::rawElement( 'tr', [], "\n$rowContents\n" );
}
// Put it all in a table
$html .= Html::rawElement( 'table',
- array( 'class' => 'mw-htmlform-matrix' ),
- Html::rawElement( 'tbody', array(), "\n$tableContents\n" ) ) . "\n";
+ [ 'class' => 'mw-htmlform-matrix' ],
+ Html::rawElement( 'tbody', [], "\n$tableContents\n" ) ) . "\n";
return $html;
}
protected function getOneCheckbox( $checked, $attribs ) {
if ( $this->mParent instanceof OOUIHTMLForm ) {
- return new OOUI\CheckboxInputWidget( array(
+ 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' ) ) {
- $checkbox = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+ $checkbox = Html::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) .
$checkbox .
- Html::element( 'label', array( 'for' => $attribs['id'] ) ) .
+ Html::element( 'label', [ 'for' => $attribs['id'] ] ) .
Html::closeElement( 'div' );
}
return $checkbox;
$inputHtml = $this->getInputHTML( $value );
$fieldType = get_class( $this );
$helptext = $this->getHelpTextHtmlTable( $this->getHelpText() );
- $cellAttributes = array( 'colspan' => 2 );
+ $cellAttributes = [ 'colspan' => 2 ];
$hideClass = '';
- $hideAttributes = array();
+ $hideAttributes = [];
if ( $this->mHideIf ) {
$hideAttributes['data-hide-if'] = FormatJson::encode( $this->mHideIf );
$hideClass = 'mw-htmlform-hide-if';
$field = Html::rawElement(
'td',
- array( 'class' => 'mw-input' ) + $cellAttributes,
+ [ 'class' => 'mw-input' ] + $cellAttributes,
$inputHtml . "\n$errors"
);
$html = Html::rawElement( 'tr',
- array( 'class' => "mw-htmlform-vertical-label $hideClass" ) + $hideAttributes,
+ [ 'class' => "mw-htmlform-vertical-label $hideClass" ] + $hideAttributes,
$label );
$html .= Html::rawElement( 'tr',
- array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass $hideClass" ) +
+ [ 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass $hideClass" ] +
$hideAttributes,
$field );
if ( $request->wasPosted() ) {
// Checkboxes are not added to the request arrays if they're not checked,
// so it's perfectly possible for there not to be an entry at all
- return $request->getArray( $this->mName, array() );
+ return $request->getArray( $this->mName, [] );
} else {
// That's ok, the user has not yet submitted the form, so show the defaults
return $this->getDefault();
// have submitted it with all the options unchecked. We will have to assume the
// latter, which basically means that you can't specify 'positive' defaults
// for GET forms.
- return $request->getArray( $this->mName, array() );
+ return $request->getArray( $this->mName, [] );
}
}
if ( isset( $this->mDefault ) ) {
return $this->mDefault;
} else {
- return array();
+ return [];
}
}
function filterDataForSubmit( $data ) {
$columns = HTMLFormField::flattenOptions( $this->mParams['columns'] );
$rows = HTMLFormField::flattenOptions( $this->mParams['rows'] );
- $res = array();
+ $res = [];
foreach ( $columns as $column ) {
foreach ( $rows as $row ) {
// Make sure option hasn't been forced