Improved personal toolbar for logged-out users
authorThis, that and the other <at.light@live.com.au>
Fri, 6 Nov 2015 23:51:59 +0000 (10:51 +1100)
committerJdlrobson <jrobson@wikimedia.org>
Tue, 1 Dec 2015 18:44:52 +0000 (18:44 +0000)
Previously, logged-out users either only saw "Create account" and "Log in"
links in the personal area, or if $wgShowIPinHeader was true, they saw

  [icon] 127.0.0.1  Talk for this IP address  Create account  Log in

where the IP address itself linked to the IP user page.

Now, logged-out users by default see the following:

  [icon] Not logged in  Talk  Contributions  Create account  Log in

The old $wgShowIPinHeader feature is removed. It is very unfriendly to
show the user's IP address (in red, no less) at the top of every page,
since this will mean nothing to most visitors. Caching means that this
can't even be done reliably, anyway.

Another improvement is that the "talk" and "contributions" links are not
shown if anonymous users don't have the 'edit' right.

Modelled after the loggedOutTalkPage() function at Dutch Wikipedia
<https://nl.wikipedia.org/w/index.php?oldid=44706954>

Bug: T112724
Change-Id: I6f44e3e5d97ea917e4a03af47f3795792e4ca122

includes/DefaultSettings.php
includes/Setup.php
includes/cache/HTMLFileCache.php
includes/skins/Skin.php
includes/skins/SkinTemplate.php
languages/i18n/en.json
languages/i18n/qqq.json

index fa6f13a..9730265 100644 (file)
@@ -2440,10 +2440,8 @@ $wgStyleVersion = '303';
 
 /**
  * This will cache static pages for non-logged-in users to reduce
- * database traffic on public sites.
- * Automatically sets $wgShowIPinHeader = false
- * ResourceLoader requests to default language and skins are cached
- * as well as single module requests.
+ * database traffic on public sites. ResourceLoader requests to default
+ * language and skins are cached as well as single module requests.
  */
 $wgUseFileCache = false;
 
@@ -3162,13 +3160,6 @@ $wgWellFormedXml = true;
  */
 $wgXhtmlNamespaces = array();
 
