Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 48 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
PostReplyPresentationModel | |
0.00% |
0 / 48 |
|
0.00% |
0 / 8 |
420 | |
0.00% |
0 / 1 |
getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
canRender | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getPrimaryLink | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
12 | |||
getSecondaryLinks | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
getHeaderMessageKey | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
getHeaderMessage | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
getCompactHeaderMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getBodyMessage | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace Flow\Notifications; |
4 | |
5 | use Flow\Container; |
6 | |
7 | class PostReplyPresentationModel extends FlowPresentationModel { |
8 | |
9 | /** @inheritDoc */ |
10 | public function getIconType() { |
11 | return $this->isUserTalkPage() ? 'edit-user-talk' : 'chat'; |
12 | } |
13 | |
14 | /** @inheritDoc */ |
15 | public function canRender() { |
16 | return $this->hasTitle() |
17 | && $this->hasValidTopicWorkflowId() |
18 | && $this->hasValidPostId(); |
19 | } |
20 | |
21 | /** @inheritDoc */ |
22 | public function getPrimaryLink() { |
23 | $topmostPostID = null; |
24 | |
25 | if ( $this->isBundled() ) { |
26 | // "Strict standards: Only variables should be passed by reference" in older PHP versions |
27 | $bundledEvents = $this->getBundledEvents(); |
28 | |
29 | /** @var Controller $notificationController */ |
30 | $notificationController = Container::get( 'controller.notification' ); |
31 | $firstChronologicallyEvent = end( $bundledEvents ); |
32 | $firstChronologicallyPostId = $firstChronologicallyEvent->getExtraParam( 'post-id' ); |
33 | $bundledEventsIncludingThis = array_merge( [ $this->event ], $bundledEvents ); |
34 | $topmostPostID = $notificationController->getTopmostPostId( $bundledEventsIncludingThis ) ?: |
35 | $firstChronologicallyPostId; |
36 | |
37 | } else { |
38 | $event = $this->event; |
39 | $firstChronologicallyPostId = $event->getExtraParam( 'post-id' ); |
40 | } |
41 | return [ |
42 | 'url' => $this->getPostLinkUrl( $firstChronologicallyPostId, $topmostPostID ), |
43 | 'label' => $this->msg( 'flow-notification-link-text-view-post' )->text(), |
44 | ]; |
45 | } |
46 | |
47 | /** @inheritDoc */ |
48 | public function getSecondaryLinks() { |
49 | if ( $this->isBundled() ) { |
50 | $links = [ $this->getBoardLink() ]; |
51 | } else { |
52 | $links = [ $this->getAgentLink(), $this->getBoardLink() ]; |
53 | } |
54 | |
55 | $links[] = $this->getFlowUnwatchDynamicActionLink( true ); |
56 | |
57 | return $links; |
58 | } |
59 | |
60 | /** @inheritDoc */ |
61 | protected function getHeaderMessageKey() { |
62 | if ( $this->isBundled() ) { |
63 | if ( $this->isUserTalkPage() ) { |
64 | return 'notification-bundle-header-flow-post-reply-user-talk'; |
65 | } else { |
66 | return 'notification-bundle-header-flow-post-reply-v2'; |
67 | } |
68 | } else { |
69 | if ( $this->isUserTalkPage() ) { |
70 | return 'notification-header-flow-post-reply-user-talk'; |
71 | } else { |
72 | return 'notification-header-flow-post-reply'; |
73 | } |
74 | } |
75 | } |
76 | |
77 | /** @inheritDoc */ |
78 | public function getHeaderMessage() { |
79 | if ( $this->isBundled() ) { |
80 | $count = $this->getNotificationCountForOutput(); |
81 | $msg = $this->msg( $this->getHeaderMessageKey() ); |
82 | |
83 | // Repeat is B/C until unused parameter is removed from translations |
84 | $msg->numParams( $count, $count ); |
85 | } else { |
86 | $msg = parent::getHeaderMessage(); |
87 | $msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) ); |
88 | } |
89 | $msg->plaintextParams( $this->getTopicTitle() ); |
90 | return $msg; |
91 | } |
92 | |
93 | /** @inheritDoc */ |
94 | public function getCompactHeaderMessage() { |
95 | $msg = $this->getMessageWithAgent( 'notification-compact-header-flow-post-reply' ); |
96 | $msg->plaintextParams( $this->getContentSnippet() ); |
97 | return $msg; |
98 | } |
99 | |
100 | /** @inheritDoc */ |
101 | public function getBodyMessage() { |
102 | if ( !$this->isBundled() ) { |
103 | if ( $this->isUserTalkPage() ) { |
104 | $msg = $this->msg( "notification-body-flow-post-reply-user-talk" ); |
105 | } else { |
106 | $msg = $this->msg( "notification-body-flow-post-reply-v2" ); |
107 | } |
108 | $msg->plaintextParams( $this->getContentSnippet() ); |
109 | return $msg; |
110 | } |
111 | } |
112 | |
113 | } |