Debian Codegraph @

extensions/Echo/includes/Formatters/EchoForeignPresentationModel.php

raw symbols SCIP
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 /**
47 * @param string[] $wikis
48 * @return string[]
49 */
50 protected function getWikiNames( array $wikis ): array {
51 $data = ForeignNotifications::getApiEndpoints( $wikis );
52 $names = [];
53 foreach ( $wikis as $wiki ) {
54 $names[] = $data[$wiki]['title'];
55 }
56 return $names;
57 }
58 }