X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FLoginSignupSpecialPage.php;h=133729ae76df6162bbd347e513ffa3e4e26be1c2;hb=50c3fdc2db6346b1025e7549bd9792e2ef2a0e22;hp=bd6b08f9c20df21a58843a57310e19a33c0e024c;hpb=a0e630ce6dcc16d4d22547749da9fba8ae3359aa;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index bd6b08f9c2..133729ae76 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -47,6 +47,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { protected $mEntryErrorType = 'error'; protected $mLoaded = false; + protected $mLoadedRequest = false; protected $mSecureLoginUrl; /** @var string */ @@ -89,19 +90,20 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { $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(); @@ -114,6 +116,22 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { $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 ( @@ -185,6 +203,12 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { 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 */ @@ -596,7 +620,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { // 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 @@ -609,7 +633,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { } // 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() ) { @@ -652,37 +676,26 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { 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 ); } } @@ -841,7 +854,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { !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; @@ -1037,6 +1050,11 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { ], $this->msg( 'userlogin-helplink2' )->text() ), 'weight' => 200, ], + // button for ResetPasswordSecondaryAuthenticationProvider + 'skipReset' => [ + 'weight' => 110, + 'flags' => [], + ], ]; } $fieldDefinitions['username'] += [