public function execute( $par ) { global $wgUser, $wgOut; // Loads styles when javascript is disabled as well $wgOut->addModuleStyles( 'ext.styleguidedemo.css' ); // Enhancements $wgOut->addModules( 'ext.styleguidedemo.js' ); $this->setHeaders(); // Form One $wgOut->wrapWikiMsg( "<h2 class=\"mw-specialpagesgroup\" id=\"mw-styleguidedemo-createform\">$1</h2>\n", 'styleguidedemo-head-createform' ); $formOne = array( 'Username' => array( 'label-message' => 'styleguidedemo-username', 'required' => true, 'type' => 'text', 'help-message' => array( 'styleguidedemo-username-help', wfMsg( 'styleguidedemo-username-infopage' ) ), 'hint-message' => 'styleguidedemo-username-hint', 'placeholder' => 'John Doe', ), 'Password' => array( 'label-message' => 'styleguidedemo-password', 'required' => true, 'type' => 'password', 'help-message' => array( 'styleguidedemo-password-help', wfMsg( 'styleguidedemo-password-infopage' ) ), ), 'ConfirmPassword' => array( 'label-message' => 'styleguidedemo-confirmpassword', 'required' => true, 'type' => 'password', 'help-message' => 'styleguidedemo-confirmpassword-help', ), 'Email' => array( 'label-message' => 'styleguidedemo-email', 'type' => 'text', 'help-message' => array( 'styleguidedemo-email-help', wfMsg( 'styleguidedemo-email-infopage' ) ), 'hint-message' => 'styleguidedemo-email-hint', 'placeholder' => wfMsg( 'styleguidedemo-email-placeholder' ), ), ); $form = new HTMLStyleForm( $formOne ); $form->setTitle( $wgOut->getTitle() ); $form->setSubmitID( 'wpCreateaccount' ); $form->setSubmitName( 'wpCreateaccount' ); $form->setSubmitText( wfMsg( 'createaccount' ) ); $form->show(); }
/** * Get the complete form "row" for the input, including help text, * labels, and whatever. * @param $value String the value to set the input to. * @return String complete HTML form row. */ function getFormRow( $value ) { # Check for invalid data. $errors = $this->validate( $value, $this->mParent->mFieldData ); $attributes = array(); if ( $errors === true || ( !$this->mParent->getRequest()->wasPosted() && ( $this->mParent->getMethod() == 'post' ) ) ) { $errors = ''; $errorClass = ''; } else { $errors = self::formatErrors( $errors ); $errorClass = 'mw-htmlform-invalid-input'; } # Hint / Tip $hinttext = null; $hinthtml = ''; $afterLabelHtml = ''; // inserted into mw-label after the <label> if ( isset( $this->mParams['hint-message'] ) ) { $msg = call_user_func_array( 'wfMessage', (array)$this->mParams['hint-message'] ); if ( $msg->exists() ) { $hinttext = $msg->parse(); } } elseif ( isset( $this->mParams['hint'] ) ) { $hinttext = $this->mParams['hint']; } if ( !is_null( $hinttext ) ) { $hinthtml = "<div class=\"mw-help-field-container\">\n" . "<span class=\"mw-help-field-hint\"></span>\n" . "<span class=\"mw-help-field-data\">" . $hinttext . "</span>\n" . "</div>\n"; } # Required ? if ( isset( $this->mParams['required'] ) ) { $afterLabelHtml .= Html::element( 'span', array( 'class' => 'mw-htmlform-required-tip', ), wfMsg( 'parentheses', wfMsg( 'htmlform-required-tip' ) ) ); } # Label $label = $this->getLabelHtml( $attributes, $hinthtml, $afterLabelHtml ); # Help message (optional) $helptext = null; $helphtml = ''; if ( isset( $this->mParams['help-message'] ) ) { $msg = call_user_func_array( 'wfMessage', (array)$this->mParams['help-message'] ); if ( $msg->exists() ) { $helptext = $msg->parse(); } } elseif ( isset( $this->mParams['help-messages'] ) ) { # help-message can be passed a message key (string) or an array containing # a message key and additional parameters. This makes it impossible to pass # an array of message key foreach( $this->mParams['help-messages'] as $name ) { $msg = wfMessage( $name ); if( $msg->exists() ) { $helptext .= $msg->parse(); // append message } } } elseif ( isset( $this->mParams['help'] ) ) { $helptext = $this->mParams['help']; } if ( !is_null( $helptext ) && $helptext != '' ) { $helphtml = Html::rawElement( 'div', array( 'class' => 'mw-htmlform-tip', ), $helptext ); } # Input $field = Html::rawElement( 'div', array( 'class' => 'mw-input' ) + $attributes, $this->getInputHTML( $value ) . "\n$errors" ); $fieldType = get_class( $this ); $html = Html::rawElement( 'div', array( 'class' => "mw-htmlform-field mw-htmlform-field-$fieldType {$this->mClass} $errorClass" ), $label . $helphtml . $field ); return $html; }