jenkins-bot has submitted this change and it was merged.

Change subject: Rephrase mention notifications
......................................................................


Rephrase mention notifications

Split mentions into 4 cases:
 - Mentioned on article talk page
 - Mentioned on agent's talk page
 - Mentioned on another user's talk page
 - Mentioned on any other page

Adjust secondary link
  icon: article or talk
  text: without namespace for article and article talk

Bug: T56433
Change-Id: Ibf965dad4f9cc468fdd4321b2450d6eaec0ac1d7
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M includes/formatters/MentionPresentationModel.php
4 files changed, 86 insertions(+), 22 deletions(-)

Approvals:
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Resources.php b/Resources.php
index 1f2cc49..5c8e1b2 100644
--- a/Resources.php
+++ b/Resources.php
@@ -81,6 +81,7 @@
                        // don't load heavy icons all the time
                        'oojs-ui.styles.icons-user',
                        'oojs-ui.styles.icons-alerts',
+                       'oojs-ui.styles.icons-content',
                ),
                'messages' => array(
                        'echo-overlay-link',
diff --git a/i18n/en.json b/i18n/en.json
index e0db05a..9a590d5 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -82,9 +82,15 @@
        "notification-add-talkpage-topic-yours2": "[[User:$1|$1]] 
{{GENDER:$1|sent}} you a message: \"[[$3#$2|$2]]\".",
        "notification-add-comment-yours2": "[[User:$1|$1]] 
{{GENDER:$1|commented}} on \"[[$3#$2|$2]]\" on your talk page.",
        "notification-mention": "[[User:$1|$1]] {{GENDER:$1|mentioned}} 
{{GENDER:$6|you}} on the $5 talk page in \"[[:$3#$2|$4]]\".",
-       "notification-header-mention": "$1 {{GENDER:$2|mentioned}} 
{{GENDER:$5|you}} on the $3 talk page in \"$4\".",
        "notification-mention-nosection": "[[User:$1|$1]] 
{{GENDER:$1|mentioned}} {{GENDER:$4|you}} on the [[:$3|$2 talk page]].",
-       "notification-header-mention-nosection": "$1 {{GENDER:$2|mentioned}} 
{{GENDER:$5|you}} on the $3 talk page.",
+       "notification-header-mention-other": "$1 {{GENDER:$2|mentioned}} 
{{GENDER:$3|you}} on '''$4''' in \"$5\".",
+       "notification-header-mention-other-nosection": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on '''$4'''.",
+       "notification-header-mention-user-talkpage": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the user talk page of '''$4''' in 
\"$5\".",
+       "notification-header-mention-user-talkpage-nosection": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the user talk page of '''$4'''.",
+       "notification-header-mention-agent-talkpage": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on {{GENDER:$2|his|her|their}} talk 
page in \"$4\".",
+       "notification-header-mention-agent-talkpage-nosection": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on {{GENDER:$2|his|her|their}} talk 
page.",
+       "notification-header-mention-article-talkpage": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the '''$4''' talk page in \"$5\".",
+       "notification-header-mention-article-talkpage-nosection": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the '''$4''' talk page.",
        "notification-user-rights": "Your user rights 
[[Special:Log/rights/$1|were {{GENDER:$1|changed}}]] by [[User:$1|$1]]. $2. 
[[Special:ListGroupRights|Learn more]]",
        "notification-header-user-rights": "Your user rights were 
{{GENDER:$2|changed}} by $1. $3.",
        "notification-user-rights-add": "You are now a member of 
{{PLURAL:$2|this group|these groups}}: $1",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 78636a5..299e8a1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -103,9 +103,15 @@
        "notification-add-talkpage-topic-yours2": "Parameters:\n* $1 - a 
username, plain text. Can be used for GENDER.\n* $2 - a page section\n* $3 - a 
page title",
        "notification-add-comment-yours2": "Parameters:\n* $1 - a username, 
plain text; can be used for GENDER\n* $2 - discussion name\n* $3 - link to user 
talk page\nSee also:\n* {{msg-mw|Notification-add-comment2}}",
        "notification-mention": "Format for displaying notifications of a 
comment in a specific section including a link to another user's user 
page.\n\nParameters:\n* $1 - the username of the person who edited, plain text. 
Can be used for GENDER\n* $2 - the section title of the discussion\n* $3 - the 
page title of the discussion\n* $4 - the raw section title text\n* $5 - the 
title text without namespace (a page title in any namespace)\n* $6 - name of 
the user viewing the notification, can be used for GENDER",
-       "notification-header-mention": "Header text for a notification when you 
are mentioned by another user.\n* $1 - user's name (not suitable for 
GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the page they 
were mentioned in (without namespace).\n* $4 - name of the section they were 
mentioned in.\n* $5 - name of the user viewing the notification, can be used 
for GENDER",
        "notification-mention-nosection": "Format for displaying notifications 
of a comment including a link to another user's user page. Parameters:\n* $1 - 
the username of the person who edited, plain text. Can be used for GENDER\n* $2 
- the title text without namespace (a page title in any namespace)\n* $3 - the 
page title of the discussion\n* $4 - name of the user viewing the notification, 
can be used for GENDER",
-       "notification-header-mention-nosection": "Header text for a 
notification when you are mentioned by another user, but not in a section of a 
page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for 
use in GENDER.\n* $3 - name of the page without namespace they were mentioned 
in.\n* $4 - full page name.\n* $5 - name of the user viewing the notification, 
can be used for GENDER",
+       "notification-header-mention-other": "Header text for a notification 
when you are mentioned by another user in a section on a page that is not an 
article talk page or a user talk page.\n* $1 - user's name (not suitable for 
GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the user 
viewing the notification, can be used for GENDER\n* $4 - name of the page they 
were mentioned in (with namespace).\n* $5 - name of the section they were 
mentioned in",
+       "notification-header-mention-other-nosection": "Header text for a 
notification when you are mentioned by another user on a page that is not an 
article talk page or a user talk page.\n* $1 - user's name (not suitable for 
GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the user 
viewing the notification, can be used for GENDER\n* $4 - name of the page they 
were mentioned in (with namespace)",
+       "notification-header-mention-user-talkpage": "Header text for a 
notification when you are mentioned by another user in a section on a user talk 
page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for 
use in GENDER.\n* $3 - name of the user viewing the notification, can be used 
for GENDER\n* $4 - name of the user whose talk page you are mentioned in 
(without namespace).\n* $5 - name of the section they were mentioned in",
+       "notification-header-mention-user-talkpage-nosection": "Header text for 
a notification when you are mentioned by another user on a user talk page.\n* 
$1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in 
GENDER.\n* $3 - name of the user viewing the notification, can be used for 
GENDER\n* $4 - name of the user whose talk page you are mentioned in (with 
namespace)",
+       "notification-header-mention-agent-talkpage": "Header text for a 
notification when you are mentioned by another user in a section on their talk 
page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for 
use in GENDER.\n* $3 - name of the user viewing the notification, can be used 
for GENDER\n* $4 - name of the section they were mentioned in",
+       "notification-header-mention-agent-talkpage-nosection": "Header text 
for a notification when you are mentioned by another user on their talk 
page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for 
use in GENDER.\n* $3 - name of the user viewing the notification, can be used 
for GENDER",
+       "notification-header-mention-article-talkpage": "Header text for a 
notification when you are mentioned by another user in a section on an article 
talk page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name 
for use in GENDER.\n* $3 - name of the user viewing the notification, can be 
used for GENDER\n* $4 - name of the article whose talk page you are mentioned 
in (without namespace).\n* $5 - name of the section they were mentioned in",
+       "notification-header-mention-article-talkpage-nosection": "Header text 
for a notification when you are mentioned by another user on an article talk 
page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for 
use in GENDER.\n* $3 - name of the user viewing the notification, can be used 
for GENDER\n* $4 - name of the article whose talk page you are mentioned in 
(without namespace)",
        "notification-user-rights": "Format for displaying notifications of a 
user right change in notification page.\n\nParameters:\n* $1 - the username of 
the person who made the user right change. Can be used for GENDER support.\n* 
$2 - a semicolon separated list of {{msg-mw|Notification-user-rights-add}}, 
{{msg-mw|Notification-user-rights-remove}}",
        "notification-header-user-rights": "Format for displaying notifications 
of a user right change in notification flyout.  Parameters:\n* $1 - the 
username of the person who made the user right change, formatted for display.  
Cannot be used for GENDER\n* $2 - the raw username of the person who made the 
user rights change, can be used for GENDER support\n* $3 - a semicolon 
separated list of {{msg-mw|notification-user-rights-add}}, 
{{msg-mw|notification-user-rights-remove}}",
        "notification-user-rights-add": "Message indicating that a user was 
added to a user group.  Parameters:\n* $1 - a comma separated list of user 
group names\n* $2 - the number of user groups, this is used for PLURAL 
support\nSee also:\n* {{msg-mw|Notification-user-rights-remove}}",
diff --git a/includes/formatters/MentionPresentationModel.php 
b/includes/formatters/MentionPresentationModel.php
index aae3e47..d81aca5 100644
--- a/includes/formatters/MentionPresentationModel.php
+++ b/includes/formatters/MentionPresentationModel.php
@@ -31,17 +31,28 @@
                return (bool)$this->event->getTitle();
        }
 
