4 * @addtogroup SpecialPage
10 function wfSpecialUserlogin() {
12 if( session_id() == '' ) {
16 $form = new LoginForm( $wgRequest );
21 * implements Special:Login
22 * @addtogroup SpecialPage
29 const WRONG_PLUGIN_PASS
= 3;
36 var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
37 var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
38 var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
42 * @param WebRequest $request A WebRequest object passed by reference
44 function LoginForm( &$request ) {
45 global $wgLang, $wgAllowRealName, $wgEnableEmail;
48 $this->mType
= $request->getText( 'type' );
49 $this->mName
= $request->getText( 'wpName' );
50 $this->mPassword
= $request->getText( 'wpPassword' );
51 $this->mRetype
= $request->getText( 'wpRetype' );
52 $this->mDomain
= $request->getText( 'wpDomain' );
53 $this->mReturnTo
= $request->getVal( 'returnto' );
54 $this->mCookieCheck
= $request->getVal( 'wpCookieCheck' );
55 $this->mPosted
= $request->wasPosted();
56 $this->mCreateaccount
= $request->getCheck( 'wpCreateaccount' );
57 $this->mCreateaccountMail
= $request->getCheck( 'wpCreateaccountMail' )
59 $this->mMailmypassword
= $request->getCheck( 'wpMailmypassword' )
61 $this->mLoginattempt
= $request->getCheck( 'wpLoginattempt' );
62 $this->mAction
= $request->getVal( 'action' );
63 $this->mRemember
= $request->getCheck( 'wpRemember' );
64 $this->mLanguage
= $request->getText( 'uselang' );
66 if( $wgEnableEmail ) {
67 $this->mEmail
= $request->getText( 'wpEmail' );
71 if( $wgAllowRealName ) {
72 $this->mRealName
= $request->getText( 'wpRealName' );
74 $this->mRealName
= '';
77 if( !$wgAuth->validDomain( $this->mDomain
) ) {
78 $this->mDomain
= 'invaliddomain';
80 $wgAuth->setDomain( $this->mDomain
);
82 # When switching accounts, it sucks to get automatically logged out
83 if( $this->mReturnTo
== $wgLang->specialPage( 'Userlogout' ) ) {
84 $this->mReturnTo
= '';
89 if ( !is_null( $this->mCookieCheck
) ) {
90 $this->onCookieRedirectCheck( $this->mCookieCheck
);
92 } else if( $this->mPosted
) {
93 if( $this->mCreateaccount
) {
94 return $this->addNewAccount();
95 } else if ( $this->mCreateaccountMail
) {
96 return $this->addNewAccountMailPassword();
97 } else if ( $this->mMailmypassword
) {
98 return $this->mailPassword();
99 } else if ( ( 'submitlogin' == $this->mAction
) ||
$this->mLoginattempt
) {
100 return $this->processLogin();
103 $this->mainLoginForm( '' );
109 function addNewAccountMailPassword() {
112 if ('' == $this->mEmail
) {
113 $this->mainLoginForm( wfMsg( 'noemail', htmlspecialchars( $this->mName
) ) );
117 $u = $this->addNewaccountInternal();
123 // Wipe the initial password and mail a temporary one
124 $u->setPassword( null );
126 $result = $this->mailPasswordInternal( $u, false );
128 wfRunHooks( 'AddNewAccount', array( $u ) );
130 $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) );
131 $wgOut->setRobotpolicy( 'noindex,nofollow' );
132 $wgOut->setArticleRelated( false );
134 if( WikiError
::isError( $result ) ) {
135 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
137 $wgOut->addWikiText( wfMsg( 'accmailtext', $u->getName(), $u->getEmail() ) );
138 $wgOut->returnToMain( false );
147 function addNewAccount() {
148 global $wgUser, $wgEmailAuthentication;
150 # Create the account and abort if there's a problem doing so
151 $u = $this->addNewAccountInternal();
155 # If we showed up language selection links, and one was in use, be
156 # smart (and sensible) and save that language as the user's preference
157 global $wgLoginLanguageSelector;
158 if( $wgLoginLanguageSelector && $this->mLanguage
)
159 $u->setOption( 'language', $this->mLanguage
);
161 # Save user settings and send out an email authentication message if needed
163 if( $wgEmailAuthentication && User
::isValidEmailAddr( $u->getEmail() ) ) {
165 $error = $u->sendConfirmationMail();
166 if( WikiError
::isError( $error ) ) {
167 $wgOut->addWikiText( wfMsg( 'confirmemail_sendfailed', $error->getMessage() ) );
169 $wgOut->addWikiText( wfMsg( 'confirmemail_oncreate' ) );
173 # If not logged in, assume the new account as the current one and set session cookies
174 # then show a "welcome" message or a "need cookies" message as needed
175 if( $wgUser->isAnon() ) {
177 $wgUser->setCookies();
178 wfRunHooks( 'AddNewAccount', array( $wgUser ) );
179 if( $this->hasSessionCookie() ) {
180 return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
182 return $this->cookieRedirectCheck( 'new' );
185 # Confirm that the account was created
187 $self = SpecialPage
::getTitleFor( 'Userlogin' );
188 $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
189 $wgOut->setArticleRelated( false );
190 $wgOut->setRobotPolicy( 'noindex,nofollow' );
191 $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
192 $wgOut->returnToMain( false, $self );
193 wfRunHooks( 'AddNewAccount', array( $u ) );
201 function addNewAccountInternal() {
202 global $wgUser, $wgOut;
203 global $wgEnableSorbs, $wgProxyWhitelist;
204 global $wgMemc, $wgAccountCreationThrottle;
205 global $wgAuth, $wgMinimalPasswordLength;
206 global $wgEmailConfirmToEdit;
208 // If the user passes an invalid domain, something is fishy
209 if( !$wgAuth->validDomain( $this->mDomain
) ) {
210 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
214 // If we are not allowing users to login locally, we should
215 // be checking to see if the user is actually able to
216 // authenticate to the authentication server before they
217 // create an account (otherwise, they can create a local account
218 // and login as any domain user). We only need to check this for
219 // domains that aren't local.
220 if( 'local' != $this->mDomain
&& '' != $this->mDomain
) {
221 if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName
) ||
!$wgAuth->authenticate( $this->mName
, $this->mPassword
) ) ) {
222 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
227 if ( wfReadOnly() ) {
228 $wgOut->readOnlyPage();
233 if ( !$wgUser->isAllowed( 'createaccount' ) ) {
234 $this->userNotPrivilegedMessage();
236 } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
237 $this->userBlockedMessage();
242 if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
243 $wgUser->inSorbsBlacklist( $ip ) )
245 $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
249 # Now create a dummy user ($u) and check if it is valid
250 $name = trim( $this->mName
);
251 $u = User
::newFromName( $name, 'creatable' );
252 if ( is_null( $u ) ) {
253 $this->mainLoginForm( wfMsg( 'noname' ) );
257 if ( 0 != $u->idForName() ) {
258 $this->mainLoginForm( wfMsg( 'userexists' ) );
262 if ( 0 != strcmp( $this->mPassword
, $this->mRetype
) ) {
263 $this->mainLoginForm( wfMsg( 'badretype' ) );
267 if ( !$u->isValidPassword( $this->mPassword
) ) {
268 $this->mainLoginForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
272 # if you need a confirmed email address to edit, then obviously you need an email address.
273 if ( $wgEmailConfirmToEdit && empty( $this->mEmail
) ) {
274 $this->mainLoginForm( wfMsg( 'noemailtitle' ) );
278 if( !empty( $this->mEmail
) && !User
::isValidEmailAddr( $this->mEmail
) ) {
279 $this->mainLoginForm( wfMsg( 'invalidemailaddress' ) );
283 # Set some additional data so the AbortNewAccount hook can be
284 # used for more than just username validation
285 $u->setEmail( $this->mEmail
);
286 $u->setRealName( $this->mRealName
);
289 if( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) {
290 // Hook point to add extra creation throttles and blocks
291 wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
292 $this->mainLoginForm( $abortError );
296 if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
297 $key = wfMemcKey( 'acctcreate', 'ip', $ip );
298 $value = $wgMemc->incr( $key );
300 $wgMemc->set( $key, 1, 86400 );
302 if ( $value > $wgAccountCreationThrottle ) {
303 $this->throttleHit( $wgAccountCreationThrottle );
308 if( !$wgAuth->addUser( $u, $this->mPassword
, $this->mEmail
, $this->mRealName
) ) {
309 $this->mainLoginForm( wfMsg( 'externaldberror' ) );
313 return $this->initUser( $u, false );
317 * Actually add a user to the database.
318 * Give it a User object that has been initialised with a name.
320 * @param $u User object.
321 * @param $autocreate boolean -- true if this is an autocreation via auth plugin
322 * @return User object.
325 function initUser( $u, $autocreate ) {
330 if ( $wgAuth->allowPasswordChange() ) {
331 $u->setPassword( $this->mPassword
);
334 $u->setEmail( $this->mEmail
);
335 $u->setRealName( $this->mRealName
);
338 $wgAuth->initUser( $u, $autocreate );
340 $u->setOption( 'rememberpassword', $this->mRemember ?
1 : 0 );
344 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
345 $ssUpdate->doUpdate();
351 * Internally authenticate the login request.
353 * This may create a local account as a side effect if the
354 * authentication plugin allows transparent local account
359 function authenticateUserData() {
360 global $wgUser, $wgAuth;
361 if ( '' == $this->mName
) {
362 return self
::NO_NAME
;
364 $u = User
::newFromName( $this->mName
);
365 if( is_null( $u ) ||
!User
::isUsableName( $u->getName() ) ) {
366 return self
::ILLEGAL
;
368 if ( 0 == $u->getID() ) {
371 * If the external authentication plugin allows it,
372 * automatically create a new account for users that
373 * are externally defined but have not yet logged in.
375 if ( $wgAuth->autoCreate() && $wgAuth->userExists( $u->getName() ) ) {
376 if ( $wgAuth->authenticate( $u->getName(), $this->mPassword
) ) {
377 $u = $this->initUser( $u, true );
379 return self
::WRONG_PLUGIN_PASS
;
382 return self
::NOT_EXISTS
;
388 // Give general extensions, such as a captcha, a chance to abort logins
389 $abort = self
::ABORTED
;
390 if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword
, &$abort ) ) ) {
394 if (!$u->checkPassword( $this->mPassword
)) {
395 if( $u->checkTemporaryPassword( $this->mPassword
) ) {
396 // The e-mailed temporary password should not be used
397 // for actual logins; that's a very sloppy habit,
398 // and insecure if an attacker has a few seconds to
399 // click "search" on someone's open mail reader.
401 // Allow it to be used only to reset the password
402 // a single time to a new value, which won't be in
403 // the user's e-mail archives.
405 // For backwards compatibility, we'll still recognize
406 // it at the login form to minimize surprises for
407 // people who have been logging in with a temporary
408 // password for some time.
410 // As a side-effect, we can authenticate the user's
411 // e-mail address if it's not already done, since
412 // the temporary password was sent via e-mail.
414 if( !$u->isEmailConfirmed() ) {
418 // At this point we just return an appropriate code
419 // indicating that the UI should show a password
420 // reset form; bot interfaces etc will probably just
421 // fail cleanly here.
423 $retval = self
::RESET_PASS
;
425 $retval = '' == $this->mPassword ? self
::EMPTY_PASS
: self
::WRONG_PASS
;
428 $wgAuth->updateUser( $u );
431 $retval = self
::SUCCESS
;
433 wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword
, $retval ) );
437 function processLogin() {
438 global $wgUser, $wgAuth;
440 switch ($this->authenticateUserData())
443 # We've verified now, update the real record
444 if( (bool)$this->mRemember
!= (bool)$wgUser->getOption( 'rememberpassword' ) ) {
445 $wgUser->setOption( 'rememberpassword', $this->mRemember ?
1 : 0 );
446 $wgUser->saveSettings();
448 $wgUser->invalidateCache();
450 $wgUser->setCookies();
452 if( $this->hasSessionCookie() ) {
453 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
455 return $this->cookieRedirectCheck( 'login' );
461 $this->mainLoginForm( wfMsg( 'noname' ) );
463 case self
::WRONG_PLUGIN_PASS
:
464 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
466 case self
::NOT_EXISTS
:
467 $this->mainLoginForm( wfMsg( 'nosuchuser', htmlspecialchars( $this->mName
) ) );
469 case self
::WRONG_PASS
:
470 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
472 case self
::EMPTY_PASS
:
473 $this->mainLoginForm( wfMsg( 'wrongpasswordempty' ) );
475 case self
::RESET_PASS
:
476 $this->resetLoginForm( wfMsg( 'resetpass_announce' ) );
479 wfDebugDieBacktrace( "Unhandled case value" );
483 function resetLoginForm( $error ) {
485 $wgOut->addWikiText( "<div class=\"errorbox\">$error</div>" );
486 $reset = new PasswordResetForm( $this->mName
, $this->mPassword
);
493 function mailPassword() {
494 global $wgUser, $wgOut, $wgAuth;
496 if( !$wgAuth->allowPasswordChange() ) {
497 $this->mainLoginForm( wfMsg( 'resetpass_forbidden' ) );
501 # Check against blocked IPs
502 # fixme -- should we not?
503 if( $wgUser->isBlocked() ) {
504 $this->mainLoginForm( wfMsg( 'blocked-mailpassword' ) );
508 # Check against the rate limiter
509 if( $wgUser->pingLimiter( 'mailpassword' ) ) {
510 $wgOut->rateLimited();
514 if ( '' == $this->mName
) {
515 $this->mainLoginForm( wfMsg( 'noname' ) );
518 $u = User
::newFromName( $this->mName
);
519 if( is_null( $u ) ) {
520 $this->mainLoginForm( wfMsg( 'noname' ) );
523 if ( 0 == $u->getID() ) {
524 $this->mainLoginForm( wfMsg( 'nosuchuser', $u->getName() ) );
528 # Check against password throttle
529 if ( $u->isPasswordReminderThrottled() ) {
530 global $wgPasswordReminderResendTime;
531 # Round the time in hours to 3 d.p., in case someone is specifying minutes or seconds.
532 $this->mainLoginForm( wfMsg( 'throttled-mailpassword',
533 round( $wgPasswordReminderResendTime, 3 ) ) );
537 $result = $this->mailPasswordInternal( $u, true );
538 if( WikiError
::isError( $result ) ) {
539 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
541 $this->mainLoginForm( wfMsg( 'passwordsent', $u->getName() ), 'success' );
547 * @return mixed true on success, WikiError on failure
550 function mailPasswordInternal( $u, $throttle = true ) {
551 global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
552 global $wgServer, $wgScript;
554 if ( '' == $u->getEmail() ) {
555 return new WikiError( wfMsg( 'noemail', $u->getName() ) );
558 $np = $u->randomPassword();
559 $u->setNewpassword( $np, $throttle );
561 setcookie( "{$wgCookiePrefix}Token", '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
566 if ( '' == $ip ) { $ip = '(Unknown)'; }
568 $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np, $wgServer . $wgScript );
570 $result = $u->sendMail( wfMsg( 'passwordremindertitle' ), $m );
576 * @param string $msg Message that will be shown on success
577 * @param bool $auto Toggle auto-redirect to main page; default true
580 function successfulLogin( $msg, $auto = true ) {
584 # Run any hooks; ignore results
586 wfRunHooks('UserLoginComplete', array(&$wgUser));
588 $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
589 $wgOut->setRobotpolicy( 'noindex,nofollow' );
590 $wgOut->setArticleRelated( false );
591 $wgOut->addWikiText( $msg );
592 if ( !empty( $this->mReturnTo
) ) {
593 $wgOut->returnToMain( $auto, $this->mReturnTo
);
595 $wgOut->returnToMain( $auto );
600 function userNotPrivilegedMessage() {
603 $wgOut->setPageTitle( wfMsg( 'whitelistacctitle' ) );
604 $wgOut->setRobotpolicy( 'noindex,nofollow' );
605 $wgOut->setArticleRelated( false );
607 $wgOut->addWikiText( wfMsg( 'whitelistacctext' ) );
609 $wgOut->returnToMain( false );
613 function userBlockedMessage() {
614 global $wgOut, $wgUser;
616 # Let's be nice about this, it's likely that this feature will be used
617 # for blocking large numbers of innocent people, e.g. range blocks on
618 # schools. Don't blame it on the user. There's a small chance that it
619 # really is the user's fault, i.e. the username is blocked and they
620 # haven't bothered to log out before trying to create an account to
621 # evade it, but we'll leave that to their guilty conscience to figure
624 $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) );
625 $wgOut->setRobotpolicy( 'noindex,nofollow' );
626 $wgOut->setArticleRelated( false );
629 $blocker = User
::whoIs( $wgUser->mBlock
->mBy
);
630 $block_reason = $wgUser->mBlock
->mReason
;
632 $wgOut->addWikiText( wfMsg( 'cantcreateaccount-text', $ip, $block_reason, $blocker ) );
633 $wgOut->returnToMain( false );
639 function mainLoginForm( $msg, $msgtype = 'error' ) {
640 global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
641 global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
642 global $wgAuth, $wgEmailConfirmToEdit;
644 if ( $this->mType
== 'signup' ) {
645 if ( !$wgUser->isAllowed( 'createaccount' ) ) {
646 $this->userNotPrivilegedMessage();
648 } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
649 $this->userBlockedMessage();
654 if ( '' == $this->mName
) {
655 if ( $wgUser->isLoggedIn() ) {
656 $this->mName
= $wgUser->getName();
658 $this->mName
= isset( $_COOKIE[$wgCookiePrefix.'UserName'] ) ?
$_COOKIE[$wgCookiePrefix.'UserName'] : null;
662 $titleObj = SpecialPage
::getTitleFor( 'Userlogin' );
664 if ( $this->mType
== 'signup' ) {
665 $template = new UsercreateTemplate();
666 $q = 'action=submitlogin&type=signup';
667 $linkq = 'type=login';
668 $linkmsg = 'gotaccount';
670 $template = new UserloginTemplate();
671 $q = 'action=submitlogin&type=login';
672 $linkq = 'type=signup';
673 $linkmsg = 'nologin';
676 if ( !empty( $this->mReturnTo
) ) {
677 $returnto = '&returnto=' . wfUrlencode( $this->mReturnTo
);
682 # Pass any language selection on to the mode switch link
683 if( $wgLoginLanguageSelector && $this->mLanguage
)
684 $linkq .= '&uselang=' . $this->mLanguage
;
686 $link = '<a href="' . htmlspecialchars ( $titleObj->getLocalUrl( $linkq ) ) . '">';
687 $link .= wfMsgHtml( $linkmsg . 'link' );
690 # Don't show a "create account" link if the user can't
691 if( $this->showCreateOrLoginLink( $wgUser ) )
692 $template->set( 'link', wfMsgHtml( $linkmsg, $link ) );
694 $template->set( 'link', '' );
696 $template->set( 'header', '' );
697 $template->set( 'name', $this->mName
);
698 $template->set( 'password', $this->mPassword
);
699 $template->set( 'retype', $this->mRetype
);
700 $template->set( 'email', $this->mEmail
);
701 $template->set( 'realname', $this->mRealName
);
702 $template->set( 'domain', $this->mDomain
);
704 $template->set( 'action', $titleObj->getLocalUrl( $q ) );
705 $template->set( 'message', $msg );
706 $template->set( 'messagetype', $msgtype );
707 $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
708 $template->set( 'userealname', $wgAllowRealName );
709 $template->set( 'useemail', $wgEnableEmail );
710 $template->set( 'emailrequired', $wgEmailConfirmToEdit );
711 $template->set( 'canreset', $wgAuth->allowPasswordChange() );
712 $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember
);
714 # Prepare language selection links as needed
715 if( $wgLoginLanguageSelector ) {
716 $template->set( 'languages', $this->makeLanguageSelector() );
717 if( $this->mLanguage
)
718 $template->set( 'uselang', $this->mLanguage
);
721 // Give authentication and captcha plugins a chance to modify the form
722 $wgAuth->modifyUITemplate( $template );
723 if ( $this->mType
== 'signup' ) {
724 wfRunHooks( 'UserCreateForm', array( &$template ) );
726 wfRunHooks( 'UserLoginForm', array( &$template ) );
729 $wgOut->setPageTitle( wfMsg( 'userlogin' ) );
730 $wgOut->setRobotpolicy( 'noindex,nofollow' );
731 $wgOut->setArticleRelated( false );
732 $wgOut->disallowUserJs(); // just in case...
733 $wgOut->addTemplate( $template );
739 function showCreateOrLoginLink( &$user ) {
740 if( $this->mType
== 'signup' ) {
742 } elseif( $user->isAllowed( 'createaccount' ) ) {
750 * Check if a session cookie is present.
752 * This will not pick up a cookie set during _this_ request, but is
753 * meant to ensure that the client is returning the cookie which was
754 * set on a previous pass through the system.
758 function hasSessionCookie() {
759 global $wgDisableCookieCheck, $wgRequest;
760 return $wgDisableCookieCheck ?
true : $wgRequest->checkSessionCookie();
766 function cookieRedirectCheck( $type ) {
769 $titleObj = SpecialPage
::getTitleFor( 'Userlogin' );
770 $check = $titleObj->getFullURL( 'wpCookieCheck='.$type );
772 return $wgOut->redirect( $check );
778 function onCookieRedirectCheck( $type ) {
781 if ( !$this->hasSessionCookie() ) {
782 if ( $type == 'new' ) {
783 return $this->mainLoginForm( wfMsg( 'nocookiesnew' ) );
784 } else if ( $type == 'login' ) {
785 return $this->mainLoginForm( wfMsg( 'nocookieslogin' ) );
788 return $this->mainLoginForm( wfMsg( 'error' ) );
791 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
798 function throttleHit( $limit ) {
801 $wgOut->addWikiText( wfMsg( 'acct_creation_throttle_hit', $limit ) );
805 * Produce a bar of links which allow the user to select another language
806 * during login/registration but retain "returnto"
810 function makeLanguageSelector() {
811 $msg = wfMsgForContent( 'loginlanguagelinks' );
812 if( $msg != '' && !wfEmptyMsg( 'loginlanguagelinks', $msg ) ) {
813 $langs = explode( "\n", $msg );
815 foreach( $langs as $lang ) {
816 $lang = trim( $lang, '* ' );
817 $parts = explode( '|', $lang );
818 $links[] = $this->makeLanguageSelectorLink( $parts[0], $parts[1] );
820 return count( $links ) > 0 ?
wfMsgHtml( 'loginlanguagelabel', implode( ' | ', $links ) ) : '';
827 * Create a language selector link for a particular language
828 * Links back to this page preserving type and returnto
830 * @param $text Link text
831 * @param $lang Language code
833 function makeLanguageSelectorLink( $text, $lang ) {
835 $self = SpecialPage
::getTitleFor( 'Userlogin' );
836 $attr[] = 'uselang=' . $lang;
837 if( $this->mType
== 'signup' )
838 $attr[] = 'type=signup';
839 if( $this->mReturnTo
)
840 $attr[] = 'returnto=' . $this->mReturnTo
;
841 $skin = $wgUser->getSkin();
842 return $skin->makeKnownLinkObj( $self, htmlspecialchars( $text ), implode( '&', $attr ) );