Merge "Avoid calling Block::deleteIfExpired() when not needed"
[lhc/web/wiklou.git] / includes / htmlform / OOUIHTMLForm.php
index d328ecc..811eaf4 100644 (file)
@@ -50,6 +50,9 @@ class OOUIHTMLForm extends HTMLForm {
        function getButtons() {
                $buttons = '';
 
+               // IE<8 has bugs with <button>, so we'll need to avoid them.
+               $isBadIE = preg_match( '/MSIE [1-7]\./i', $this->getRequest()->getHeader( 'User-Agent' ) );
+
                if ( $this->mShowSubmit ) {
                        $attribs = array( 'infusable' => true );
 
@@ -70,6 +73,7 @@ class OOUIHTMLForm extends HTMLForm {
                        $attribs['label'] = $this->getSubmitText();
                        $attribs['value'] = $this->getSubmitText();
                        $attribs['flags'] = $this->mSubmitFlags;
+                       $attribs['useInputTag'] = $isBadIE;
 
                        $buttons .= new OOUI\ButtonInputWidget( $attribs );
                }
@@ -78,6 +82,7 @@ class OOUIHTMLForm extends HTMLForm {
                        $buttons .= new OOUI\ButtonInputWidget( array(
                                'type' => 'reset',
                                'label' => $this->msg( 'htmlform-reset' )->text(),
+                               'useInputTag' => $isBadIE,
                        ) );
                }
 
@@ -92,13 +97,27 @@ class OOUIHTMLForm extends HTMLForm {
                                $attrs['id'] = $button['id'];
                        }
 
+                       if ( $isBadIE ) {
+                               $label = $button['value'];
+                       } elseif ( isset( $button['label-message'] ) ) {
+                               $label = new OOUI\HtmlSnippet( $this->msg( $button['label-message'] )->parse() );
+                       } elseif ( isset( $button['label'] ) ) {
+                               $label = $button['label'];
+                       } elseif ( isset( $button['label-raw'] ) ) {
+                               $label = new OOUI\HtmlSnippet( $button['label-raw'] );
+                       } else {
+                               $label = $button['value'];
+                       }
+
                        $attrs['classes'] = isset( $attrs['class'] ) ? (array)$attrs['class'] : array();
 
                        $buttons .= new OOUI\ButtonInputWidget( array(
                                'type' => 'submit',
                                'name' => $button['name'],
                                'value' => $button['value'],
-                               'label' => $button['value'],
+                               'label' => $label,
+                               'flags' => $button['flags'],
+                               'useInputTag' => $isBadIE,
                        ) + $attrs );
                }
 
@@ -108,9 +127,32 @@ class OOUIHTMLForm extends HTMLForm {
                return $html;
        }
 
+       protected function wrapFieldSetSection( $legend, $section, $attributes ) {
+               // to get a user visible effect, wrap the fieldset into a framed panel layout
+               $layout = new OOUI\PanelLayout( array(
+                       'expanded' => false,
+                       'padded' => true,
+                       'framed' => true,
+                       'infusable' => false,
+               ) );
+
+               $layout->appendContent(
+                       new OOUI\FieldsetLayout( array(
+                               'label' => $legend,
+                               'infusable' => false,
+                               'items' => array(
+                                       new OOUI\Widget( array(
+                                               'content' => new OOUI\HtmlSnippet( $section )
+                                       ) ),
+                               ),
+                       ) + $attributes )
+               );
+               return $layout;
+       }
+
        /**
         * Put a form section together from the individual fields' HTML, merging it and wrapping.
-        * @param OOUI\\FieldLayout[] $fieldsHtml
+        * @param OOUI\FieldLayout[] $fieldsHtml
         * @param string $sectionName
         * @param bool $anyFieldHasLabel Unused
         * @return string HTML