-/**
- * Show IP address, for non-logged in users. It's necessary to switch this off
- * for some forms of caching.
- * @warning Will disable file cache.
- */
-$wgShowIPinHeader = true;
-
 /**
  * Site notice shown at the top of each page
  *
index 44c1f71..a94bd12 100644 (file)
@@ -421,11 +421,9 @@ if ( is_array( $wgExtraNamespaces ) ) {
 // To determine the user language, use $wgLang->getCode()
 $wgContLanguageCode = $wgLanguageCode;
 
-// Easy to forget to falsify $wgShowIPinHeader for static caches.
+// Easy to forget to falsify $wgDebugToolbar for static caches.
 // If file cache or squid cache is on, just disable this (DWIMD).
-// Do the same for $wgDebugToolbar.
 if ( $wgUseFileCache || $wgUseSquid ) {
-       $wgShowIPinHeader = false;
        $wgDebugToolbar = false;
 }
 
index 483eaa5..298f6e2 100644 (file)
@@ -96,12 +96,12 @@ class HTMLFileCache extends FileCacheBase {
         * @return bool
         */
        public static function useFileCache( IContextSource $context ) {
-               global $wgUseFileCache, $wgShowIPinHeader, $wgDebugToolbar, $wgContLang;
+               global $wgUseFileCache, $wgDebugToolbar, $wgContLang;
                if ( !$wgUseFileCache ) {
                        return false;
                }
-               if ( $wgShowIPinHeader || $wgDebugToolbar ) {
-                       wfDebug( "HTML file cache skipped. Either \$wgShowIPinHeader and/or \$wgDebugToolbar on\n" );
+               if ( $wgDebugToolbar ) {
+                       wfDebug( "HTML file cache skipped. \$wgDebugToolbar on\n" );
 
                        return false;
                }
index 08e4885..8177371 100644 (file)
@@ -232,7 +232,7 @@ abstract class Skin extends ContextSource {
                $title = $this->getRelevantTitle();
 
                // User/talk link
-               if ( $user->isLoggedIn() || $this->showIPinHeader() ) {
+               if ( $user->isLoggedIn() ) {
                        $titles[] = $user->getUserPage();
                        $titles[] = $user->getTalkPage();
                }
@@ -725,12 +725,12 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * Returns true if the IP should be shown in the header
-        * @return bool
+        * @deprecated since 1.27, feature removed
+        * @return bool Always false
         */
        function showIPinHeader() {
-               global $wgShowIPinHeader;
-               return $wgShowIPinHeader && session_id() != '';
+               wfDeprecated( __METHOD__, '1.27' );
+               return false;
        }
 
        /**
index 4d7c03a..e796582 100644 (file)
@@ -207,7 +207,7 @@ class SkinTemplate extends Skin {
                $this->loggedin = $user->isLoggedIn();
                $this->username = $user->getName();
 
-               if ( $this->loggedin || $this->showIPinHeader() ) {
+               if ( $this->loggedin ) {
                        $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
                } else {
                        # This won't be used in the standard skins, but we define it to preserve the interface
@@ -660,21 +660,28 @@ class SkinTemplate extends Skin {
                                'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
                        );
 
-                       if ( $this->showIPinHeader() ) {
-                               $href = &$this->userpageUrlDetails['href'];
+                       // No need to show Talk and Contributions to anons if they can't contribute!
+                       if ( User::groupHasPermission( '*', 'edit' ) ) {
+                               // Show the text "Not logged in"
                                $personal_urls['anonuserpage'] = array(
-                                       'text' => $this->username,
-                                       'href' => $href,
-                                       'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
-                                       'active' => ( $pageurl == $href )
+                                       'text' => $this->msg( 'notloggedin' )->text()
                                );
-                               $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
-                               $href = &$usertalkUrlDetails['href'];
+
+                               // Because of caching, we can't link directly to the IP talk and
+                               // contributions pages. Instead we use the special page shortcuts
+                               // (which work correctly regardless of caching). This means we can't
+                               // determine whether these links are active or not, but since major
+                               // skins (MonoBook, Vector) don't use this information, it's not a
+                               // huge loss.
                                $personal_urls['anontalk'] = array(
                                        'text' => $this->msg( 'anontalk' )->text(),
-                                       'href' => $href,
-                                       'class' => $usertalkUrlDetails['exists'] ? false : 'new',
-                                       'active' => ( $pageurl == $href )
+                                       'href' => self::makeSpecialUrlSubpage( 'MyTalk', false ),
+                                       'active' => false
+                               );
+                               $personal_urls['anoncontribs'] = array(
+                                       'text' => $this->msg( 'anoncontribs' )->text(),
+                                       'href' => self::makeSpecialUrlSubpage( 'MyContributions', false ),
+                                       'active' => false
                                );
                        }
 
index 4bec8e2..0092ada 100644 (file)
        "morenotlisted": "This list is not complete.",
        "mypage": "Page",
        "mytalk": "Talk",
-       "anontalk": "Talk for this IP address",
+       "anontalk": "Talk",
        "navigation": "Navigation",
        "and": "&#32;and",
        "qbfind": "Find",
        "contributions-summary": "",
        "contributions-title": "User contributions for $1",
        "mycontris": "Contributions",
+       "anoncontribs": "Contributions",
        "contribsub2": "For {{GENDER:$3|$1}} ($2)",
        "contributions-userdoesnotexist": "User account \"$1\" is not registered.",
        "nocontribs": "No changes were found matching these criteria.",
        "accesskey-pt-preferences": "",
        "accesskey-pt-watchlist": "l",
        "accesskey-pt-mycontris": "y",
+       "accesskey-pt-anoncontribs": "y",
        "accesskey-pt-login": "o",
        "accesskey-pt-logout": "",
        "accesskey-pt-createaccount": "",
        "tooltip-pt-preferences": "Your preferences",
        "tooltip-pt-watchlist": "A list of pages you are monitoring for changes",
        "tooltip-pt-mycontris": "A list of your contributions",
+       "tooltip-pt-anoncontribs": "A list of edits made from this IP address",
        "tooltip-pt-login": "You are encouraged to log in; however, it is not mandatory",
        "tooltip-pt-logout": "Log out",
        "tooltip-pt-createaccount": "You are encouraged to create an account and log in; however, it is not mandatory",
index 4c1146e..1ebdcff 100644 (file)
        "morenotlisted": "An indication that more of a templates list is not shown.\n\nUsed as \"More...\" link for {{msg-mw|pageinfo-templates}} field.\n\nSimilar to {{msg-mw|moredotdotdot}}.",
        "mypage": "A text for the link to the user's user page in the links at the top of the page.\n{{Identical|Page}}",
        "mytalk": "In the personal URLs page section - right upper corner.\n\nUsed as link title in your personal toolbox.\n\nSee also:\n* {{msg-mw|Mytalk}}\n* {{msg-mw|Accesskey-pt-mytalk}}\n* {{msg-mw|Tooltip-pt-mytalk}}\n{{Identical|Talk}}",
-       "anontalk": "Link to the talk page appearing in [[mw:Help:Navigation#User_Links|user links]] for each anonymous users when [[mw:Manual:$wgShowIPinHeader|$wgShowIPinHeader]] is true.\n\nSee also:\n* {{msg-mw|Anontalk}}\n* {{msg-mw|Accesskey-pt-anontalk}}\n* {{msg-mw|Tooltip-pt-anontalk}}",
+       "anontalk": "Same as {{msg-mw|mytalk}} but used for non-logged-in users.\n{{Identical|Talk}}\n\nSee also:\n* {{msg-mw|Accesskey-pt-anontalk}}\n* {{msg-mw|Tooltip-pt-anontalk}}",
        "navigation": "This is shown as a section header in the sidebar of most skins.\n\n{{Identical|Navigation}}",
        "and": "The translation for \"and\" appears in the [[Special:Version]] page, between the last two items of a list. If a comma is needed, add it at the beginning without a gap between it and the \"&\". &amp;#32; is a blank space, one character long. Please leave it as it is.\n\nThis can also appear in the credits page if the credits feature is enabled,for example [{{canonicalurl:Support|action=credits}} the credits of the support page]. (To view any credits page type <nowiki>&action=credits</nowiki> at the end of any URL in the address bar.)\n{{Identical|And}}",
        "qbfind": "Alternative for \"search\" as used in Cologne Blue skin.\n{{Identical|Find}}",
        "contributions-summary": "{{doc-specialpagesummary|contributions}}",
        "contributions-title": "{{Gender}}\nThe page title in your browser bar, but not the page title.\n\nParameters:\n* $1 - the username\nSee also:\n* {{msg-mw|Contributions}}",
        "mycontris": "In the personal urls page section - right upper corner.\n\nSee also:\n* {{msg-mw|Mycontris}}\n* {{msg-mw|Accesskey-pt-mycontris}}\n* {{msg-mw|Tooltip-pt-mycontris}}\n{{Identical|Contribution}}",
+       "anoncontribs": "Same as {{msg-mw|mycontris}} but used for non-logged-in users.\n\nSee also:\n* {{msg-mw|Accesskey-pt-anoncontribs}}\n* {{msg-mw|Tooltip-pt-anoncontribs}}\n{{Identical|Contribution}}",
        "contribsub2": "Contributions for \"user\" (links). Parameters:\n* $1 is an IP address or a username, with a link which points to the user page (if registered user).\n* $2 is list of tool links. The list contains a link which has text {{msg-mw|Sp-contributions-talk}}.\n* $3 is a plain text username used for GENDER.\n{{Identical|For $1}}",
        "contributions-userdoesnotexist": "This message is used in [[Special:Contributions]]. It is used to tell the user that the name he searched for doesn't exists.\n\nParameters:\n* $1 - a username\n\n{{identical|userdoesnotexist}}",
        "nocontribs": "Used in [[Special:Contributions]] and [[Special:DeletedContributions]].\n\nSee examples: [[Special:Contributions/x]] and [[Special:DeletedContributions/x]].\n\nParameters:\n* $1 - (Unused) the user name",
        "accesskey-pt-preferences": "{{doc-accesskey}}\nSee also:\n* {{msg-mw|Mypreferences}}\n* {{msg-mw|Accesskey-pt-preferences}}\n* {{msg-mw|Tooltip-pt-preferences}}",
        "accesskey-pt-watchlist": "{{doc-accesskey}}\nSee also:\n* {{msg-mw|Mywatchlist}}\n* {{msg-mw|Accesskey-pt-watchlist}}\n* {{msg-mw|Tooltip-pt-watchlist}}",
        "accesskey-pt-mycontris": "{{doc-accesskey}}\nSee also:\n* {{msg-mw|Mycontris}}\n* {{msg-mw|Accesskey-pt-mycontris}}\n* {{msg-mw|Tooltip-pt-mycontris}}",
+       "accesskey-pt-anoncontribs": "{{doc-accesskey}}\nSee also:\n* {{msg-mw|Anoncontribs}}\n* {{msg-mw|Tooltip-pt-anoncontribs}}",
        "accesskey-pt-login": "{{doc-accesskey}}",
        "accesskey-pt-logout": "{{doc-accesskey}}\nSee also:\n* {{msg-mw|Logout}}\n* {{msg-mw|Accesskey-pt-logout}}\n* {{msg-mw|Tooltip-pt-logout}}",
        "accesskey-pt-createaccount": "{{doc-accesskey}}",
        "tooltip-pt-preferences": "Tooltip shown when hovering over the {{msg-mw|Mypreferences}} link in your personal toolbox (upper right side).\n\nSee also:\n* {{msg-mw|Mypreferences}}\n* {{msg-mw|Accesskey-pt-preferences}}\n* {{msg-mw|Tooltip-pt-preferences}}\n{{Identical|Preferences}}",
        "tooltip-pt-watchlist": "Tooltip shown when hovering over the {{msg-mw|Mywatchlist}} link in your personal toolbox (upper right side).\n\nSee also:\n* {{msg-mw|Mywatchlist}}\n* {{msg-mw|Accesskey-pt-watchlist}}\n* {{msg-mw|Tooltip-pt-watchlist}}",
        "tooltip-pt-mycontris": "Tooltip shown when hovering over the {{msg-mw|Mycontris}} link in your personal toolbox (upper right side).\n\nSee also:\n* {{msg-mw|Mycontris}}\n* {{msg-mw|Accesskey-pt-mycontris}}\n* {{msg-mw|Tooltip-pt-mycontris}}",
+       "tooltip-pt-anoncontribs": "Tooltip shown when hovering over the {{msg-mw|Anoncontribs}} link in your personal toolbox (upper right side).\n\nSee also:\n* {{msg-mw|Anoncontribs}}\n* {{msg-mw|Accesskey-pt-anoncontribs}}",
        "tooltip-pt-login": "Tooltip shown when hovering over the link 'Log in' in the upper right corner show on all pages while not logged in.",
        "tooltip-pt-logout": "Tooltip shown when hovering over the {{msg-mw|Logout}} link in your personal toolbox (upper right side).\n\nSee also:\n* {{msg-mw|Logout}}\n* {{msg-mw|Accesskey-pt-logout}}\n* {{msg-mw|Tooltip-pt-logout}}\n{{Identical|Log out}}",
        "tooltip-pt-createaccount": "Tooltip shown when hovering over the link 'Create account' in the upper right corner show on all pages while not logged in.",