protected $mEntryErrorType = 'error';
protected $mLoaded = false;
+ protected $mLoadedRequest = false;
protected $mSecureLoginUrl;
/** @var string */
$wgUseMediaWikiUIEverywhere = true;
}
+ protected function setRequest( array $data, $wasPosted = null ) {
+ parent::setRequest( $data, $wasPosted );
+ $this->mLoadedRequest = false;
+ }
+
/**
- * Load data from request.
- * @private
- * @param string $subPage Subpage of Special:Userlogin
+ * Load basic request parameters for this Special page.
+ * @param $subPage
*/
- protected function load( $subPage ) {
- global $wgSecureLogin;
-
- if ( $this->mLoaded ) {
+ private function loadRequestParameters( $subPage ) {
+ if ( $this->mLoadedRequest ) {
return;
}
- $this->mLoaded = true;
-
+ $this->mLoadedRequest = true;
$request = $this->getRequest();
$this->mPosted = $request->wasPosted();
$this->mLanguage = $request->getText( 'uselang' );
$this->mReturnTo = $request->getVal( 'returnto', '' );
$this->mReturnToQuery = $request->getVal( 'returntoquery', '' );
+ }
+
+ /**
+ * Load data from request.
+ * @private
+ * @param string $subPage Subpage of Special:Userlogin
+ */
+ protected function load( $subPage ) {
+ global $wgSecureLogin;
+
+ $this->loadRequestParameters( $subPage );
+ if ( $this->mLoaded ) {
+ return;
+ }
+ $this->mLoaded = true;
+ $request = $this->getRequest();
$securityLevel = $this->getRequest()->getText( 'force' );
if (
return $params;
}
+ protected function beforeExecute( $subPage ) {
+ // finish initializing the class before processing the request - T135924
+ $this->loadRequestParameters( $subPage );
+ return parent::beforeExecute( $subPage );
+ }
+
/**
* @param string|null $subPage
*/
// add pre/post text
// header used by ConfirmEdit, CondfirmAccount, Persona, WikimediaIncubator, SemanticSignup
// should be above the error message but HTMLForm doesn't support that
- $form->addHeaderText( $fakeTemplate->html( 'header' ) );
+ $form->addHeaderText( $fakeTemplate->get( 'header' ) );
// FIXME the old form used this for error/warning messages which does not play well with
// HTMLForm (maybe it could with a subclass?); for now only display it for signups
}
// header used by MobileFrontend
- $form->addHeaderText( $fakeTemplate->html( 'formheader' ) );
+ $form->addHeaderText( $fakeTemplate->get( 'formheader' ) );
// blank signup footer for site customization
if ( $this->isSignup() && $this->showExtraInformation() ) {
if ( $wgLoginLanguageSelector && $this->mLanguage ) {
$linkq .= '&uselang=' . $this->mLanguage;
}
- $createOrLoginHref = $linkTitle->getLocalURL( $linkq );
-
- if ( $this->getUser()->isLoggedIn() ) {
- $createOrLoginHtml = Html::rawElement( 'div',
- [ 'class' => 'mw-ui-vform-field' ],
- Html::element( 'a',
- [
- 'id' => 'mw-createaccount-join',
- 'href' => $createOrLoginHref,
- // put right after all auth inputs in the tab order
- 'tabindex' => 100,
- ],
- $this->msg( 'userlogin-createanother' )->escaped()
- )
- );
- } else {
- $createOrLoginHtml = Html::rawElement( 'div',
- [ 'id' => 'mw-createaccount-cta',
- 'class' => 'mw-ui-vform-field' ],
- $this->msg( 'userlogin-noaccount' )->escaped()
- . Html::element( 'a',
- [
- 'id' => 'mw-createaccount-join',
- 'href' => $createOrLoginHref,
- 'class' => 'mw-ui-button',
- 'tabindex' => 100,
- ],
- $this->msg( 'userlogin-joinproject' )->escaped()
- )
- );
- }
+
+ $loggedIn = $this->getUser()->isLoggedIn();
+ $createOrLoginHtml = Html::rawElement( 'div',
+ [ 'id' => 'mw-createaccount' . ( !$loggedIn ? '-cta' : '' ),
+ 'class' => ( $loggedIn ? 'mw-form-related-link-container' : 'mw-ui-vform-field' ) ],
+ ( $loggedIn ? '' : $this->msg( 'userlogin-noaccount' )->escaped() )
+ . Html::element( 'a',
+ [
+ 'id' => 'mw-createaccount-join' . ( $loggedIn ? '-loggedin' : '' ),
+ 'href' => $linkTitle->getLocalURL( $linkq ),
+ 'class' => ( $loggedIn ? '' : 'mw-ui-button' ),
+ 'tabindex' => 100,
+ ],
+ $this->msg(
+ ( $this->getUser()->isLoggedIn() ?
+ 'userlogin-createanother' :
+ 'userlogin-joinproject'
+ ) )->escaped()
+ )
+ );
$form->addFooterText( $createOrLoginHtml );
}
}
array $requests, array $fieldInfo, array &$formDescriptor, $action
) {
$coreFieldDescriptors = $this->getFieldDefinitions( $this->fakeTemplate );
- $specialFields = array_merge( [ 'extraInput', 'linkcontainer' ],
+ $specialFields = array_merge( [ 'extraInput', 'linkcontainer', 'entryError' ],
array_keys( $this->fakeTemplate->getExtraInputDefinitions() ) );
// keep the ordering from getCoreFieldDescriptors() where there is no explicit weight
!isset( $coreField['baseField'] )
|| !isset( $fieldInfo[$coreField['baseField']] )
) && !in_array( $fieldName, $specialFields, true )
- && $coreField['type'] !== 'submit'
+ && ( !isset( $coreField['type'] ) || $coreField['type'] !== 'submit' )
) {
$coreFieldDescriptors[$fieldName] = null;
continue;
'linkcontainer' => [
// help link
'type' => 'info',
- 'cssclass' => 'mw-form-related-link-container',
- 'id' => 'mw-userlogin-help',
+ 'cssclass' => 'mw-form-related-link-container mw-userlogin-help',
+ // 'id' => 'mw-userlogin-help', // FIXME HTMLInfoField ignores this
'raw' => true,
'default' => Html::element( 'a', [
'href' => Skin::makeInternalOrExternalUrl( wfMessage( 'helplogin-url' )
], $this->msg( 'userlogin-helplink2' )->text() ),
'weight' => 200,
],
+ // button for ResetPasswordSecondaryAuthenticationProvider
+ 'skipReset' => [
+ 'weight' => 110,
+ 'flags' => [],
+ ],
];
}
$fieldDefinitions['username'] += [
// 'required' => true,
];
+ if ( $this->mEntryError ) {
+ $fieldDefinitions['entryError'] = [
+ 'type' => 'info',
+ 'default' => Html::rawElement( 'div', [ 'class' => $this->mEntryErrorType . 'box', ],
+ $this->mEntryError ),
+ 'raw' => true,
+ 'rawrow' => true,
+ 'weight' => -100,
+ ];
+ }
+
if ( !$this->showExtraInformation() ) {
unset( $fieldDefinitions['linkcontainer'] );
}