Also change the wrapping on both forms to use a <fieldset>, which is visually more consistent with the other forms we have floating around the site. Add visualClear to all HTMLForm forms, and remove all the redundant CSS for the login form, quite a bit of which has been dead for a while.
protected $mMessagePrefix;
protected $mFlatFields;
protected $mFieldTree;
- protected $mShowReset;
+ protected $mShowReset = false;
public $mFieldData;
+
protected $mSubmitCallback;
protected $mValidationErrorMessage;
- protected $mIntro;
+
+ protected $mPre = '';
+ protected $mHeader = '';
+ protected $mPost = '';
+
protected $mSubmitID;
protected $mSubmitText;
protected $mTitle;
protected $mHiddenFields = array();
protected $mButtons = array();
+
+ protected $mWrapperLegend = false;
/**
* Build a new HTMLForm from an array of field attributes
}
$this->mFieldTree = $loadedDescriptor;
-
- $this->mShowReset = true;
}
/**
function setValidationErrorMessage( $msg ) {
$this->mValidationErrorMessage = $msg;
}
+
+ /**
+ * Set the introductory message, overwriting any existing message.
+ * @param $msg String complete text of message to display
+ */
+ function setIntro( $msg ) { $this->mPre = $msg; }
/**
- * Set the introductory message
+ * Add introductory text.
* @param $msg String complete text of message to display
*/
- function setIntro( $msg ) {
- $this->mIntro = $msg;
- }
+ function addPreText( $msg ) { $this->mPre .= $msg; }
+
+ /**
+ * Add header text, inside the form.
+ * @param $msg String complete text of message to display
+ */
+ function addHeaderText( $msg ) { $this->mHeader .= $msg; }
+
+ /**
+ * Add text to the end of the display.
+ * @param $msg String complete text of message to display
+ */
+ function addPostText( $msg ) { $this->mPost .= $msg; }
/**
* Add a hidden field to the output
$this->displayErrors( $submitResult );
}
- if ( isset( $this->mIntro ) ) {
- $wgOut->addHTML( $this->mIntro );
- }
-
- $html = $this->getBody();
-
- // Hidden fields
- $html .= $this->getHiddenFields();
-
- // Buttons
- $html .= $this->getButtons();
+ $html = ''
+ . $this->mHeader
+ . $this->getBody()
+ . $this->getHiddenFields()
+ . $this->getButtons()
+ ;
$html = $this->wrapForm( $html );
- $wgOut->addHTML( $html );
+ $wgOut->addHTML( ''
+ . $this->mPre
+ . $html
+ . $this->mPost
+ );
}
/**
* @return String wrapped HTML.
*/
function wrapForm( $html ) {
+
+ # Include a <fieldset> wrapper for style, if requested.
+ if( $this->mWrapperLegend !== false ){
+ $html = Xml::fieldset( $this->mWrapperLegend, $html );
+ }
+
return Html::rawElement(
'form',
array(
'action' => $this->getTitle()->getFullURL(),
'method' => 'post',
+ 'class' => 'visualClear',
),
$html
);
function setSubmitID( $t ) {
$this->mSubmitID = $t;
}
+
+ /**
+ * Prompt the whole form to be wrapped in a <fieldset>, with
+ * this text as its <legend> element.
+ * @param $legend String HTML to go inside the <legend> element.
+ * Will be escaped
+ */
+ public function setWrapperLegend( $legend ){ $this->mWrapperLegend = $legend; }
/**
* Set the prefix for various default messages
unset( $this->mFormFields['Email'] );
} else {
if( $wgEmailConfirmToEdit ){
- $this->mFormFields['Email']['label-help'] = 'prefs-help-email-required';
+ $this->mFormFields['Email']['help-message'] = 'prefs-help-email-required';
$this->mFormFields['Email']['required'] = '';
} else {
- $this->mFormFields['Email']['label-help'] = 'prefs-help-email';
+ $this->mFormFields['Email']['help-message'] = 'prefs-help-email';
}
}
$this->mFormFields['Remember']['checked'] = '1';
}
- $form = new HTMLForm( $this->mFormFields, '' );
+ $form = new HTMLForm( $this->mFormFields );
+
$form->setTitle( $this->getTitle() );
$form->setSubmitText( wfMsg( 'createaccount' ) );
$form->setSubmitId( 'wpCreateaccount' );
$form->suppressReset();
- $form->loadData();
+ $form->setWrapperLegend( wfMsg( 'createaccount' ) );
+
$form->addHiddenField( 'returnto', $this->mReturnTo );
$form->addHiddenField( 'returntoquery', $this->mReturnToQuery );
+ $form->addHeaderText( ''
+ . Html::rawElement( 'p', array( 'id' => 'userloginlink' ),
+ $link )
+ . $this->mFormHeader
+ . $langSelector
+ );
+ $form->addPreText( ''
+ . $msg
+ . Html::rawElement(
+ 'div',
+ array( 'id' => 'signupstart' ),
+ wfMsgExt( 'loginstart', array( 'parseinline' ) )
+ )
+ );
+ $form->addPostText(
+ Html::rawElement(
+ 'div',
+ array( 'id' => 'signupend' ),
+ wfMsgExt( 'loginend', array( 'parseinline' ) )
+ )
+ );
+
# Add a 'send password by email' button if available
if( $wgEnableEmail && $wgUser->isLoggedIn() ){
$form->addButton(
);
}
- $formContents = ''
- . Html::rawElement( 'p', array( 'id' => 'userloginlink' ),
- $link )
- . $this->mFormHeader
- . $langSelector
- . $form->getBody()
- . $form->getHiddenFields()
- . $form->getButtons()
- ;
+ $form->loadData();
$wgOut->setPageTitle( wfMsg( 'createaccount' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->disallowUserJs(); # Stop malicious userscripts sniffing passwords
- $wgOut->addHTML(
- Html::rawElement(
- 'div',
- array( 'id' => 'loginstart' ),
- wfMsgExt( 'loginstart', array( 'parseinline' ) )
- ) .
- $msg .
- Html::rawElement(
- 'div',
- array( 'id' => 'userloginForm' ),
- $form->wrapForm( $formContents )
- ) .
- Html::rawElement(
- 'div',
- array( 'id' => 'loginend' ),
- wfMsgExt( 'loginend', array( 'parseinline' ) )
- )
- );
+
+ $form->displayForm( false );
}
$form->setSubmitText( wfMsg( 'login' ) );
$form->setSubmitId( 'wpLoginAttempt' );
$form->suppressReset();
- $form->loadData();
+ $form->setWrapperLegend( wfMsg( 'userlogin' ) );
+
$form->addHiddenField( 'returnto', $this->mReturnTo );
$form->addHiddenField( 'returntoquery', $this->mReturnToQuery );
+ $form->addHeaderText( ''
+ . Html::rawElement( 'p', array( 'id' => 'userloginlink' ),
+ $link )
+ . Html::rawElement( 'div', array( 'id' => 'userloginprompt' ),
+ wfMsgExt( 'loginprompt', array( 'parseinline' ) ) )
+ . $this->mFormHeader
+ . $langSelector
+ );
+ $form->addPreText( ''
+ . $msg
+ . Html::rawElement(
+ 'div',
+ array( 'id' => 'loginstart' ),
+ wfMsgExt( 'loginstart', array( 'parseinline' ) )
+ )
+ );
+ $form->addPostText(
+ Html::rawElement(
+ 'div',
+ array( 'id' => 'loginend' ),
+ wfMsgExt( 'loginend', array( 'parseinline' ) )
+ )
+ );
+
# Add a 'mail reset' button if available
$buttons = '';
if( $wgEnableEmail && $wgAuth->allowPasswordChange() ){
);
}
- $formContents = ''
- . Html::rawElement( 'p', array( 'id' => 'userloginlink' ),
- $link )
- . Html::rawElement( 'div', array( 'id' => 'userloginprompt' ),
- wfMsgExt( 'loginprompt', array( 'parseinline' ) ) )
- . $this->mFormHeader
- . $langSelector
- . $form->getBody()
- . $form->getHiddenFields()
- . $form->getButtons()
- ;
+ $form->loadData();
$wgOut->setPageTitle( wfMsg( 'login' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->disallowUserJs(); # Stop malicious userscripts sniffing passwords
- $wgOut->addHTML(
- Html::rawElement(
- 'div',
- array( 'id' => 'loginstart' ),
- wfMsgExt( 'loginstart', array( 'parseinline' ) )
- ) .
- $msg .
- Html::rawElement(
- 'div',
- array( 'id' => 'userloginForm' ),
- $form->wrapForm( $formContents )
- ) .
- Html::rawElement(
- 'div',
- array( 'id' => 'loginend' ),
- wfMsgExt( 'loginend', array( 'parseinline' ) )
- )
- );
+ $form->displayForm( '' );
}
/**
'logout' => 'Log out',
'userlogout' => 'Log out',
'notloggedin' => 'Not logged in',
-'nologin' => "Don't have an account? $1.",
+'nologin' => "Don't have an account? '''$1'''.",
'nologinlink' => 'Create an account',
'createaccount' => 'Create account',
-'gotaccount' => 'Already have an account? $1.',
+'gotaccount' => "Already have an account? '''$1'''.",
'gotaccountlink' => 'Log in',
'createaccountmail' => 'by e-mail',
'badretype' => 'The passwords you entered do not match.',
margin-top: 2em;
}
-div#userloginForm form,
-div#userlogin form#userlogin2 {
- margin: 0 3em 1em 0;
- border: 1px solid #aaa;
- clear: both;
- padding: 1.5em 2em;
- background-color: #f9f9f9;
- float: left;
-}
-.rtl div#userloginForm form,
-.rtl div#userlogin form#userlogin2 {
- float: right;
-}
-
-div#userloginForm table,
-div#userlogin form#userlogin2 table {
- background-color: #f9f9f9;
-}
-
-div#userloginForm h2,
-div#userlogin form#userlogin2 h2 {
- padding-top: 0;
-}
-
-div#userlogin .captcha,
-div#userloginForm .captcha {
- border: 1px solid #bbb;
- padding: 1.5em 2em;
- background-color: white;
-}
-
-#loginend, #signupend {
- clear: both;
-}
-
#userloginprompt, #languagelinks {
font-size: 85%;
}
-#login-sectiontip {
- font-size: 85%;
- line-height: 1.2;
- padding-top: 2em;
-}
-
-#userlogin .loginText, #userlogin .loginPassword {
- width: 12em;
-}
-
-#userloginlink a, #wpLoginattempt, #wpCreateaccount {
- font-weight: bold;
-}
-
/*
** IE/Mac fixes, hope to find a validating way to move this
** to a separate stylesheet. This would work but doesn't validate: