mediawiki-extensions-Echo/includes/formatters/MentionInSummaryPresentationModel.php
Max Semenik 467b13fe89 Ping users mentioned in edit summaries
Disabled by default for now.

Bug: T32750
Change-Id: I8012b82b6e27cc2612fb2302d0c9feb3f3623d62
2018-02-22 12:37:35 -08:00

60 lines
1.4 KiB
PHP

<?php
class EchoMentionInSummaryPresentationModel extends EchoEventPresentationModel {
public function getIconType() {
return 'mention';
}
public function canRender() {
return (bool)$this->event->getTitle();
}
public function getHeaderMessage() {
$msg = $this->getMessageWithAgent( 'notification-header-mention-summary' );
$msg->params( $this->getViewingUserForGender() );
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle() ) );
return $msg;
}
public function getBodyMessage() {
if ( $this->userCan( Revision::DELETED_COMMENT ) ) {
$revision = $this->event->getRevision();
$summary = $revision->getComment();
$summary = Linker::formatComment( $summary );
$summary = Sanitizer::stripAllTags( $summary );
$msg = $this->msg( 'notification-body-mention' )
->plaintextParams( $summary );
return $msg;
} else {
return false;
}
}
public function getPrimaryLink() {
return [
'url' => $this->getDiffURL(),
'label' => $this->msg( 'notification-link-text-view-changes', $this->getViewingUserForGender() )->text(),
];
}
public function getSecondaryLinks() {
return [ $this->getAgentLink() ];
}
protected function getSubjectMessageKey() {
return 'notification-mention-email-subject';
}
private function getDiffURL() {
$title = $this->event->getTitle();
return $title->getLocalURL( [
'oldid' => 'prev',
'diff' => $this->event->getExtraParam( 'revid' )
] );
}
}