Merge "Converted FileBackendStore to using the WAN cache"
[lhc/web/wiklou.git] / includes / htmlform / HTMLCheckMatrix.php
index 606523b..83f1266 100644 (file)
@@ -113,8 +113,9 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                        foreach ( $columns as $columnTag ) {
                                $thisTag = "$columnTag-$rowTag";
                                // Construct the checkbox
+                               $thisId = "{$this->mID}-$thisTag";
                                $thisAttribs = array(
-                                       'id' => "{$this->mID}-$thisTag",
+                                       'id' => $thisId,
                                        'value' => $thisTag,
                                );
                                $checked = in_array( $thisTag, (array)$value, true );
@@ -125,10 +126,17 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                                        $checked = true;
                                        $thisAttribs['disabled'] = 1;
                                }
+                               $chkBox = Xml::check( "{$this->mName}[]", $checked, $attribs + $thisAttribs );
+                               if ( $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
+                                       $chkBox = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+                                               $chkBox .
+                                               Html::element( 'label', array( 'for' => $thisId ) ) .
+                                               Html::closeElement( 'div' );
+                               }
                                $rowContents .= Html::rawElement(
                                        'td',
                                        array(),
-                                       Xml::check( "{$this->mName}[]", $checked, $attribs + $thisAttribs )
+                                       $chkBox
                                );
                        }
                        $tableContents .= Html::rawElement( 'tr', array(), "\n$rowContents\n" );
@@ -170,6 +178,13 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                $helptext = $this->getHelpTextHtmlTable( $this->getHelpText() );
                $cellAttributes = array( 'colspan' => 2 );
 
+               $hideClass = '';
+               $hideAttributes = array();
+               if ( $this->mHideIf ) {
+                       $hideAttributes['data-hide-if'] = FormatJson::encode( $this->mHideIf );
+                       $hideClass = 'mw-htmlform-hide-if';
+               }
+
                $label = $this->getLabelHtml( $cellAttributes );
 
                $field = Html::rawElement(
@@ -178,9 +193,12 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                        $inputHtml . "\n$errors"
                );
 
-               $html = Html::rawElement( 'tr', array( 'class' => 'mw-htmlform-vertical-label' ), $label );
+               $html = Html::rawElement( 'tr',
+                       array( 'class' => "mw-htmlform-vertical-label $hideClass" ) + $hideAttributes,
+                       $label );
                $html .= Html::rawElement( 'tr',
-                       array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass" ),
+                       array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass $hideClass" ) +
+                               $hideAttributes,
                        $field );
 
                return $html . $helptext;