Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
EchoForeignPresentationModel | |
0.00% |
0 / 22 |
|
0.00% |
0 / 6 |
72 | |
0.00% |
0 / 1 |
getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPrimaryLink | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeaderMessageKey | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getHeaderMessage | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
getBodyMessage | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getWikiNames | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Notifications\Formatters; |
4 | |
5 | use MediaWiki\Extension\Notifications\ForeignNotifications; |
6 | |
7 | class EchoForeignPresentationModel extends EchoEventPresentationModel { |
8 | public function getIconType() { |
9 | return 'global'; |
10 | } |
11 | |
12 | public function getPrimaryLink() { |
13 | return false; |
14 | } |
15 | |
16 | protected function getHeaderMessageKey() { |
17 | $data = $this->event->getExtra(); |
18 | $section = $data['section'] == 'message' ? 'notice' : $data['section']; |
19 | |
20 | // notification-header-foreign-alert |
21 | // notification-header-foreign-notice |
22 | // notification-header-foreign-all |
23 | return "notification-header-foreign-{$section}"; |
24 | } |
25 | |
26 | public function getHeaderMessage() { |
27 | $msg = parent::getHeaderMessage(); |
28 | |
29 | $data = $this->event->getExtra(); |
30 | $firstWiki = reset( $data['wikis'] ); |
31 | $names = $this->getWikiNames( [ $firstWiki ] ); |
32 | $msg->params( $names[0] ); |
33 | $msg->numParams( count( $data['wikis'] ) - 1 ); |
34 | $msg->numParams( count( $data['wikis'] ) ); |
35 | |
36 | return $msg; |
37 | } |
38 | |
39 | public function getBodyMessage() { |
40 | $data = $this->event->getExtra(); |
41 | $msg = $this->msg( 'notification-body-foreign' ); |
42 | $msg->params( $this->language->listToText( $this->getWikiNames( $data['wikis'] ) ) ); |
43 | return $msg; |
44 | } |
45 | |
46 | protected function getWikiNames( array $wikis ) { |
47 | $data = ForeignNotifications::getApiEndpoints( $wikis ); |
48 | $names = []; |
49 | foreach ( $wikis as $wiki ) { |
50 | $names[] = $data[$wiki]['title']; |
51 | } |
52 | return $names; |
53 | } |
54 | } |