HTMLRadioField: Only add 'mw-ui' classes when needed
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 30 May 2016 15:00:00 +0000 (17:00 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 30 May 2016 15:00:59 +0000 (17:00 +0200)
Otherwise the field would change if something loaded the deprecated
'mediawiki.ui' style modules.

Bug: T133114
Change-Id: I06ddeade961bdf11eda6572d246333d750cfc2ab

includes/htmlform/HTMLRadioField.php

index 12a8a1f..9d3cc13 100644 (file)
@@ -59,6 +59,8 @@ class HTMLRadioField extends HTMLFormField {
        }
 
        function formatOptions( $options, $value ) {
+               global $wgUseMediaWikiUIEverywhere;
+
                $html = '';
 
                $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ] );
@@ -71,12 +73,16 @@ class HTMLRadioField extends HTMLFormField {
                                $html .= $this->formatOptions( $info, $value );
                        } else {
                                $id = Sanitizer::escapeId( $this->mID . "-$info" );
+                               $classes = [ 'mw-htmlform-flatlist-item' ];
+                               if ( $wgUseMediaWikiUIEverywhere || $this->mParent instanceof VFormHTMLForm ) {
+                                       $classes[] = 'mw-ui-radio';
+                               }
                                $radio = Xml::radio( $this->mName, $info, $info === $value, $attribs + [ 'id' => $id ] );
                                $radio .= '&#160;' . call_user_func( $elementFunc, 'label', [ 'for' => $id ], $label );
 
                                $html .= ' ' . Html::rawElement(
                                        'div',
-                                       [ 'class' => 'mw-htmlform-flatlist-item mw-ui-radio' ],
+                                       [ 'class' => $classes ],
                                        $radio
                                );
                        }