jenkins-bot has submitted this change and it was merged.
Change subject: Notifications presentation models
......................................................................
Notifications presentation models
Bug: T116849
Change-Id: I31f46a85529fc5f9ed491889ed6fe6e0906b690e
---
M PageTriage.hooks.php
M PageTriage.php
M i18n/en.json
M i18n/qqq.json
A includes/Notifications/PageTriageAddDeletionTagPresentationModel.php
A includes/Notifications/PageTriageAddMaintenanceTagPresentationModel.php
A includes/Notifications/PageTriageMarkAsReviewedPresentationModel.php
R includes/Notifications/PageTriageNotificationFormatter.php
8 files changed, 170 insertions(+), 13 deletions(-)
Approvals:
Sbisson: Looks good to me, but someone else must approve
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/PageTriage.hooks.php b/PageTriage.hooks.php
index a7d579e..604a7f3 100755
--- a/PageTriage.hooks.php
+++ b/PageTriage.hooks.php
@@ -473,6 +473,7 @@
* @param $notifications array a list of enabled echo events
* @param $notificationCategories array details for echo events
* @param $icons array of icon details
+ * @return bool
*/
public static function onBeforeCreateEchoEvent( &$notifications,
&$notificationCategories, &$icons ) {
global $wgPageTriageEnabledEchoEvents;
@@ -486,14 +487,13 @@
if ( in_array( 'pagetriage-mark-as-reviewed',
$wgPageTriageEnabledEchoEvents ) ) {
$notifications['pagetriage-mark-as-reviewed'] = array(
+ 'presentation-model' =>
'PageTriageMarkAsReviewedPresentationModel',
'primary-link' => array( 'message' =>
'notification-link-text-view-page', 'destination' => 'title' ),
'category' => 'page-review',
'group' => 'neutral',
'formatter-class' =>
'PageTriageNotificationFormatter',
'title-message' =>
'pagetriage-notification-mark-as-reviewed2',
'title-params' => array( 'agent', 'title' ),
- 'flyout-message' =>
'pagetriage-notification-mark-as-reviewed-flyout',
- 'flyout-params' => array( 'agent', 'title' ),
'email-subject-message' =>
'pagetriage-notification-mark-as-reviewed-email-subject2',
'email-subject-params' => array( 'agent',
'title' ),
'email-body-batch-message' =>
'pagetriage-notification-mark-as-reviewed-email-batch-body',
@@ -503,14 +503,13 @@
}
if ( in_array( 'pagetriage-add-maintenance-tag',
$wgPageTriageEnabledEchoEvents ) ) {
$notifications['pagetriage-add-maintenance-tag'] =
array(
+ 'presentation-model' =>
'PageTriageAddMaintenanceTagPresentationModel',
'primary-link' => array( 'message' =>
'notification-link-text-view-page', 'destination' => 'title' ),
'category' => 'page-review',
'group' => 'neutral',
'formatter-class' =>
'PageTriageNotificationFormatter',
'title-message' =>
'pagetriage-notification-add-maintenance-tag2',
'title-params' => array( 'agent', 'title',
'tag' ),
- 'flyout-message' =>
'pagetriage-notification-add-maintenance-tag-flyout',
- 'flyout-params' => array( 'agent', 'title',
'tag' ),
'email-subject-message' =>
'pagetriage-notification-add-maintenance-tag-email-subject2',
'email-subject-params' => array( 'agent',
'title' ),
'email-body-batch-message' =>
'pagetriage-notification-add-maintenance-tag-email-batch-body',
@@ -520,14 +519,13 @@
}
if ( in_array( 'pagetriage-add-deletion-tag',
$wgPageTriageEnabledEchoEvents ) ) {
$notifications['pagetriage-add-deletion-tag'] = array(
+ 'presentation-model' =>
'PageTriageAddDeletionTagPresentationModel',
'primary-link' => array( 'message' =>
'notification-link-text-view-page', 'destination' => 'title' ),
'category' => 'page-review',
'group' => 'negative',
'formatter-class' =>
'PageTriageNotificationFormatter',
'title-message' =>
'pagetriage-notification-add-deletion-tag2',
'title-params' => array( 'agent', 'title',
'tag' ),
- 'flyout-message' =>
'pagetriage-notification-add-deletion-tag-flyout',
- 'flyout-params' => array( 'agent', 'title',
'tag' ),
'email-subject-message' =>
'pagetriage-notification-add-deletion-tag-email-subject2',
'email-subject-params' => array( 'agent',
'title' ),
'email-body-batch-message' =>
'pagetriage-notification-add-deletion-tag-email-batch-body',
@@ -543,6 +541,7 @@
* Add users to be notified on an echo event
* @param $event EchoEvent
* @param $users array
+ * @return bool
*/
public static function onEchoGetDefaultNotifiedUsers( $event, &$users )
{
switch ( $event->getType() ) {
diff --git a/PageTriage.php b/PageTriage.php
index f2dd47e..81bb8cd 100644
--- a/PageTriage.php
+++ b/PageTriage.php
@@ -128,7 +128,10 @@
$wgAutoloadClasses['PageTriageExternalTagsOptions'] = $dir .
'includes/PageTriageExternalTagsOptions.php';
$wgAutoloadClasses['PageTriageExternalDeletionTagsOptions'] = $dir .
'includes/PageTriageExternalDeletionTagsOptions.php';
$wgAutoloadClasses['PageTriageLogFormatter'] = $dir .
'includes/PageTriageLogFormatter.php';
-$wgAutoloadClasses['PageTriageNotificationFormatter'] = $dir .
'includes/PageTriageNotificationFormatter.php';
+$wgAutoloadClasses['PageTriageNotificationFormatter'] = $dir .
'includes/Notifications/PageTriageNotificationFormatter.php';
+$wgAutoloadClasses['PageTriageMarkAsReviewedPresentationModel'] = $dir .
'includes/Notifications/PageTriageMarkAsReviewedPresentationModel.php';
+$wgAutoloadClasses['PageTriageAddMaintenanceTagPresentationModel'] = $dir .
'includes/Notifications/PageTriageAddMaintenanceTagPresentationModel.php';
+$wgAutoloadClasses['PageTriageAddDeletionTagPresentationModel'] = $dir .
'includes/Notifications/PageTriageAddDeletionTagPresentationModel.php';
$wgAutoloadClasses['ApiPageTriageList'] = $dir . 'api/ApiPageTriageList.php';
$wgAutoloadClasses['ApiPageTriageStats'] = $dir . 'api/ApiPageTriageStats.php';
diff --git a/i18n/en.json b/i18n/en.json
index 747da40..2fcde15 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -356,17 +356,17 @@
"pagetriage-toolbar-minimize": "Minimize",
"pagetriage-tag-warning-notice": "Note: This page is only $1
{{PLURAL:$1|minute|minutes}} old. Consider waiting to tag it, unless the issue
is serious.",
"pagetriage-notification-mark-as-reviewed2": "The page [[$2]] was
{{GENDER:$1|reviewed}} by [[User:$1|$1]]",
- "pagetriage-notification-mark-as-reviewed-flyout": "The page [[$2]] was
{{GENDER:$1|reviewed}} by <b>$1</b>",
"pagetriage-notification-mark-as-reviewed-email-subject2": "Your page
was {{GENDER:$1|reviewed}} on {{SITENAME}}",
"pagetriage-notification-mark-as-reviewed-email-batch-body": "The page
$1 was {{GENDER:$2|reviewed}} by $2.",
"pagetriage-notification-add-maintenance-tag2": "The page [[$2]] was
{{GENDER:$1|reviewed}} and {{GENDER:$1|tagged}} by [[User:$1|$1]].
{{PLURAL:$4|Tag|Tags}}: $3",
- "pagetriage-notification-add-maintenance-tag-flyout": "The page [[$2]]
was {{GENDER:$1|reviewed}} and {{GENDER:$1|tagged}} by <b>$1</b>.
{{PLURAL:$4|Tag|Tags}}: $3",
"pagetriage-notification-add-maintenance-tag-email-subject2": "Your
page was {{GENDER:$1|tagged}} on {{SITENAME}}",
"pagetriage-notification-add-maintenance-tag-email-batch-body": "The
page $1 was {{GENDER:$2|reviewed}} and {{GENDER:$2|tagged}} by $2.",
"pagetriage-notification-add-deletion-tag2": "The page [[$2]] was
{{GENDER:$1|reviewed}} and {{GENDER:$1|marked for deletion}} by [[User:$1|$1]].
{{PLURAL:$4|Tag|Tags}}: $3",
- "pagetriage-notification-add-deletion-tag-flyout": "The page [[$2]] was
{{GENDER:$1|reviewed}} and {{GENDER:$1|marked for deletion}} by <b>$1</b>.
{{PLURAL:$4|Tag|Tags}}: $3",
"pagetriage-notification-add-deletion-tag-email-subject2": "Your page
was {{GENDER:$1|marked for deletion}} on {{SITENAME}}",
"pagetriage-notification-add-deletion-tag-email-batch-body": "The page
$1 was {{GENDER:$2|marked for deletion}} by $2.",
+ "notification-header-pagetriage-mark-as-reviewed": "The page $3 was
{{GENDER:$2|reviewed}} by <b>$1</b>",
+ "notification-header-pagetriage-add-maintenance-tag": "The page $3 was
{{GENDER:$2|reviewed}} and {{GENDER:$2|tagged}} by <b>$1</b>.
{{PLURAL:$5|Tag|Tags}}: $4",
+ "notification-header-pagetriage-add-deletion-tag": "The page $3 was
{{GENDER:$2|reviewed}} and {{GENDER:$2|marked for deletion}} by <b>$1</b>.
{{PLURAL:$5|Tag|Tags}}: $4",
"echo-pref-subscription-page-review": "Reviews a page I created",
"echo-pref-tooltip-page-review": "Notify me when someone reviews a page
I created.",
"echo-category-title-page-review": "Page {{PLURAL:$1|review|reviews}}",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index df6d3e5..a921e3b 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -368,17 +368,17 @@
"pagetriage-toolbar-minimize": "Tooltip for the minimize button in the
Curation Toolbar (also docks the minimized toolbar to the side of the
screen).\n{{Identical|Minimize}}",
"pagetriage-tag-warning-notice": "Warning notice in maintenance and
deletion tag flyout if the page was created less than some amount of time
ago.\n\nParameters:\n* $1 - number of minutes",
"pagetriage-notification-mark-as-reviewed2": "Title for 'mark as
reviewed' notification. Parameters:\n* $1 is the username of the person who
marked the page as reviewed, plain text\n* $2 is the title of the page\nSee
also:\n* {{msg-mw|Pagetriage-notification-mark-as-reviewed-flyout}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-email-batch-body}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-email-subject2}}",
- "pagetriage-notification-mark-as-reviewed-flyout": "Flyout-specific
title for 'mark as reviewed' notification. Parameters:\n* $1 is the username
of the person who marked the page as reviewed, plain text\n* $2 is the title of
the page\nSee also:\n* {{msg-mw|Pagetriage-notification-mark-as-reviewed2}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-email-batch-body}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-email-subject2}}",
"pagetriage-notification-mark-as-reviewed-email-subject2": "Email
subject for \"mark as reviewed\" notification. Parameters:\n* $1 - the
username of the person who marked the page as reviewed, for PLURAL support\n*
$2 - (Unused) the title of the page\nSee also:\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed2}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-flyout}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-email-batch-body}}",
"pagetriage-notification-mark-as-reviewed-email-batch-body": "Email
batch body for 'mark as reviewed' notification. Parameters:\n* $1 is the title
of the page\n* $2 is the username of the person who reviewed the page\nSee
also:\n* {{msg-mw|Pagetriage-notification-mark-as-reviewed2}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-flyout}}\n*
{{msg-mw|Pagetriage-notification-mark-as-reviewed-email-subject2}}",
"pagetriage-notification-add-maintenance-tag2": "Title for 'add
maintenance tag' notification. Parameters:\n* $1 is the username of the person
who added maintenance tag, plain text\n* $2 is the title of the page\n* $3 is
the list of maintenance tags\n* $4 is the number of maintenance tags\nSee
also:\n* {{msg-mw|Pagetriage-notification-add-maintenance-tag-flyout}}\n*
{{msg-mw|Pagetriage-notification-add-maintenance-tag-email-subject2}}",
- "pagetriage-notification-add-maintenance-tag-flyout": "Flyout-specific
title for 'add maintenance tag' notification. Parameters:\n* $1 is the
username of the person who added maintenance tag, plain text\n* $2 is the title
of the page\n* $3 is the list of maintenance tags\n* $4 is the number of
maintenance tags\nSee also:\n*
{{msg-mw|Pagetriage-notification-add-maintenance-tag2}}\n*
{{msg-mw|Pagetriage-notification-add-maintenance-tag-email-subject2}}",
"pagetriage-notification-add-maintenance-tag-email-subject2": "Email
subject for \"add maintenance tag\" notification. Parameters:\n* $1 - the
username of the person who added maintenance tag, for PLURAL support\n* $2 -
(Unused) the title of the page\nSee also:\n*
{{msg-mw|Pagetriage-notification-add-maintenance-tag2}}\n*
{{msg-mw|Pagetriage-notification-add-maintenance-tag-flyout}}",
"pagetriage-notification-add-maintenance-tag-email-batch-body": "Email
batch body for 'add maintenance tag' notification. Parameters:\n* $1 is the
title of the page\n* $2 is the username of the person who added maintenance tag
to the page",
"pagetriage-notification-add-deletion-tag2": "Title for 'add deletion
tag' notification. Parameters:\n* $1 is the username of the person who added
deletion tag, plain text\n* $2 is the title of the page\n* $3 is the list of
deletion tags\n* $4 is the number of deletion tags\nSee also:\n*
{{msg-mw|Pagetriage-notification-add-deletion-tag-flyout}}\n*
{{msg-mw|Pagetriage-notification-add-deletion-tag-email-subject2}}",
- "pagetriage-notification-add-deletion-tag-flyout": "Flyout-specific
title for 'add deletion tag' notification. Parameters:\n* $1 - the username of
the person who added deletion tag, plain text\n* $2 - the title of the page\n*
$3 - the list of deletion tags\n* $4 - the number of deletion tags\nSee
also:\n* {{msg-mw|Pagetriage-notification-add-deletion-tag2}}\n*
{{msg-mw|Pagetriage-notification-add-deletion-tag-email-subject2}}",
"pagetriage-notification-add-deletion-tag-email-subject2": "Email
subject for \"add deletion tag\" notification. Parameters:\n* $1 - the
username of the person who added deletion tag, for PLURAL support\n* $2 -
(Unused) the title of the page\nSee also:\n*
{{msg-mw|Pagetriage-notification-add-deletion-tag2}}\n*
{{msg-mw|Pagetriage-notification-add-deletion-tag-flyout}}",
"pagetriage-notification-add-deletion-tag-email-batch-body": "Email
batch body for 'add deletion tag' notification. Parameters:\n* $1 is the title
of the page\n* $2 is the username of the person who added maintenance tag to
the page",
+ "notification-header-pagetriage-mark-as-reviewed": "Flyout-specific
title for 'mark as reviewed' notification. Parameters:\n* $1 is the formatted
user name (the user name, or hidden if deleted user)\n* $2 can be used for
GENDER of user at $1\n* $3 is the title of the page",
+ "notification-header-pagetriage-add-maintenance-tag": "Flyout-specific
title for 'add maintenance tag' notification. Parameters:\n* $1 is the
formatted user name (the user name, or hidden if deleted user)\n* $2 can be
used for GENDER of user at $1\n* $3 is the title of the page\n* $4 is the list
of maintenance tags\n* $5 is the number of maintenance tags",
+ "notification-header-pagetriage-add-deletion-tag": "Flyout-specific
title for 'add deletion tag' notification. Parameters:\n* $1 is the formatted
user name (the user name, or hidden if deleted user)\n* $2 can be used for
GENDER of user at $1\n* $3 is the title of the page\n* $4 is the list of
maintenance tags\n* $5 is the number of maintenance tags",
"echo-pref-subscription-page-review": "Option for getting notifications
when someone reviews a page created by the user.\n\nThis is the conclusion of
the sentence begun by the header: {{msg-mw|Prefs-echosubscriptions}}.",
"echo-pref-tooltip-page-review": "This is a short description of the
page-review notification category.\n{{Related|Echo-pref-tooltip}}",
"echo-category-title-page-review": "This is a short title for
notification category.\n\nUsed as <code>$1</code> in
{{msg-mw|Echo-dismiss-message}} and <code>$2</code> in
{{msg-mw|Echo-email-batch-category-header}}.\n\nParameters:\n* $1 - the number
used for plural support\n{{Related|Echo-category-title}}",
diff --git
a/includes/Notifications/PageTriageAddDeletionTagPresentationModel.php
b/includes/Notifications/PageTriageAddDeletionTagPresentationModel.php
new file mode 100644
index 0000000..ffe6818
--- /dev/null
+++ b/includes/Notifications/PageTriageAddDeletionTagPresentationModel.php
@@ -0,0 +1,58 @@
+<?php
+
+class PageTriageAddDeletionTagPresentationModel extends
EchoEventPresentationModel {
+ /**
+ * {@inheritdoc}
+ */
+ public function canRender() {
+ return $this->event->getTitle() instanceof Title;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIconType() {
+ return 'trash';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPrimaryLink() {
+ return array(
+ $this->event->getTitle()->getFullURL(),
+ $this->msg( 'notification-link-text-view-page' )->text()
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getHeaderMessage() {
+ $msg = parent::getHeaderMessage();
+
+ // parent adds agent & gender, this adds title as 3rd param, tag list
as
+ // 4th & amount of tags as 5th (for PLURAL)
+ $msg->params( $this->event->getTitle() );
+ $msg->params( $this->getTagsForOutput() );
+
+ return $msg;
+ }
+
+ /**
+ * Returns an array of [tag list, amount of tags], to be used as msg
params.
+ *
+ * @return array [(string) tag list, (int) amount of tags]
+ */
+ protected function getTagsForOutput() {
+ global $wgContLang;
+
+ $eventData = $this->event->getExtra();
+
+ if ( !is_array( $eventData ) ) {
+ return array( '', 0 );
+ }
+
+ return array( $wgContLang->listToText( $eventData ), count( $eventData
) );
+ }
+}
diff --git
a/includes/Notifications/PageTriageAddMaintenanceTagPresentationModel.php
b/includes/Notifications/PageTriageAddMaintenanceTagPresentationModel.php
new file mode 100644
index 0000000..c5382e9
--- /dev/null
+++ b/includes/Notifications/PageTriageAddMaintenanceTagPresentationModel.php
@@ -0,0 +1,58 @@
+<?php
+
+class PageTriageAddMaintenanceTagPresentationModel extends
EchoEventPresentationModel {
+ /**
+ * {@inheritdoc}
+ */
+ public function canRender() {
+ return $this->event->getTitle() instanceof Title;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIconType() {
+ return 'checkmark';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPrimaryLink() {
+ return array(
+ $this->event->getTitle()->getFullURL(),
+ $this->msg( 'notification-link-text-view-page' )->text()
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getHeaderMessage() {
+ $msg = parent::getHeaderMessage();
+
+ // parent adds agent & gender, this adds title as 3rd param, tag list
as
+ // 4th & amount of tags as 5th (for PLURAL)
+ $msg->params( $this->event->getTitle() );
+ $msg->params( $this->getTagsForOutput() );
+
+ return $msg;
+ }
+
+ /**
+ * Returns an array of [tag list, amount of tags], to be used as msg
params.
+ *
+ * @return array [(string) tag list, (int) amount of tags]
+ */
+ protected function getTagsForOutput() {
+ global $wgContLang;
+
+ $eventData = $this->event->getExtra();
+
+ if ( !is_array( $eventData ) ) {
+ return array( '', 0 );
+ }
+
+ return array( $wgContLang->listToText( $eventData ), count( $eventData
) );
+ }
+}
diff --git
a/includes/Notifications/PageTriageMarkAsReviewedPresentationModel.php
b/includes/Notifications/PageTriageMarkAsReviewedPresentationModel.php
new file mode 100644
index 0000000..ffeaa3d
--- /dev/null
+++ b/includes/Notifications/PageTriageMarkAsReviewedPresentationModel.php
@@ -0,0 +1,39 @@
+<?php
+
+class PageTriageMarkAsReviewedPresentationModel extends
EchoEventPresentationModel {
+ /**
+ * {@inheritdoc}
+ */
+ public function canRender() {
+ return $this->event->getTitle() instanceof Title;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIconType() {
+ return 'checkmark';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPrimaryLink() {
+ return array(
+ $this->event->getTitle()->getFullURL(),
+ $this->msg( 'notification-link-text-view-page' )->text()
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getHeaderMessage() {
+ $msg = parent::getHeaderMessage();
+
+ // parent adds agent & gender, this adds title as 3rd param
+ $msg->params( $this->event->getTitle() );
+
+ return $msg;
+ }
+}
diff --git a/includes/PageTriageNotificationFormatter.php
b/includes/Notifications/PageTriageNotificationFormatter.php
similarity index 100%
rename from includes/PageTriageNotificationFormatter.php
rename to includes/Notifications/PageTriageNotificationFormatter.php
--
To view, visit https://gerrit.wikimedia.org/r/252670
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I31f46a85529fc5f9ed491889ed6fe6e0906b690e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/PageTriage
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Catrope <[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