1 | <?php |
||
16 | class ChangeNotificationPresentationModel extends EchoEventPresentationModel { |
||
17 | |||
18 | /** |
||
19 | * @see EchoEventPresentationModel::getIconType |
||
20 | */ |
||
21 | 4 | public function getIconType() { |
|
36 | |||
37 | /** |
||
38 | * @see EchoEventPresentationModel::canRender |
||
39 | */ |
||
40 | 1 | public function canRender() { |
|
43 | |||
44 | /** |
||
45 | * @param EchoEvent |
||
46 | * @return string |
||
47 | */ |
||
48 | 2 | public function callbackForBundleCount( EchoEvent $event ) { |
|
51 | |||
52 | /** |
||
53 | * @see EchoEventPresentationModel::getHeaderMessageKey |
||
54 | */ |
||
55 | 2 | public function getHeaderMessageKey() { |
|
63 | |||
64 | /** |
||
65 | * @see EchoEventPresentationModel::getHeaderMessage |
||
66 | */ |
||
67 | 1 | public function getHeaderMessage() { |
|
68 | |||
69 | 1 | $extra = $this->event->getExtra(); |
|
70 | 1 | $msg = parent::getHeaderMessage(); |
|
71 | |||
72 | 1 | $msg->params( |
|
73 | 1 | $this->getTruncatedTitleText( $this->event->getTitle(), true ) |
|
74 | ); |
||
75 | |||
76 | // Plural indicator |
||
77 | 1 | $msg->params( |
|
78 | 1 | ( isset( $extra['properties'] ) ? count( $extra['properties'] ) : 0 ) |
|
79 | ); |
||
80 | |||
81 | 1 | $count = $this->getNotificationCountForOutput( |
|
82 | 1 | false, // we need only other pages count |
|
83 | 1 | [ $this, 'callbackForBundleCount' ] |
|
84 | ); |
||
85 | |||
86 | 1 | if ( $count > 0 ) { |
|
87 | $msg->numParams( $count ); |
||
88 | } |
||
89 | |||
90 | 1 | return $msg; |
|
91 | } |
||
92 | |||
93 | /** |
||
94 | * @see EchoEventPresentationModel::getBodyMessage |
||
95 | */ |
||
96 | 5 | public function getBodyMessage() { |
|
97 | |||
98 | 5 | $extra = $this->event->getExtra(); |
|
99 | 5 | $labels = array(); |
|
100 | |||
101 | 5 | if ( !isset( $extra['properties'] ) || $extra['properties'] === array() ) { |
|
102 | 3 | return false; |
|
103 | } |
||
104 | |||
105 | 2 | foreach ( $extra['properties'] as $dataItem ) { |
|
106 | |||
107 | 2 | $prefix = ''; |
|
108 | |||
109 | 2 | if ( $dataItem->getDBKey() === '' ) { |
|
110 | 1 | continue; |
|
111 | } |
||
112 | |||
113 | 2 | if ( $dataItem->getNamespace() === NS_CATEGORY ) { |
|
114 | $prefix = $this->language->getNsText( NS_CATEGORY ) . ':'; |
||
115 | } |
||
116 | |||
117 | try { |
||
118 | 2 | $labels[] = $prefix . DIProperty::newFromUserLabel( $dataItem->getDBKey() )->getLabel(); |
|
119 | } catch ( \SMW\Exception\PredefinedPropertyLabelMismatchException $e ) { |
||
120 | continue; |
||
121 | } |
||
122 | } |
||
123 | |||
124 | 2 | $msg = wfMessage( "notification-body-{$this->type}" ); |
|
125 | 2 | $msg->params( $this->language->listToText( $labels ) ); |
|
126 | 2 | $msg->params( count( $labels ) ); |
|
127 | |||
128 | 2 | return $msg; |
|
129 | } |
||
130 | |||
131 | /** |
||
132 | * @see EchoEventPresentationModel::getPrimaryLink |
||
133 | */ |
||
134 | 3 | public function getPrimaryLink() { |
|
135 | 3 | $title = $this->event->getTitle(); |
|
136 | return array( |
||
137 | 3 | 'url' => $title->getFullURL(), |
|
138 | 3 | 'label' => $title->getFullText() |
|
139 | ); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @see EchoEventPresentationModel::getSecondaryLinks |
||
144 | */ |
||
145 | 3 | public function getSecondaryLinks() { |
|
166 | |||
167 | } |
||
168 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.