2018-01-19 21:26:49 +00:00
|
|
|
<?php
|
|
|
|
|
2019-04-17 15:46:06 +00:00
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
|
|
|
|
2018-01-19 21:26:49 +00:00
|
|
|
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() );
|
2018-12-31 15:43:56 +00:00
|
|
|
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
|
2018-01-19 21:26:49 +00:00
|
|
|
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBodyMessage() {
|
2019-03-27 18:26:03 +00:00
|
|
|
$revision = $this->event->getRevision();
|
2019-07-16 00:06:15 +00:00
|
|
|
if ( $revision && $revision->getComment() && $this->userCan( RevisionRecord::DELETED_COMMENT ) ) {
|
2019-05-09 21:31:54 +00:00
|
|
|
$summary = $revision->getComment()->text;
|
2018-01-19 21:26:49 +00:00
|
|
|
$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' )
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
}
|