var $mType, $mReason, $mRealName;
var $mAbortLoginErrorMsg = 'login-abort-generic';
private $mLoaded = false;
+ private $mSecureLoginUrl;
+ // TODO Remove old forms and mShowVForm gating after all WMF wikis have
+ // adapted messages and help links to new versions.
+ private $mShowVForm;
/**
* @ var WebRequest
*/
private $mOverrideRequest = null;
+ /**
+ * Effective request; set at the beginning of load
+ *
+ * @var WebRequest $mRequest
+ */
+ private $mRequest = null;
+
/**
* @param WebRequest $request
*/
} else {
$request = $this->mOverrideRequest;
}
+ $this->mRequest = $request;
$this->mType = $request->getText( 'type' );
$this->mUsername = $request->getText( 'wpName' );
$this->mReturnTo = '';
$this->mReturnToQuery = '';
}
+
+ $this->mShowVForm = $this->shouldShowVForm();
}
function getDescription() {
- return $this->msg( $this->getUser()->isAllowed( 'createaccount' ) ?
- 'userlogin' : 'userloginnocreate' )->text();
+ if ( !$this->getUser()->isAllowed( 'createaccount' ) ) {
+ return $this->msg( 'userloginnocreate' )->text();
+ }
+ if ( $this->mShowVForm ) {
+ if ( $this->mType === 'signup' ) {
+ return $this->msg( 'createaccount' )->text();
+ } else {
+ return $this->msg( 'login' )->text();
+ }
+ } else {
+ return $this->msg( 'userlogin' )->text();
+ }
}
public function execute( $par ) {
$this->load();
$this->setHeaders();
+ if ( $par == 'signup' ) { # Check for [[Special:Userlogin/signup]]
+ $this->mType = 'signup';
+ }
+
+ // If logging in and not on HTTPS, either redirect to it or offer a link.
global $wgSecureLogin;
if (
$this->mType !== 'signup' &&
- $wgSecureLogin &&
WebRequest::detectProtocol() !== 'https'
) {
$title = $this->getFullTitle();
'wpStickHTTPS' => $this->mStickHTTPS
);
$url = $title->getFullURL( $query, false, PROTO_HTTPS );
- $this->getOutput()->redirect( $url );
- return;
- }
-
- if ( $par == 'signup' ) { # Check for [[Special:Userlogin/signup]]
- $this->mType = 'signup';
+ if ( $wgSecureLogin ) {
+ $this->getOutput()->redirect( $url );
+ return;
+ } else {
+ // A wiki without HTTPS login support should set $wgServer to
+ // http://somehost, in which case the secure URL generated
+ // above won't actually start with https://
+ if ( substr( $url, 0, 8 ) === 'https://' ) {
+ $this->mSecureLoginUrl = $url;
+ }
+ }
}
if ( !is_null( $this->mCookieCheck ) ) {
}
}
+ /**
+ * Whether to show new vertically laid out login form.
+ * ?useNew=1 forces new style, ?useNew=0 forces old style,
+ * otherwise consult $wgUseVFormUserLogin.
+ * @return Boolean
+ */
+ private function shouldShowVForm() {
+ global $wgUseVFormUserLogin;
+
+ if ( $this->mType == 'signup' ) {
+ return false;
+ } else {
+ return $this->mRequest->getBool( 'useNew', $wgUseVFormUserLogin );
+ }
+ }
+
/**
* @private
*/
$titleObj = $this->getTitle();
$user = $this->getUser();
+ $out = $this->getOutput();
if ( $this->mType == 'signup' ) {
// Block signup here if in readonly. Keeps user from
$q = 'action=submitlogin&type=signup';
$linkq = 'type=login';
$linkmsg = 'gotaccount';
- $this->getOutput()->addModules( 'mediawiki.special.userlogin.signup' );
+ $out->addModules( 'mediawiki.special.userlogin.signup' );
} else {
- $template = new UserloginTemplate();
+ if ( $this->mShowVForm ) {
+ $template = new UserloginTemplateVForm();
+ $out->addModuleStyles( array(
+ 'mediawiki.ui',
+ 'mediawiki.special.userlogin.vform'
+ ) );
+ } else {
+ $template = new UserloginTemplate();
+ }
$q = 'action=submitlogin&type=login';
$linkq = 'type=signup';
$linkmsg = 'nologin';
$linkq .= $returnto;
}
- # Don't show a "create account" link if the user can't
+ # Don't show a "create account" link if the user can't.
if( $this->showCreateOrLoginLink( $user ) ) {
# Pass any language selection on to the mode switch link
if( $wgLoginLanguageSelector && $this->mLanguage ) {
$linkq .= '&uselang=' . $this->mLanguage;
}
- $link = Html::element( 'a', array( 'href' => $titleObj->getLocalURL( $linkq ) ),
- $this->msg( $linkmsg . 'link' )->text() ); # Calling either 'gotaccountlink' or 'nologinlink'
+ if ( !$this->mShowVForm ) {
+ $link = Html::element( 'a', array( 'href' => $titleObj->getLocalURL( $linkq ) ),
+ $this->msg( $linkmsg . 'link' )->text() ); # Calling either 'gotaccountlink' or 'nologinlink'
+
+ $template->set( 'link', $this->msg( $linkmsg )->rawParams( $link )->parse() );
- $template->set( 'link', $this->msg( $linkmsg )->rawParams( $link )->parse() );
+ } else {
+ // Supply URL, login template creates the button.
+ // (The template 'link' key, passed above, is obsolete in the VForm design.)
+ $template->set( 'createOrLoginHref', $titleObj->getLocalURL( $linkq ) );
+ }
} else {
$template->set( 'link', '' );
}
}
}
+ $template->set( 'secureLoginUrl', $this->mSecureLoginUrl );
// Use loginend-https for HTTPS requests if it's not blank, loginend otherwise
- // Ditto for signupend
+ // Ditto for signupend. New forms use neither.
$usingHTTPS = WebRequest::detectProtocol() == 'https';
$loginendHTTPS = $this->msg( 'loginend-https' );
$signupendHTTPS = $this->msg( 'signupend-https' );
wfRunHooks( 'UserLoginForm', array( &$template ) );
}
- $out = $this->getOutput();
$out->disallowUserJs(); // just in case...
$out->addTemplate( $template );
}