Merge "Update CLDRPluralRuleParser library"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 22 Sep 2014 17:02:00 +0000 (17:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 22 Sep 2014 17:02:00 +0000 (17:02 +0000)
includes/specials/SpecialMediaStatistics.php
includes/specials/SpecialUserlogin.php
includes/templates/Userlogin.php
languages/i18n/en.json
resources/src/mediawiki.special/mediawiki.special.userlogin.login.css
tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php

index 681c332..3fd8413 100644 (file)
@@ -185,6 +185,9 @@ class MediaStatisticsPage extends QueryPage {
                if ( $decimal == 0 ) {
                        return '0';
                }
+               if ( $decimal >= 100 ) {
+                       return '100';
+               }
                $percent = sprintf( "%." . max( 0, 2 - floor( log10( $decimal ) ) ) . "f", $decimal );
                // Then remove any trailing 0's
                return preg_replace( '/\.?0*$/', '', $percent );
index 845413e..6de7c90 100644 (file)
@@ -238,11 +238,19 @@ class LoginForm extends SpecialPage {
                }
                $this->setHeaders();
 
-               // In the case where the user is already logged in, do not show the login page.
-               // The use case scenario for this is when a user opens a large number of tabs, is
-               // redirected to the login page on all of them, and then logs in on one, expecting
-               // all the others to work properly.
-               if ( $this->mType !== 'signup' && !$this->mPosted && $this->getUser()->isLoggedIn() ) {
+               // In the case where the user is already logged in, and was redirected to the login form from a
+               // page that requires login, do not show the login page. The use case scenario for this is when
+               // a user opens a large number of tabs, is redirected to the login page on all of them, and then
+               // logs in on one, expecting all the others to work properly.
+               //
+               // However, do show the form if it was visited intentionally (no 'returnto' is present). People
+               // who often switch between several accounts have grown accustomed to this behavior.
+               if (
+                       $this->mType !== 'signup' &&
+                       !$this->mPosted &&
+                       $this->getUser()->isLoggedIn() &&
+                       ( $this->mReturnTo !== '' || $this->mReturnToQuery !== '' )
+               ) {
                        $this->successfulLogin();
                }
 
@@ -1392,6 +1400,7 @@ class LoginForm extends SpecialPage {
                $template->set( 'cansecurelogin', ( $wgSecureLogin === true ) );
                $template->set( 'stickhttps', (int)$this->mStickHTTPS );
                $template->set( 'loggedin', $user->isLoggedIn() );
+               $template->set( 'loggedinuser', $user->getName() );
 
                if ( $this->mType == 'signup' ) {
                        if ( !self::getCreateaccountToken() ) {
index ad01905..8bba426 100644 (file)
@@ -37,6 +37,11 @@ class UserloginTemplate extends BaseTemplate {
        <?php } ?>
        <div id="userloginForm">
                <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
+                       <?php if ( $this->data['loggedin'] ) { ?>
+                               <div class="warningbox">
+                                       <?php echo $this->getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?>
+                               </div>
+                       <?php } ?>
                        <section class="mw-form-header">
                                <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
                        </section>
@@ -166,9 +171,15 @@ class UserloginTemplate extends BaseTemplate {
                        </div>
 
                        <?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
-                               <div id="mw-createaccount-cta">
-                                       <?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-progressive"><?php $this->msg( 'userlogin-joinproject' ); ?></a>
-                               </div>
+                               <?php if ( $this->data['loggedin'] ) { ?>
+                                       <div id="mw-createaccount-another">
+                                               <a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button"><?php $this->msg( 'userlogin-createanother' ); ?></a>
+                                       </div>
+                               <?php } else { ?>
+                                       <div id="mw-createaccount-cta">
+                                               <?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-progressive"><?php $this->msg( 'userlogin-joinproject' ); ?></a>
+                                       </div>
+                               <?php } ?>
                        <?php } ?>
                        <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
                        <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
index 5ec4a07..8b6e66b 100644 (file)
        "userlogin-resetpassword-link": "Forgot your password?",
        "helplogin-url": "https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Logging_in",
        "userlogin-helplink2": "Help with logging in",
+       "userlogin-loggedin": "You are already logged in as {{GENDER:$1|$1}}.\nUse the form below to log in as another user.",
+       "userlogin-createanother": "Create another account",
        "createacct-emailrequired": "Email address",
        "createacct-emailoptional": "Email address (optional)",
        "createacct-email-ph": "Enter your email address",
index ee6a57c..64471b2 100644 (file)
@@ -6,6 +6,10 @@
        background: url(images/glyph-people-large.png) no-repeat 50%;
        margin: 0 auto;
        padding-top: 4em;
+}
+
+#mw-createaccount-cta,
+#mw-createaccount-another {
        font-size: 0.9em;
        font-weight: normal;
        text-align: center;
index b1d4257..d56ecad 100644 (file)
@@ -37,6 +37,7 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
        }
 
        /**
+        * @covers SpecialPageFactory::getPage
         * @dataProvider specialPageProvider
         */
        public function testGetPage( $spec, $shouldReuseInstance ) {
@@ -53,6 +54,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
                SpecialPageFactory::resetList();
        }
 
+       /**
+        * @covers SpecialPageFactory::getNames
+        */
        public function testGetNames() {
                $this->mergeMwGlobalArrayValue( 'wgSpecialPages', array( 'testdummy' => 'SpecialAllPages' ) );
 
@@ -63,6 +67,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
                SpecialPageFactory::resetList();
        }
 
+       /**
+        * @covers SpecialPageFactory::resolveAlias
+        */
        public function testResolveAlias() {
                $this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) );
 
@@ -75,6 +82,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
                SpecialPageFactory::resetList();
        }
 
+       /**
+        * @covers SpecialPageFactory::getLocalNameFor
+        */
        public function testGetLocalNameFor() {
                $this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) );
 
@@ -86,6 +96,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
                SpecialPageFactory::resetList();
        }
 
+       /**
+        * @covers SpecialPageFactory::getTitleForAlias
+        */
        public function testGetTitleForAlias() {
                $this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) );