-       /**
-        * Override to switch the message key to -nosection
-        * if no section title was detected
-        *
-        * @return string
-        */
        protected function getHeaderMessageKey() {
                // Messages used:
-               // notification-header-mention
-               // notification-header-mention-nosection
-               $key = parent::getHeaderMessageKey();
+               // notification-header-mention-other
+               // notification-header-mention-other-nosection
+               // notification-header-mention-article-talkpage
+               // notification-header-mention-article-talkpage-nosection
+               // notification-header-mention-agent-talkpage
+               // notification-header-mention-agent-talkpage-nosection
+               // notification-header-mention-user-talkpage
+               // notification-header-mention-user-talkpage-nosection
+               $key = 'notification-header-mention';
+
+               if ( $this->onArticleTalkpage() ) {
+                       $key .= '-article-talkpage';
+               } elseif ( $this->onAgentTalkpage() ) {
+                       $key .= '-agent-talkpage';
+               } elseif ( $this->onUserTalkpage() ) {
+                       $key .= '-user-talkpage';
+               } else {
+                       $key .= '-other';
+               }
+
                if ( !$this->getSection() ) {
                        $key .= '-nosection';
                }
@@ -50,9 +61,21 @@
        }
 
        public function getHeaderMessage() {
-               $msg = parent::getHeaderMessage();
-               // @fixme this message should not say "xx talk page"
-               $msg->params( $this->event->getTitle()->getText() );
+               $msg = $this->getMessageWithAgent( $this->getHeaderMessageKey() 
);
+               $msg->params( $this->getViewingUserForGender() );
+
+               if ( $this->onArticleTalkpage() ) {
+                       $msg->params( $this->event->getTitle()->getText() );
+               } elseif ( $this->onAgentTalkpage() ) {
+                       // No params to add here.
+                       // If we remove this check, onUserTalkpage() has to
+                       // make sure it is a user talk page but NOT the agent's 
talk page.
+               } elseif ( $this->onUserTalkpage() ) {
+                       $msg->params( $this->event->getTitle()->getText() );
+               } else {
+                       $msg->params( 
$this->event->getTitle()->getPrefixedText() );
+               }
+
                $section = $this->getSection();
                if ( $section ) {
                        $msg->params(
@@ -62,11 +85,7 @@
                                                30
                                )
                        );
-               } else {
-                       // For the -nosection message
-                       $msg->params( 
$this->event->getTitle()->getPrefixedText() );
                }
