Debian Codegraph @

extensions/Echo/includes/Formatters/EchoMentionInSummaryPresentationModel.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Notifications\Formatters;
4
5 use MediaWiki\MediaWikiServices;
6 use MediaWiki\Parser\Sanitizer;
7 use MediaWiki\Revision\RevisionRecord;
8
9 class EchoMentionInSummaryPresentationModel extends EchoEventPresentationModel {
10
11 public function getIconType() {
12 return 'mention';
13 }
14
15 public function canRender() {
16 return (bool)$this->event->getTitle();
17 }
18
19 public function getHeaderMessage() {
20 $msg = $this->getMessageWithAgent( 'notification-header-mention-summary' );
21 $msg->params( $this->getViewingUserForGender() );
22 $msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
23
24 return $msg;
25 }
26
27 public function getBodyMessage() {
28 $revision = $this->event->getRevision();
29 if ( $revision && $revision->getComment() && $this->userCan( RevisionRecord::DELETED_COMMENT ) ) {
30 $summary = $revision->getComment()->text;
31 $summary = MediaWikiServices::getInstance()->getCommentFormatter()
32 ->format( $summary );
33 $summary = Sanitizer::stripAllTags( $summary );
34
35 return $this->msg( 'notification-body-mention' )
36 ->plaintextParams( $summary );
37 } else {
38 return false;
39 }
40 }
41
42 public function getPrimaryLink() {
43 return [
44 'url' => $this->getDiffURL(),
45 'label' => $this->msg( 'notification-link-text-view-changes', $this->getViewingUserForGender() )->text(),
46 ];
47 }
48
49 public function getSecondaryLinks() {
50 return [ $this->getAgentLink() ];
51 }
52
53 protected function getSubjectMessageKey() {
54 return 'notification-mention-email-subject';
55 }
56
57 private function getDiffURL() {
58 return $this->event->getTitle()->getLocalURL( [
59 'oldid' => 'prev',
60 'diff' => $this->event->getExtraParam( 'revid' )
61 ] );
62 }
63 }