2018-01-19 21:26:49 +00:00
|
|
|
<?php
|
|
|
|
|
2022-11-01 22:01:23 +00:00
|
|
|
namespace MediaWiki\Extension\Notifications\Formatters;
|
|
|
|
|
|
|
|
use Linker;
|
2019-04-17 15:46:06 +00:00
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
2022-11-01 22:01:23 +00:00
|
|
|
use Sanitizer;
|
2019-04-17 15:46:06 +00:00
|
|
|
|
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 );
|
|
|
|
|
2022-11-01 21:39:23 +00:00
|
|
|
return $this->msg( 'notification-body-mention' )
|
2018-01-19 21:26:49 +00:00
|
|
|
->plaintextParams( $summary );
|
|
|
|
} 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() {
|
2022-11-01 21:39:23 +00:00
|
|
|
return $this->event->getTitle()->getLocalURL( [
|
2018-01-19 21:26:49 +00:00
|
|
|
'oldid' => 'prev',
|
|
|
|
'diff' => $this->event->getExtraParam( 'revid' )
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
}
|