From 0589bee118696da6644f3177136bf35e672ba4b9 Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 22 May 2016 01:36:21 +0200 Subject: [PATCH] Special:UserLogin: Consolidate create account buttons When logged in and not logged in. Both now shares the same styles and DOM structure. The differences: * When logged in, you don't get a "Don't have an account?" message * When logged in, the button's label is "Create another account" instead of "Join {wikiname}" Bug: T135925 Change-Id: I90c7a1288af927a03da3ccf9499f625935742125 --- .../specialpage/LoginSignupSpecialPage.php | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index 0e4252c9e8..66718f9f9e 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -652,37 +652,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 ); } } -- 2.20.1