jenkins-bot has submitted this change and it was merged. Change subject: Presentation model for reverted ......................................................................
Presentation model for reverted Bug: T116843 Change-Id: Ide03220ad8ad621b5943e36d71e484a21bc8a65b --- M Echo.php M autoload.php M i18n/en.json M i18n/qqq.json A includes/formatters/RevertedPresentationModel.php 5 files changed, 48 insertions(+), 4 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/Echo.php b/Echo.php index 7e38a40..cb11735 100644 --- a/Echo.php +++ b/Echo.php @@ -328,6 +328,7 @@ 'immediate' => true, ), 'reverted' => array( + 'presentation-model' => 'EchoRevertedPresentationModel', 'user-locators' => array( array( 'EchoUserLocator::locateFromEventExtra', array( 'reverted-user-id' ) ), ), @@ -338,8 +339,6 @@ 'formatter-class' => 'EchoEditFormatter', 'title-message' => 'notification-reverted2', 'title-params' => array( 'agent', 'title', 'difflink', 'number', 'userpage-contributions' ), - 'flyout-message' => 'notification-reverted-flyout2', - 'flyout-params' => array( 'agent', 'title', 'difflink', 'number' ), 'email-subject-message' => 'notification-reverted-email-subject2', 'email-subject-params' => array( 'agent', 'title', 'number' ), 'email-body-batch-message' => 'notification-reverted-email-batch-body2', diff --git a/autoload.php b/autoload.php index 681690a..5387fda 100644 --- a/autoload.php +++ b/autoload.php @@ -73,6 +73,7 @@ 'EchoNotifier' => __DIR__ . '/Notifier.php', 'EchoOnWikiList' => __DIR__ . '/includes/ContainmentSet.php', 'EchoPageLinkFormatter' => __DIR__ . '/includes/formatters/PageLinkFormatter.php', + 'EchoRevertedPresentationModel' => __DIR__ . '/includes/formatters/RevertedPresentationModel.php', 'EchoRevisionLocalCache' => __DIR__ . '/includes/cache/RevisionLocalCache.php', 'EchoRowUpdateGenerator' => __DIR__ . '/includes/BatchRowUpdate.php', 'EchoSeenTime' => __DIR__ . '/includes/SeenTime.php', diff --git a/i18n/en.json b/i18n/en.json index 43c97b7..1eae999 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -80,7 +80,7 @@ "notification-welcome-link": "", "notification-welcome-linktext": "Welcome", "notification-reverted2": "Your {{PLURAL:$4|edit on [[:$2]] has|edits on [[:$2]] have}} been {{GENDER:$1|reverted}} by [[$5|$1]]. $3", - "notification-reverted-flyout2": "Your {{PLURAL:$4|edit on $2 has|edits on $2 have}} been {{GENDER:$1|reverted}} by $1. $3", + "notification-header-reverted": "Your {{PLURAL:$4|edit on $3 has|edits on $3 have}} been {{GENDER:$2|reverted}} by $1.", "notification-emailuser": "[[User:$1|$1]] {{GENDER:$1|sent}} you an email.", "notification-emailuser-flyout": "$1 {{GENDER:$1|sent}} you an email", "notification-edit-talk-page-email-subject2": "$1 {{GENDER:$1|left}} you a message on {{SITENAME}}", diff --git a/i18n/qqq.json b/i18n/qqq.json index b66dfcb..94eb661 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -101,7 +101,7 @@ "notification-welcome-link": "{{notranslate}}", "notification-welcome-linktext": "Link text for link to the wiki's welcome or introduction page.\n{{Identical|Welcome}}", "notification-reverted2": "Format for displaying notifications of a user's edit being reverted. Parameters:\n* $1 - the username of the person who reverted, plain text. Can be used for GENDER.\n* $2 - the page that was reverted, formatted\n* $3 - a diff link which is labeled {{msg-mw|Showdiff}}\n* $4 - the number of edits that were reverted. NOTE: This will only be set to 1 or 2, with 2 actually meaning 'an unknown number greater than 0'.\n* $5 - Page for reverting user.\nUser page if logged in, or user's contributions page if logged out.\n{{Related|Notification-reverted}}", - "notification-reverted-flyout2": "Flyout-specific format for displaying notifications of a user's edit being reverted.\n\nParameters:\n* $1 - the username of the person who reverted, plain text. Can be used for GENDER.\n* $2 - the page that was reverted, formatted\n* $3 - a diff link which is labeled {{msg-mw|Showdiff}}\n* $4 - the number of edits that were reverted. NOTE: This will only be set to 1 or 2, with 2 actually meaning \"an unknown number greater than 0\".\n{{Related|Notification-reverted}}", + "notification-header-reverted": "Flyout-specific format for displaying notifications of a user's edit being reverted.\n\nParameters:\n* $1 - the formatted username of the person who reverted.\n* $2 - the username for GENDER\n* $3 - the page that was reverted, formatted\n* $4 - the number of edits that were reverted. NOTE: This will only be set to 1 or 2, with 2 actually meaning \"an unknown number greater than 0\".\n{{Related|Notification-reverted}}", "notification-emailuser": "Format for displaying notifications of a user has sent an email to another user. Parameters:\n* $1 - the username of the person the email, plain text. Can be used for GENDER.", "notification-emailuser-flyout": "Flyout-specific format for displaying notifications of user has sent an email to another user.\n\nParameters:\n* $1 - the username of the person who sent the email, plain text. Can be used for GENDER.", "notification-edit-talk-page-email-subject2": "Email subject. Parameters:\n* $1 - a username which can be used for gender support", diff --git a/includes/formatters/RevertedPresentationModel.php b/includes/formatters/RevertedPresentationModel.php new file mode 100644 index 0000000..4f26804 --- /dev/null +++ b/includes/formatters/RevertedPresentationModel.php @@ -0,0 +1,44 @@ +<?php + +class EchoRevertedPresentationModel extends EchoEventPresentationModel { + + public function getIconType() { + return 'revert'; + } + + public function canRender() { + return (bool)$this->event->getTitle(); + } + + public function getHeaderMessage() { + $msg = parent::getHeaderMessage(); + $msg->params( $this->event->getTitle()->getPrefixedText() ); + $msg->params( $this->getNumberOfEdits() ); + return $msg; + } + + public function getPrimaryLink() { + $url = $this->event->getTitle()->getLocalURL( array( + 'oldid' => 'prev', + 'diff' => $this->event->getExtraParam( 'revid' ) + ) ); + return array( + $url, $this->msg( 'notification-link-text-view-changes' )->text() + ); + } + + + /** + * Return a number that represents if one or multiple edits + * have been reverted for formatting purposes. + * @return int + */ + private function getNumberOfEdits() { + $method = $this->event->getExtraParam( 'method' ); + if ( $method && $method === 'rollback' ) { + return 2; + } else { + return 1; + } + } +} -- To view, visit https://gerrit.wikimedia.org/r/253613 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ide03220ad8ad621b5943e36d71e484a21bc8a65b Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits