blob: 46ce1db086765da1926f34bc9d211e833bf0c701 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<?php
use MediaWiki\Revision\RevisionRecord;
class EchoRevertedPresentationModel extends EchoEventPresentationModel {
public function getIconType() {
return 'revert';
}
public function canRender() {
return (bool)$this->event->getTitle();
}
public function getHeaderMessage() {
$msg = parent::getHeaderMessage();
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
$msg->params( $this->getNumberOfEdits() );
return $msg;
}
public function getBodyMessage() {
$summary = $this->event->getExtraParam( 'summary' );
if (
!$this->isAutomaticSummary( $summary ) &&
$this->userCan( RevisionRecord::DELETED_COMMENT )
) {
$msg = $this->msg( 'notification-body-reverted' );
$msg->plaintextParams( $this->formatSummary( $summary ) );
return $msg;
} else {
return false;
}
}
private function formatSummary( $wikitext ) {
return EchoDiscussionParser::getTextSnippetFromSummary( $wikitext, $this->language );
}
public function getPrimaryLink() {
$url = $this->event->getTitle()->getLocalURL( [
'oldid' => 'prev',
'diff' => $this->event->getExtraParam( 'revid' )
] );
return [
'url' => $url,
'label' => $this->msg( 'notification-link-text-view-changes', $this->getViewingUserForGender() )->text()
];
}
public function getSecondaryLinks() {
$links = [ $this->getAgentLink() ];
$title = $this->event->getTitle();
if ( $title->canHaveTalkPage() ) {
$links[] = $this->getPageLink(
$title->getTalkPage(), '', true
);
}
return $links;
}
/**
* Return a number that represents if one or multiple edits
* have been reverted for formatting purposes.
* @return int
*/
private function getNumberOfEdits() {
$method = $this->event->getExtraParam( 'method' );
if ( $method && $method === 'rollback' ) {
return 2;
} else {
return 1;
}
}
private function isAutomaticSummary( $summary ) {
$autoSummaryMsg = wfMessage( 'undo-summary' )->inContentLanguage();
$autoSummaryMsg->params( $this->event->getExtraParam( 'reverted-revision-id' ) );
$autoSummaryMsg->params( $this->getViewingUserForGender() );
$autoSummary = $autoSummaryMsg->text();
return $summary === $autoSummary;
}
protected function getSubjectMessageKey() {
return 'notification-reverted-email-subject2';
}
public function getSubjectMessage() {
return parent::getSubjectMessage()->params( $this->getNumberOfEdits() );
}
}
|