jenkins-bot has submitted this change and it was merged.
Change subject: Convert Echo notifications to the new system
......................................................................
Convert Echo notifications to the new system
* Add ThanksPresentationModel and FlowThanksPresentationModel
* Rename notification-thanks-flyout2 to notification-header-edit-thank,
shift parameters around and add GENDER support for thanked user
* Rename notification-flow-thanks-flyout to notification-header-flow-thank
and shift parameters around; this one did already have GENDER support
for the thanked user
Depends on Idb975feaec in Echo.
Bug: T116847
Change-Id: Iab0f2311e7ffb6a9ce21cd76e564511d03805530
---
A FlowThanksPresentationModel.php
M Thanks.hooks.php
M Thanks.php
A ThanksPresentationModel.php
M i18n/en.json
M i18n/qqq.json
6 files changed, 105 insertions(+), 9 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
Siebrand: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/FlowThanksPresentationModel.php b/FlowThanksPresentationModel.php
new file mode 100644
index 0000000..6bc23d8
--- /dev/null
+++ b/FlowThanksPresentationModel.php
@@ -0,0 +1,52 @@
+<?php
+class EchoFlowThanksPresentationModel extends EchoEventPresentationModel {
+ public function canRender() {
+ return (bool)$this->event->getTitle();
+ }
+
+ public function getIconType() {
+ return 'thanks';
+ }
+
+ public function getHeaderMessage() {
+ $msg = parent::getHeaderMessage();
+ $msg->params( $this->event->getExtraParam( 'topic-title' ) );
+ $msg->params( $this->event->getTitle()->getPrefixedText() );
+
+ $user = User::newFromId( $this->event->getExtraParam(
'thanked-user-id' ) );
+ $msg->params( $user ? $user->getName() : '[]' );
+ return $msg;
+ }
+
+ public function getPrimaryLink() {
+ $title = $this->event->getTitle();
+ // Make a link to #flow-post-{postid}
+ $title = Title::makeTitle(
+ $title->getNamespace(),
+ $title->getDBKey(),
+ 'flow-post' . $this->event->getExtraParam( 'post-id' )
+ );
+
+ return array(
+ $title->getFullURL( array(
+ 'workflow' => $this->event->getExtraParam(
'workflow' )
+ ) ),
+ $this->msg( 'notification-link-text-view-post' )
+ );
+ }
+
+ // TODO add thanking user as secondary link once we can make that look
nice (T115421)
+ /*
+ public function getSecondaryLinks() {
+ $agent = $this->event->getAgent();
+ if ( !$agent || !$this->userCan( Revision::DELETED_USER ) ) {
+ return array();
+ }
+
+ $url = $agent->getUserPage()->getLocalURL();
+ return array(
+ $url => $agent->getName()
+ );
+ }
+ */
+}
diff --git a/Thanks.hooks.php b/Thanks.hooks.php
index a672c95..6cb1d3d 100644
--- a/Thanks.hooks.php
+++ b/Thanks.hooks.php
@@ -160,11 +160,10 @@
'primary-link' => array( 'message' =>
'notification-link-text-view-edit', 'destination' => 'diff' ),
'category' => 'edit-thank',
'group' => 'positive',
+ 'presentation-model' => 'EchoThanksPresentationModel',
'formatter-class' => 'EchoThanksFormatter',
'title-message' => 'notification-thanks',
'title-params' => array( 'agent', 'difflink', 'title' ),
- 'flyout-message' => 'notification-thanks-flyout2',
- 'flyout-params' => array( 'agent', 'title' ),
'payload' => array( 'summary' ),
'email-subject-message' =>
'notification-thanks-email-subject',
'email-subject-params' => array( 'agent' ),
@@ -174,14 +173,13 @@
);
$notifications['flow-thank'] = array(
- 'primary-link' => array ( 'message' =>
'notification-link-text-view-post', 'destination' => 'post' ),
+ 'primary-link' => array( 'message' =>
'notification-link-text-view-post', 'destination' => 'post' ),
'category' => 'edit-thank',
'group' => 'positive',
+ 'presentation-model' =>
'EchoFlowThanksPresentationModel',
'formatter-class' => 'EchoFlowThanksFormatter',
'title-message' => 'notification-flow-thanks',
'title-params' => array( 'agent', 'postlink',
'topictitle', 'title', 'user' ),
- 'flyout-message' => 'notification-flow-thanks-flyout',
- 'flyout-params' => array( 'agent', 'topictitle',
'title', 'user' ),
'email-subject-message' =>
'notification-flow-thanks-email-subject',
'email-subject-params' => array( 'agent', 'user' ),
'email-body-batch-message' =>
'notification-flow-thanks-email-batch-body',
diff --git a/Thanks.php b/Thanks.php
index 23ed7f7..18c7647 100644
--- a/Thanks.php
+++ b/Thanks.php
@@ -45,6 +45,8 @@
$wgAutoloadClasses['ThanksHooks'] = __DIR__ . '/Thanks.hooks.php';
$wgAutoloadClasses['EchoThanksFormatter'] = __DIR__ . '/ThanksFormatter.php';
$wgAutoloadClasses['EchoFlowThanksFormatter'] = __DIR__ .
'/FlowThanksFormatter.php';
+$wgAutoloadClasses['EchoThanksPresentationModel'] = __DIR__ .
'/ThanksPresentationModel.php';
+$wgAutoloadClasses['EchoFlowThanksPresentationModel'] = __DIR__ .
'/FlowThanksPresentationModel.php';
$wgAutoloadClasses['ApiThank'] = __DIR__ . '/ApiThank.php';
$wgAutoloadClasses['ApiRevThank'] = __DIR__ . '/ApiRevThank.php';
$wgAutoloadClasses['ApiFlowThank'] = __DIR__ . '/ApiFlowThank.php';
diff --git a/ThanksPresentationModel.php b/ThanksPresentationModel.php
new file mode 100644
index 0000000..dc6e9a8
--- /dev/null
+++ b/ThanksPresentationModel.php
@@ -0,0 +1,44 @@
+<?php
+class EchoThanksPresentationModel extends EchoEventPresentationModel {
+ public function canRender() {
+ return (bool)$this->event->getTitle();
+ }
+
+ public function getIconType() {
+ return 'thanks';
+ }
+
+ public function getHeaderMessage() {
+ $msg = parent::getHeaderMessage();
+ $msg->params( $this->event->getTitle()->getPrefixedText() );
+
+ $user = User::newFromId( $this->event->getExtraParam(
'thanked-user-id' ) );
+ $msg->params( $user ? $user->getName() : '[]' );
+ return $msg;
+ }
+
+ public function getPrimaryLink() {
+ return array(
+ $this->event->getTitle()->getLocalURL( array(
+ 'oldid' => 'prev',
+ 'diff' => $this->event->getExtraParam( 'revid' )
+ ) ),
+ $this->msg( 'notification-link-text-view-edit' )
+ );
+ }
+
+ // TODO add thanking user as secondary link once we can make that look
nice (T115421)
+ /*
+ public function getSecondaryLinks() {
+ $agent = $this->event->getAgent();
+ if ( !$agent || !$this->userCan( Revision::DELETED_USER ) ) {
+ return array();
+ }
+
+ $url = $agent->getUserPage()->getLocalURL();
+ return array(
+ $url => $agent->getName()
+ );
+ }
+ */
+}
diff --git a/i18n/en.json b/i18n/en.json
index f5381d1..3eb0ddf 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -25,7 +25,7 @@
"echo-category-title-edit-thank": "Thanks",
"notification-thanks-diff-link": "your edit",
"notification-thanks": "[[User:$1|$1]] {{GENDER:$1|thanked}} you for $2
on [[:$3]].",
- "notification-thanks-flyout2": "[[User:$1|$1]] {{GENDER:$1|thanked}}
you for your edit on $2.",
+ "notification-header-edit-thank": "$1 {{GENDER:$2|thanked}}
{{GENDER:$4|you}} for your edit on $3.",
"notification-thanks-email-subject": "$1 {{GENDER:$1|thanked}} you for
your edit on {{SITENAME}}",
"notification-thanks-email-batch-body": "$1 {{GENDER:$1|thanked}} you
for your edit on $2.",
"log-name-thanks": "Thanks log",
@@ -40,7 +40,7 @@
"flow-thanks-thanked-notice": "$1 received your thanks for
{{GENDER:$2|his|her|their}} comment.",
"notification-flow-thanks": "[[User:$1|$1]] {{GENDER:$1|thanked}}
{{GENDER:$5|you}} for $2 in \"$3\" on [[:$4]].",
"notification-flow-thanks-post-link": "your comment",
- "notification-flow-thanks-flyout": "[[User:$1|$1]]
{{GENDER:$1|thanked}} {{GENDER:$4|you}} for your comment in \"$2\" on $3.",
+ "notification-header-flow-thank": "$1 {{GENDER:$2|thanked}}
{{GENDER:$5|you}} for your comment in \"$3\" on $4.",
"notification-flow-thanks-email-subject": "$1 {{GENDER:$1|thanked}}
{{GENDER:$2|you}} for your comment on {{SITENAME}}",
"notification-flow-thanks-email-batch-body": "$1 {{GENDER:$1|thanked}}
{{GENDER:$4|you}} for your comment in \"$2\" on $3.",
"apihelp-flowthank-description": "Send a public thank-you notification
for a Flow comment.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 7ff0f29..6dc5368 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -34,7 +34,7 @@
"echo-category-title-edit-thank": "This is a short title for the
notification category.\n\nUsed as <code>$1</code> in
{{msg-mw|Echo-dismiss-message}} and as <code>$2</code> in
{{msg-mw|Echo-email-batch-category-header}}\n{{Related|Echo-category-title}}\n{{Identical|Thank}}",
"notification-thanks-diff-link": "The text of a link to the user's
edit.\n\nUsed for <code>$2</code> in {{msg-mw|Notification-thanks}}. Should
have capitalization appropriate for the middle of a sentence.\n\nThis is an
object in a sentence so it should be in object case in languages where there is
a special object form for words.",
"notification-thanks": "Format for displaying notifications when a user
is thanked for their edit. Parameters:\n* $1 is the username of the person
sending the thanks, as plain text. Can be used for GENDER.\n* $2 is a link to
the user's edit. The text of the link is
{{msg-mw|Notification-thanks-diff-link}}.\n* $3 is the title of the page the
user edited.",
- "notification-thanks-flyout2": "Format for displaying notifications in
the flyout when a user is thanked for their edit. Parameters:\n* $1 is the
username of the person sending the thanks, as plain text. Can be used for
GENDER.\n* $2 is the title of the page the user edited.",
+ "notification-header-edit-thank": "Header text for a notification when
a user is thanked for their edit. Parameters:\n* $1 is the username of the user
sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name
for use in GENDER.\n* $3 is the title of the page the thanked user edited.\n*
$4 is the username of the user being thanked, for use in GENDER.",
"notification-thanks-email-subject": "E-mail subject. Parameters:\n* $1
is the username of the person sending the thanks, as plain text. Can be used
for GENDER.",
"notification-thanks-email-batch-body": "E-mail notification.
Parameters:\n* $1 is the username of the person sending the thanks, as plain
text. Can be used for GENDER.\n* $2 the title of the page the user edited.",
"log-name-thanks": "Name of log that appears on [[Special:Log]].",
@@ -49,7 +49,7 @@
"flow-thanks-thanked-notice": "{{doc-singularthey}}\nMessage displayed
after a user has thanked another user for their comment.\n\nParameters:\n* $1 -
the username of the user that was thanked\n* $2 - the gender of the user that
was thanked\nSee also:\n* {{msg-mw|Thanks-thanked-notice}}",
"notification-flow-thanks": "Format for displaying notifications when a
user is thanked for their comment on a Flow board.\n\nParameters:\n* $1 - the
username of the person sending the thanks, as plain text. Can be used for
GENDER.\n* $2 - a link to the comment. The text of the link is
{{msg-mw|Notification-flow-thanks-post-link}}.\n* $3 - the title of the topic
the comment belongs to\n* $4 - the title of the page where the comment is
located\n* $5 - the username (of the thanked person ?). Can be used for
GENDER.",
"notification-flow-thanks-post-link": "The text of a link to the
comment made by the user.\n\nUsed for <code>$2</code> in
{{msg-mw|notification-flow-thanks}}. Should have capitalization appropriate for
the middle of a sentence.\n\nThis is an object in a sentence so it should be in
object case in languages where there is a special object form for words.",
- "notification-flow-thanks-flyout": "Format for displaying notifications
in the flyout when a user is thanked for their comment on a Flow board.
Parameters:\n* $1 - the username of the person sending the thanks, as plain
text. Can be used for GENDER.\n* $2 - the title of the topic the comment
belongs to\n* $3 - the title of the page where the comment is located\n* $4 -
the username. Can be used for GENDER.",
+ "notification-header-flow-thank": "Header text for a notification when
a user is thanked for their comment on a Flow board. Parameters:\n* $1 is the
username of the user sending the thanks (not suitable for GENDER).\n* $2 is the
thanking user's name for use in GENDER.\n* $3 is the title of the topic the
comment belongs to\n* $4 is the title of the page where the comment is
located\n* $5 is the username of the user being thanked, for use in GENDER.",
"notification-flow-thanks-email-subject": "Email subject when a user is
thanked for a comment on a Flow board. Parameters:\n* $1 - the username of the
person sending the thanks, as plain text. Can be used for GENDER.\n* $2 - the
username. Can be used for GENDER.",
"notification-flow-thanks-email-batch-body": "Email notification.
Parameters:\n* $1 - the username of the person sending the thanks, as plain
text. Can be used for GENDER.\n* $2 - the title of the topic the comment
belongs to\n* $3 - the title of the page where the comment is located\n* $4 -
the username. Can be used for GENDER.",
"apihelp-flowthank-description":
"{{doc-apihelp-description|flowthank}}",
--
To view, visit https://gerrit.wikimedia.org/r/249358
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iab0f2311e7ffb6a9ce21cd76e564511d03805530
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Thanks
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Legoktm <[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