Merge "Add blanket support for mediawiki ui via globals"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 16 Aug 2014 00:48:19 +0000 (00:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 16 Aug 2014 00:48:19 +0000 (00:48 +0000)
1  2 
includes/htmlform/HTMLForm.php

@@@ -107,7 -107,6 +107,7 @@@ class HTMLForm extends ContextSource 
                'select' => 'HTMLSelectField',
                'radio' => 'HTMLRadioField',
                'multiselect' => 'HTMLMultiSelectField',
 +              'limitselect' => 'HTMLSelectLimitField',
                'check' => 'HTMLCheckField',
                'toggle' => 'HTMLCheckField',
                'int' => 'HTMLIntField',
         * @return string
         */
        public function getDisplayFormat() {
-               return $this->displayFormat;
+               global $wgHTMLFormAllowTableFormat;
+               $format = $this->displayFormat;
+               if ( !$wgHTMLFormAllowTableFormat && $format === 'table' ) {
+                       $format = 'div';
+               }
+               return $format;
        }
  
        /**
         * @return string HTML.
         */
        function getButtons() {
+               global $wgUseMediaWikiUIEverywhere;
                $buttons = '';
  
                if ( $this->mShowSubmit ) {
  
                        $attribs['class'] = array( 'mw-htmlform-submit' );
  
+                       if ( $this->isVForm() || $wgUseMediaWikiUIEverywhere ) {
+                               array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' );
+                       }
                        if ( $this->isVForm() ) {
                                // mw-ui-block is necessary because the buttons aren't necessarily in an
                                // immediate child div of the vform.
                                // @todo Let client specify if the primary submit button is progressive or destructive
                                array_push(
                                        $attribs['class'],
-                                       'mw-ui-button',
                                        'mw-ui-big',
-                                       'mw-ui-constructive',
                                        'mw-ui-block'
                                );
                        }
                                $attrs['id'] = $button['id'];
                        }
  
+                       if ( $wgUseMediaWikiUIEverywhere ) {
+                               if ( isset( $attrs['class' ] ) ) {
+                                       $attrs['class'] .= ' mw-ui-button';
+                               } else {
+                                       $attrs['class'] = 'mw-ui-button';
+                               }
+                       }
                        $buttons .= Html::element( 'input', $attrs ) . "\n";
                }
  
                                // Close enough to a div.
                                $getFieldHtmlMethod = 'getDiv';
                                break;
+                       case 'div':
+                               $getFieldHtmlMethod = 'getDiv';
+                               break;
                        default:
                                $getFieldHtmlMethod = 'get' . ucfirst( $displayFormat );
                }