X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FHTMLForm.php;h=10ac65d68bc5265a26a3a08706de5d0ae59cf724;hb=5833ddcfc5ef7f586320693cef4c8cfdd29c1769;hp=69ec1007c262ae32cc5fdc603e506816facadae2;hpb=d8887852c03605a943ba0bd377c9eebe6e08d5cd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 69ec1007c2..10ac65d68b 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1,107 +1,1391 @@ $info, + * where $info is an Associative Array with any of the following: + * + * 'class' -- the subclass of HTMLFormField that will be used + * to create the object. *NOT* the CSS class! + * 'type' -- roughly translates into the \n"; + + return $html; } /** - * @private - * @param $varname String: name of the textbox. - * @param $value String: optional value (default empty) - * @param $size Integer: optional size of the textbox (default 20) + * Get the submit and (potentially) reset buttons. + * @return String HTML. */ - function textbox( $varname, $value='', $size=20 ) { - if ( $this->mRequest->wasPosted() ) { - $value = $this->mRequest->getText( $varname, $value ); + function getButtons() { + $html = ''; + + $attribs = array(); + + if ( isset( $this->mSubmitID ) ) + $attribs['id'] = $this->mSubmitID; + if ( isset( $this->mSubmitName ) ) + $attribs['name'] = $this->mSubmitName; + if ( isset( $this->mSubmitTooltip ) ) { + global $wgUser; + $attribs += $wgUser->getSkin()->tooltipAndAccessKeyAttribs( $this->mSubmitTooltip ); + } + + $attribs['class'] = 'mw-htmlform-submit'; + + $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; + + if( $this->mShowReset ) { + $html .= Html::element( + 'input', + array( + 'type' => 'reset', + 'value' => wfMsg( 'htmlform-reset' ) + ) + ) . "\n"; + } + + foreach( $this->mButtons as $button ){ + $attrs = array( + 'type' => 'submit', + 'name' => $button['name'], + 'value' => $button['value'] + ); + if ( $button['attribs'] ) + $attrs += $button['attribs']; + if( isset( $button['id'] ) ) + $attrs['id'] = $button['id']; + $html .= Html::element( 'input', $attrs ); } - $value = htmlspecialchars( $value ); - return "
\n"; + + return $html; } /** - * @private - * @param $varname String: name of the radiobox. - * @param $fields Array: Various fields. + * Get the whole body of the form. */ - function radiobox( $varname, $fields ) { - foreach ( $fields as $value => $checked ) { - $s .= "
\n"; + function getBody() { + return $this->displaySection( $this->mFieldTree ); + } + + /** + * Format and display an error message stack. + * @param $errors Mixed String or Array of message keys + */ + function displayErrors( $errors ) { + if ( is_array( $errors ) ) { + $errorstr = $this->formatErrors( $errors ); + } else { + $errorstr = $errors; } - return $this->fieldset( $varname, $s ); + + $errorstr = Html::rawElement( 'div', array( 'class' => 'error' ), $errorstr ); + + global $wgOut; + $wgOut->addHTML( $errorstr ); } /** - * @private - * @param $varname String: name of the textareabox. - * @param $value String: optional value (default empty) - * @param $size Integer: optional size of the textarea (default 20) + * Format a stack of error messages into a single HTML string + * @param $errors Array of message keys/values + * @return String HTML, a