Merge "Revert "Convert Special:EmailUser to use OOUIHTMLForm""
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 12 Jan 2016 00:09:48 +0000 (00:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 12 Jan 2016 00:09:48 +0000 (00:09 +0000)
1  2 
includes/htmlform/HTMLForm.php

@@@ -671,10 -671,10 +671,10 @@@ class HTMLForm extends ContextSource 
        }
  
        /**
 -       * Set the introductory message, overwriting any existing message.
 +       * Set the introductory message HTML, overwriting any existing message.
         * @since 1.19
         *
 -       * @param string $msg Complete text of message to display
 +       * @param string $msg Complete HTML of message to display
         *
         * @return HTMLForm $this for chaining calls (since 1.20)
         */
        }
  
        /**
 -       * Add introductory text.
 +       * Add HTML to introductory message.
         *
 -       * @param string $msg Complete text of message to display
 +       * @param string $msg Complete HTML of message to display
         *
         * @return HTMLForm $this for chaining calls (since 1.20)
         */
        }
  
        /**
 -       * Add header text, inside the form.
 +       * Add HTML to the header, inside the form.
         *
 -       * @param string $msg Complete text of message to display
 +       * @param string $msg Additional HTML to display in header
         * @param string|null $section The section to add the header to
         *
         * @return HTMLForm $this for chaining calls (since 1.20)
         * Set header text, inside the form.
         * @since 1.19
         *
 -       * @param string $msg Complete text of message to display
 +       * @param string $msg Complete HTML of header to display
         * @param string|null $section The section to add the header to
         *
         * @return HTMLForm $this for chaining calls (since 1.20)
         *
         * @param string|null $section The section to get the header text for
         * @since 1.26
 -       * @return string
 +       * @return string HTML
         */
        function getHeaderText( $section = null ) {
                if ( is_null( $section ) ) {
        /**
         * Add a button to the form
         *
 -       * @param string $name Field name.
 -       * @param string $value Field value
 -       * @param string $id DOM id for the button (default: null)
 -       * @param array $attribs
 -       *
 +       * @since 1.27 takes an array as shown. Earlier versions accepted
 +       *  'name', 'value', 'id', and 'attribs' as separate parameters in that
 +       *  order.
 +       * @note Custom labels ('label', 'label-message', 'label-raw') are not
 +       *  supported for IE6 and IE7 due to bugs in those browsers. If detected,
 +       *  they will be served buttons using 'value' as the button label.
 +       * @param array $data Data to define the button:
 +       *  - name: (string) Button name.
 +       *  - value: (string) Button value.
 +       *  - label-message: (string, optional) Button label message key to use
 +       *    instead of 'value'. Overrides 'label' and 'label-raw'.
 +       *  - label: (string, optional) Button label text to use instead of
 +       *    'value'. Overrides 'label-raw'.
 +       *  - label-raw: (string, optional) Button label HTML to use instead of
 +       *    'value'.
 +       *  - id: (string, optional) DOM id for the button.
 +       *  - attribs: (array, optional) Additional HTML attributes.
 +       *  - flags: (string|string[], optional) OOUI flags.
         * @return HTMLForm $this for chaining calls (since 1.20)
         */
 -      public function addButton( $name, $value, $id = null, $attribs = null ) {
 -              $this->mButtons[] = compact( 'name', 'value', 'id', 'attribs' );
 +      public function addButton( $data ) {
 +              if ( !is_array( $data ) ) {
 +                      $args = func_get_args();
 +                      if ( count( $args ) < 2 || count( $args ) > 4 ) {
 +                              throw new InvalidArgumentException(
 +                                      'Incorrect number of arguments for deprecated calling style'
 +                              );
 +                      }
 +                      $data = array(
 +                              'name' => $args[0],
 +                              'value' => $args[1],
 +                              'id' => isset( $args[2] ) ? $args[2] : null,
 +                              'attribs' => isset( $args[3] ) ? $args[3] : null,
 +                      );
 +              } else {
 +                      if ( !isset( $data['name'] ) ) {
 +                              throw new InvalidArgumentException( 'A name is required' );
 +                      }
 +                      if ( !isset( $data['value'] ) ) {
 +                              throw new InvalidArgumentException( 'A value is required' );
 +                      }
 +              }
 +              $this->mButtons[] = $data + array(
 +                      'id' => null,
 +                      'attribs' => null,
 +                      'flags' => null,
 +              );
  
                return $this;
        }
         *
         * @param bool|string|array|Status $submitResult Output from HTMLForm::trySubmit()
         *
 -       * @return string
 +       * @return string HTML
         */
        function getHTML( $submitResult ) {
                # For good measure (it is the default)
                        ) . "\n";
                }
  
 +              // 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' ) );
 +
                foreach ( $this->mButtons as $button ) {
                        $attrs = array(
                                'type' => 'submit',
                                'value' => $button['value']
                        );
  
 +                      if ( isset( $button['label-message'] ) ) {
 +                              $label = $this->msg( $button['label-message'] )->parse();
 +                      } elseif ( isset( $button['label'] ) ) {
 +                              $label = htmlspecialchars( $button['label'] );
 +                      } elseif ( isset( $button['label-raw'] ) ) {
 +                              $label = $button['label-raw'];
 +                      } else {
 +                              $label = htmlspecialchars( $button['value'] );
 +                      }
 +
                        if ( $button['attribs'] ) {
                                $attrs += $button['attribs'];
                        }
                                $attrs['class'][] = 'mw-ui-button';
                        }
  
 -                      $buttons .= Html::element( 'input', $attrs ) . "\n";
 +                      if ( $isBadIE ) {
 +                              $buttons .= Html::element( 'input', $attrs ) . "\n";
 +                      } else {
 +                              $buttons .= Html::rawElement( 'button', $attrs, $label ) . "\n";
 +                      }
                }
  
                $html = Html::rawElement( 'span',
         */
        public function setSubmitDestructive() {
                $this->mSubmitFlags = array( 'destructive', 'primary' );
-               return $this;
        }
  
        /**
         */
        public function setSubmitProgressive() {
                $this->mSubmitFlags = array( 'progressive', 'primary' );
-               return $this;
        }
  
        /**