-               $msg->params( $this->getViewingUserForGender() );
 
                return $msg;
        }
@@ -97,7 +116,9 @@
        }
 
        public function getSecondaryLinks() {
-               $url = $this->event->getTitle()->getLocalURL( array(
+               $title = $this->event->getTitle();
+
+               $url = $title->getLocalURL( array(
                        'oldid' => 'prev',
                        'diff' => $this->event->getExtraParam( 'revid' )
                ) );
@@ -108,6 +129,36 @@
                        'icon' => 'changes',
                        'prioritized' => true,
                );
-               return array( $this->getAgentLink(), $viewChangesLink );
+
+               $pageLink = array(
+                       'url' => $title->getFullURL(),
+                       'label' => $this->isArticle() ?  $title->getText() : 
$title->getPrefixedText(),
+                       'description' => '',
+                       'icon' => $this->isTalk() ? 'speechBubbles' : 'article',
+                       'prioritized' => true,
+               );
+
+               return array( $this->getAgentLink(), $pageLink, 
$viewChangesLink );
+       }
+
+       private function onArticleTalkpage() {
+               return $this->event->getTitle()->getNamespace() === NS_TALK;
+       }
+
+       private function onAgentTalkpage() {
+               return $this->event->getTitle()->getPrefixedText() === 
$this->event->getAgent()->getTalkPage()->getPrefixedText();
+       }
+
+       private function onUserTalkpage() {
+               return $this->event->getTitle()->getNamespace() === 
NS_USER_TALK;
+       }
+
+       private function isTalk() {
+               return $this->event->getTitle()->isTalkPage();
+       }
+
+       private function isArticle() {
+               $ns = $this->event->getTitle()->getNamespace();
+               return $ns === NS_MAIN || $ns === NS_TALK;
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/265177
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf965dad4f9cc468fdd4321b2450d6eaec0ac1d7
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to