X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLForm.php;h=05fb44eeec4af66d938f2fa80213c87dff8a6677;hb=d949901f3cc991d41d10eb2b2dcf62a46c1ff6bd;hp=e51620f20846d4f8e493b41d78139d4a9e90c6ba;hpb=235219d34b1382d8b0130f1e9ff88108f466cc8b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index e51620f208..05fb44eeec 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -128,6 +128,7 @@ class HTMLForm extends ContextSource { 'textwithbutton' => 'HTMLTextFieldWithButton', 'textarea' => 'HTMLTextAreaField', 'select' => 'HTMLSelectField', + 'combobox' => 'HTMLComboboxField', 'radio' => 'HTMLRadioField', 'multiselect' => 'HTMLMultiSelectField', 'limitselect' => 'HTMLSelectLimitField', @@ -854,15 +855,53 @@ class HTMLForm extends ContextSource { /** * 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; } @@ -1040,6 +1079,9 @@ class HTMLForm extends ContextSource { ) . "\n"; } + // IE<8 has bugs with