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