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