Sbisson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/251502
Change subject: Presentation model for topic-renamed notification
......................................................................
Presentation model for topic-renamed notification
* Fix 'old-subject' to return previous topic title
instead of current topic title.
Bug: T116845
Change-Id: I210289db39196f0b132011a1c5292adb37f0b160
---
M autoload.php
M i18n/en.json
M i18n/qqq.json
M includes/Notifications/Controller.php
M includes/Notifications/Notifications.php
A includes/Notifications/TopicRenamedPresentationModel.php
6 files changed, 70 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/02/251502/1
diff --git a/autoload.php b/autoload.php
index a7391bc..e0e7960 100644
--- a/autoload.php
+++ b/autoload.php
@@ -377,6 +377,7 @@
'Flow\\Tests\\TemplatingTest' => __DIR__ .
'/tests/phpunit/TemplatingTest.php',
'Flow\\Tests\\UrlGeneratorTest' => __DIR__ .
'/tests/phpunit/UrlGeneratorTest.php',
'Flow\\Tests\\WatchedTopicItemTest' => __DIR__ .
'/tests/phpunit/WatchedTopicItemsTest.php',
+ 'Flow\\TopicRenamedPresentationModel' => __DIR__ .
'/includes/Notifications/TopicRenamedPresentationModel.php',
'Flow\\UrlGenerator' => __DIR__ . '/includes/UrlGenerator.php',
'Flow\\Utils\\NamespaceIterator' => __DIR__ .
'/includes/Utils/NamespaceIterator.php',
'Flow\\Utils\\PagesWithPropertyIterator' => __DIR__ .
'/includes/Utils/PagesWithPropertyIterator.php',
diff --git a/i18n/en.json b/i18n/en.json
index 7ae5033..6c8dfa9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -264,6 +264,7 @@
"flow-comment-moderated": "Moderated comment",
"flow-last-modified": "Last modified about $1",
"flow-workflow": "workflow",
+ "notification-header-flow-topic-renamed": "$1 {{GENDER:$2|changed}} the
title of \"$3\" to \"$4\" on $5",
"flow-notification-reply": "<span class=\"plainlinks
mw-echo-title-heading\">[$5 $2]</span><br />$1 {{GENDER:$1|responded}} on
'''$4'''.",
"flow-notification-reply-bundle": "<span class=\"plainlinks
mw-echo-title-heading\">[$4 $2]</span><br />$1 and $5
{{PLURAL:$6|other|others}} {{GENDER:$1|responded}} on '''$3'''.",
"flow-notification-edit": "<span class=\"plainlinks
mw-echo-title-heading\">[$6 $2]</span><br />$1 has {{GENDER:$1|edited}} your
<span class=\"plainlinks\">[$5 post]</span> on [[$3|$4]].",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 2bdfc67..985e117 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -276,6 +276,7 @@
"flow-notification-reply-bundle": "Notification text for when a user
receives replies from multiple users on the same topic.\n\nParameters:\n* $1 -
username of the person who replied\n* $2 - title of the topic\n* $3 - title for
the page that the Flow board is attached to\n* $4 - permantent URL for the
post\n* $5 - the count of other action performers, could be number or
{{msg-mw|Echo-notification-count}}. e.g. 7 others or 99+ others\n* $6 - a
number used for plural support\nSee also:\n*
{{msg-mw|Flow-notification-reply-email-batch-bundle-body}}\n{{Related|Flow-notification}}",
"flow-notification-edit": "Notification text for when a user's post is
edited. Parameters:\n* $1 - username of the person who edited the post\n* $2 -
title of the topic\n* $3 - title for the Flow board\n* $4 - title for the page
that the Flow board is attached to\n* $5 - permanent URL for the post\n* $6 -
permanent URL for the topic\n{{Related|Flow-notification}}",
"flow-notification-edit-bundle": "Notification text for when a user
receives post edits from multiple users on the same topic.\n\nParameters:\n* $1
- username of the person who edited post\n* $2 - title of the topic\n* $3 -
title for the page that the Flow board is attached to\n* $4 - permantent URL
for the topic\n* $5 - the count of other action performers, could be number or
{{msg-mw|Echo-notification-count}}. e.g. 7 others or 99+ others\n* $6 - a
number used for plural support\nSee also:\n*
{{msg-mw|Flow-notification-edit-email-batch-bundle-body}}\n{{Related|Flow-notification}}",
+ "notification-header-flow-topic-renamed": "Notification header text for
when a topic is renamed. Parameters:\n$1 - the formatted username of the user
who renamed the topic\n* $2 - the username for gender purposes\n* $3 - old
title of the topic\n* $4 - new title of the topic\n* $5 - title of the Flow
board.\n{{Related|Flow-notification}}",
"flow-notification-newtopic": "Notification text for when a new topic
is created. Parameters:\n* $1 - username of the person who created the topic\n*
$2 - (Unused) title for the Flow board\n* $3 - title for the page that the Flow
board is attached to\n* $4 - title of the topic\n* $5 - Fully qualified url to
view the created topic.\n{{Related|Flow-notification}}",
"flow-notification-newtopic-bundle": "Notification text for when
multiple new topics are created on the same page. Parameters:\n* $1 - The
number of topics that were created. This value is capped to 250. When this
value is 250 it means 250 or more topics have been created.\n* $2 - The title
of the page the topics were created on\n* $3 - Fully qualified url to view the
related board sorted by newest topics.\n{{Related|Flow-notification}}",
"flow-notification-rename": "Notification text for when the subject of
a topic is changed. Parameters:\n* $1 - username of the person who edited the
title, can be used for GENDER\n* $2 - permalink to the topic\n* $3 - old topic
subject\n* $4 - new topic subject\n* $5 - title for the Flow board\n* $6 -
title for the page that the Flow board is attached
to\n{{Related|Flow-notification}}",
diff --git a/includes/Notifications/Controller.php
b/includes/Notifications/Controller.php
index a610318..01e7a80 100644
--- a/includes/Notifications/Controller.php
+++ b/includes/Notifications/Controller.php
@@ -114,8 +114,9 @@
break;
case 'flow-topic-renamed':
+ $previousRevision =
$revision->getCollection()->getPrevRevision( $revision );
$extraData += array(
- 'old-subject' =>
$this->language->truncate( trim( $topicRevision->getContent( 'wikitext' ) ),
200 ),
+ 'old-subject' =>
$this->language->truncate( trim( $previousRevision->getContent( 'wikitext' ) ),
200 ),
'new-subject' =>
$this->language->truncate( trim( $revision->getContent( 'wikitext' ) ), 200 ),
);
break;
diff --git a/includes/Notifications/Notifications.php
b/includes/Notifications/Notifications.php
index d92d315..89f45ae 100644
--- a/includes/Notifications/Notifications.php
+++ b/includes/Notifications/Notifications.php
@@ -80,6 +80,7 @@
'email-body-batch-bundle-params' => array( 'agent', 'subject',
'title', 'agent-other-display', 'agent-other-count' ),
) + $notificationTemplate,
'flow-topic-renamed' => array(
+ 'presentation-model' => 'Flow\TopicRenamedPresentationModel',
'primary-link' => array(
'message' => 'flow-notification-link-text-view-post',
'destination' => 'flow-post'
diff --git a/includes/Notifications/TopicRenamedPresentationModel.php
b/includes/Notifications/TopicRenamedPresentationModel.php
new file mode 100644
index 0000000..8b967e3
--- /dev/null
+++ b/includes/Notifications/TopicRenamedPresentationModel.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Flow;
+
+use EchoEventPresentationModel;
+use Flow\Model\UUID;
+use Title;
+
+class TopicRenamedPresentationModel extends EchoEventPresentationModel {
+
+ public function canRender() {
+ $validTitle = (bool)$this->event->getTitle();
+ $validWorkflowId = $this->event->getExtraParam(
'topic-workflow' ) instanceof UUID;
+ $validPostId = $this->event->getExtraParam( 'post-id' )
instanceof UUID;
+ return $validTitle && $validWorkflowId && $validPostId;
+ }
+
+ public function getIconType() {
+ return 'flow-discussion';
+ }
+
+ public function getPrimaryLink() {
+ $url = $this->getPostLinkUrl();
+ $text = $this->msg( 'flow-notification-link-text-view-post'
)->text();
+ return array( $url, $text );
+ }
+
+ public function getHeaderMessage() {
+ $msg = parent::getHeaderMessage();
+ $msg->params( $this->event->getExtraParam( 'old-subject' ) );
+ $msg->params( $this->event->getExtraParam( 'new-subject' ) );
+ $msg->params( $this->event->getTitle()->getPrefixedText() );
+ return $msg;
+ }
+
+ /**
+ * Return a full url of following format:
+ *
https://<site>/wiki/Topic:<topicId>?topic_showPostId=<postId>&fromnotif=1#flow-post-<postId>
+ * @todo: Generate a url to the first unread post of a topic when we
figure out bundling in the new email formatter.
+ * @return string
+ */
+ protected function getPostLinkUrl() {
+ /** @var UUID $workflowId */
+ $workflowId = $this->event->getExtraParam( 'topic-workflow' );
+ /** @var UUID $postId */
+ $postId = $this->event->getExtraParam( 'post-id' );
+
+ $title = Title::makeTitleSafe(
+ NS_TOPIC,
+ $workflowId->getAlphadecimal(),
+ 'flow-post-' . $postId->getAlphadecimal()
+ );
+
+ $url = $title->getFullURL(
+ array(
+ 'topic_showPostId' =>
$postId->getAlphadecimal(),
+ 'fromnotif' => 1,
+ )
+ );
+
+ return $url;
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/251502
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I210289db39196f0b132011a1c5292adb37f0b160
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits