Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 42 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
SummaryEditedPresentationModel | |
0.00% |
0 / 42 |
|
0.00% |
0 / 9 |
306 | |
0.00% |
0 / 1 |
getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
canRender | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getPrimaryLink | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSecondaryLinks | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
getHeaderMessageKey | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
isFirstRevision | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeaderMessage | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getBodyMessage | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getDiffLink | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Flow\Notifications; |
4 | |
5 | use Flow\Container; |
6 | use Flow\UrlGenerator; |
7 | use MediaWiki\Title\Title; |
8 | |
9 | class SummaryEditedPresentationModel extends FlowPresentationModel { |
10 | |
11 | /** @inheritDoc */ |
12 | public function getIconType() { |
13 | return 'flow-topic-renamed'; |
14 | } |
15 | |
16 | /** @inheritDoc */ |
17 | public function canRender() { |
18 | return $this->hasTitle() |
19 | && $this->hasValidTopicWorkflowId() |
20 | && $this->event->getExtraParam( 'revision-id' ) !== null; |
21 | } |
22 | |
23 | /** @inheritDoc */ |
24 | public function getPrimaryLink() { |
25 | return $this->getViewTopicLink(); |
26 | } |
27 | |
28 | /** @inheritDoc */ |
29 | public function getSecondaryLinks() { |
30 | if ( $this->isBundled() ) { |
31 | $links = [ $this->getBoardLink() ]; |
32 | } else { |
33 | $links = [ $this->getAgentLink(), $this->getBoardLink() ]; |
34 | if ( !$this->isFirstRevision() ) { |
35 | $links[] = $this->getDiffLink( false ); |
36 | } |
37 | } |
38 | |
39 | $links[] = $this->getFlowUnwatchDynamicActionLink( true ); |
40 | |
41 | return $links; |
42 | } |
43 | |
44 | /** @inheritDoc */ |
45 | protected function getHeaderMessageKey() { |
46 | if ( $this->isBundled() ) { |
47 | $key = "notification-bundle-header-flow-summary-edited"; |
48 | } elseif ( $this->isFirstRevision() ) { |
49 | $key = 'notification-header-flow-summary-edited-first'; |
50 | } else { |
51 | $key = 'notification-header-flow-summary-edited'; |
52 | } |
53 | |
54 | if ( $this->isUserTalkPage() ) { |
55 | $key .= '-user-talk'; |
56 | } |
57 | |
58 | return $key; |
59 | } |
60 | |
61 | protected function isFirstRevision() { |
62 | return $this->event->getExtraParam( 'prev-revision-id' ) === null; |
63 | } |
64 | |
65 | /** @inheritDoc */ |
66 | public function getHeaderMessage() { |
67 | $msg = $this->msg( $this->getHeaderMessageKey() ); |
68 | $msg->plaintextParams( $this->getTopicTitle() ); |
69 | $msg->params( $this->getViewingUserForGender() ); |
70 | return $msg; |
71 | } |
72 | |
73 | /** @inheritDoc */ |
74 | public function getBodyMessage() { |
75 | $key = 'notification-body-flow-summary-edited'; |
76 | if ( $this->isUserTalkPage() ) { |
77 | $key .= '-user-talk'; |
78 | } |
79 | |
80 | return $this->msg( $key )->plaintextParams( $this->getContentSnippet() ); |
81 | } |
82 | |
83 | protected function getDiffLink( $prioritized = true ) { |
84 | /** @var UrlGenerator $urlGenerator */ |
85 | $urlGenerator = Container::get( 'url_generator' ); |
86 | $anchor = $urlGenerator->diffSummaryLink( |
87 | Title::newFromText( $this->event->getExtraParam( 'topic-workflow' )->getAlphadecimal(), NS_TOPIC ), |
88 | $this->event->getExtraParam( 'topic-workflow' ), |
89 | $this->event->getExtraParam( 'revision-id' ) |
90 | ); |
91 | |
92 | return [ |
93 | 'url' => $anchor->getFullURL(), |
94 | 'label' => $this->msg( 'notification-link-text-view-changes' )->params( $this->getViewingUserForGender() )->text(), |
95 | 'description' => '', |
96 | 'icon' => 'changes', |
97 | 'prioritized' => $prioritized, |
98 | ]; |
99 | } |
100 | } |