mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-13 17:52:33 +00:00
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
This commit is contained in:
parent
7a987af51c
commit
190ace1ed7
52
FlowThanksPresentationModel.php
Normal file
52
FlowThanksPresentationModel.php
Normal file
|
@ -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()
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -160,11 +160,10 @@ class ThanksHooks {
|
|||
'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 @@ class ThanksHooks {
|
|||
);
|
||||
|
||||
$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',
|
||||
|
|
|
@ -45,6 +45,8 @@ $wgExtensionCredits['other'][] = array(
|
|||
$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';
|
||||
|
|
44
ThanksPresentationModel.php
Normal file
44
ThanksPresentationModel.php
Normal file
|
@ -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()
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -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.",
|
||||
|
|
|
@ -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}}",
|
||||
|
|
Loading…
Reference in a new issue