Merge "Fix HTML output arround HTMLForm's submit buttons when in vform"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 8 Feb 2014 03:25:09 +0000 (03:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 8 Feb 2014 03:25:09 +0000 (03:25 +0000)
1  2 
includes/htmlform/HTMLForm.php

@@@ -700,10 -700,7 +700,10 @@@ class HTMLForm extends ContextSource 
                $this->getOutput()->preventClickjacking();
                $this->getOutput()->addModules( 'mediawiki.htmlform' );
                if ( $this->isVForm() ) {
 -                      $this->getOutput()->addModuleStyles( 'mediawiki.ui' );
 +                      $this->getOutput()->addModuleStyles( array(
 +                              'mediawiki.ui',
 +                              'mediawiki.ui.button',
 +                      ) );
                        // @todo Should vertical form set setWrapperLegend( false )
                        // to hide ugly fieldsets?
                }
         * @return String HTML.
         */
        function getButtons() {
-               $html = '<span class="mw-htmlform-submit-buttons">';
+               $buttons = '';
  
                if ( $this->mShowSubmit ) {
                        $attribs = array();
                        if ( $this->isVForm() ) {
                                // mw-ui-block is necessary because the buttons aren't necessarily in an
                                // immediate child div of the vform.
 -                              array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-big', 'mw-ui-primary', 'mw-ui-block' );
 +                              // @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'
 +                              );
                        }
  
-                       $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
-                       // Buttons are top-level form elements in table and div layouts,
-                       // but vform wants all elements inside divs to get spaced-out block
-                       // styling.
-                       if ( $this->isVForm() ) {
-                               $html = Html::rawElement( 'div', null, "\n$html\n" );
-                       }
+                       $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
                }
  
                if ( $this->mShowReset ) {
-                       $html .= Html::element(
-                                       'input',
-                                       array(
-                                               'type' => 'reset',
-                                               'value' => $this->msg( 'htmlform-reset' )->text()
-                                       )
-                               ) . "\n";
+                       $buttons .= Html::element(
+                               'input',
+                               array(
+                                       'type' => 'reset',
+                                       'value' => $this->msg( 'htmlform-reset' )->text()
+                               )
+                       ) . "\n";
                }
  
                foreach ( $this->mButtons as $button ) {
                                $attrs['id'] = $button['id'];
                        }
  
-                       $html .= Html::element( 'input', $attrs );
+                       $buttons .= Html::element( 'input', $attrs ) . "\n";
                }
  
-               $html .= '</span>';
+               $html = Html::rawElement( 'span',
+                       array( 'class' => 'mw-htmlform-submit-buttons' ), "\n$buttons" ) . "\n";
+               // Buttons are top-level form elements in table and div layouts,
+               // but vform wants all elements inside divs to get spaced-out block
+               // styling.
+               if ( $this->mShowSubmit && $this->isVForm() ) {
+                       $html = Html::rawElement( 'div', null, "\n$html" ) . "\n";
+               }
  
                return $html;
        }