Sbisson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/251411

Change subject: Presentation model for new-topic notification
......................................................................

Presentation model for new-topic notification

Bug: T116845
Change-Id: I574a3514dc7f911e3e3541cd69d93e41b28dba38
---
M autoload.php
M i18n/en.json
M i18n/qqq.json
A includes/Notifications/NewTopicPresentationModel.php
M includes/Notifications/Notifications.php
5 files changed, 49 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/11/251411/1

diff --git a/autoload.php b/autoload.php
index a7391bc..1b31298 100644
--- a/autoload.php
+++ b/autoload.php
@@ -245,6 +245,7 @@
        'Flow\\Model\\WikiReference' => __DIR__ . 
'/includes/Model/WikiReference.php',
        'Flow\\Model\\Workflow' => __DIR__ . '/includes/Model/Workflow.php',
        'Flow\\NewTopicFormatter' => __DIR__ . 
'/includes/Notifications/Formatter.php',
+       'Flow\\NewTopicPresentationModel' => __DIR__ . 
'/includes/Notifications/NewTopicPresentationModel.php',
        'Flow\\NotificationController' => __DIR__ . 
'/includes/Notifications/Controller.php',
        'Flow\\NotificationFormatter' => __DIR__ . 
'/includes/Notifications/Formatter.php',
        'Flow\\NotificationsUserLocator' => __DIR__ . 
'/includes/Notifications/UserLocator.php',
diff --git a/i18n/en.json b/i18n/en.json
index 7ae5033..4774740 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -268,6 +268,8 @@
        "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]].",
        "flow-notification-edit-bundle": "$1 and $5 {{PLURAL:$6|other|others}} 
{{GENDER:$1|edited}} a <span class=\"plainlinks\">[$4 post]</span> in \"$2\" on 
\"$3\".",
+       "notification-header-flow-new-topic": "$4",
+       "notification-body-flow-new-topic": "$1 {{GENDER:$2|created}} a new 
topic on $3",
        "flow-notification-newtopic": "<span class=\"mw-echo-title-heading 
plainlinks\">[$5 $4]</span><br />$1 {{GENDER:$1|created}} a new topic on 
'''$3'''.",
        "flow-notification-newtopic-bundle": "{{PLURAL:$1|$1 new topic|$1 new 
topics|250=250+ new topics}} on '''<span class=\"plainlinks\">[$3 
$2]</span>'''",
        "flow-notification-rename": "$1 {{GENDER:$1|changed}} the title of 
<span class=\"plainlinks\">[$2 $3]</span> to \"$4\" on [[$5|$6]].",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 2bdfc67..a1f86c3 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -276,6 +276,8 @@
        "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-new-topic": "Notification header text for 
when a new topic is created. Parameters:\n$1 - the formatted username of the 
user who created the topic\n* $2 - the username for gender purposes\n* $3 - 
title of the Flow board\n* $4 - title of the 
topic.\n{{Related|Flow-notification}}",
+       "notification-body-flow-new-topic": "Notification body text for when a 
new topic is created. Parameters:\n$1 - the formatted username of the user who 
created the topic\n* $2 - the username for gender purposes\n* $3 - title of the 
Flow board\n* $4 - title of the topic.\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/NewTopicPresentationModel.php 
b/includes/Notifications/NewTopicPresentationModel.php
new file mode 100644
index 0000000..d82f056
--- /dev/null
+++ b/includes/Notifications/NewTopicPresentationModel.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Flow;
+
+use EchoEventPresentationModel;
+
+class NewTopicPresentationModel extends EchoEventPresentationModel {
+
+       public function canRender() {
+               return (bool)$this->event->getTitle();
+       }
+
+       public function getIconType()
+       {
+               return 'flow-discussion';
+       }
+
+       public function getPrimaryLink()
+       {
+               /** @var UrlGenerator $urlGenerator */
+               $urlGenerator = Container::get( 'url_generator' );
+               $url = $urlGenerator->boardLink( $this->event->getTitle(), 
'newest' )->getFullURL();
+               $msg = $this->msg( 'flow-notification-link-text-view-topic' );
+               return array( $url, $msg );
+       }
+
+       public function getHeaderMessage() {
+               $msg = parent::getHeaderMessage();
+               $msg->params( $this->event->getTitle() );
+               $msg->params( $this->event->getExtra()['topic-title'] );
+               return $msg;
+       }
+
+       public function getBodyMessage() {
+               $msg = $this->msg( 'notification-body-flow-new-topic' );
+               list( $formattedName, $genderName ) = 
$this->getAgentForOutput();
+               $msg->params( $formattedName, $genderName );
+               $msg->params( $this->event->getTitle() );
+               $msg->params( $this->event->getExtra()['topic-title'] );
+               return $msg;
+       }
+
+}
\ No newline at end of file
diff --git a/includes/Notifications/Notifications.php 
b/includes/Notifications/Notifications.php
index d92d315..d580331 100644
--- a/includes/Notifications/Notifications.php
+++ b/includes/Notifications/Notifications.php
@@ -11,6 +11,7 @@
 
 $notifications = array(
        'flow-new-topic' => array(
+               'presentation-model' => 'Flow\NewTopicPresentationModel',
                'formatter-class' => 'Flow\NewTopicFormatter',
                'user-locators' => array(
                        'EchoUserLocator::locateUsersWatchingTitle',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I574a3514dc7f911e3e3541cd69d93e41b28dba38
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

Reply via email to