mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
8c810dff48
Also added "composer fix" command. Change-Id: I25cb61b3b92798f1259d1575a336e2b056d5764f
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
class EchoForeignPresentationModel extends EchoEventPresentationModel {
|
|
public function getIconType() {
|
|
return 'global';
|
|
}
|
|
|
|
public function getPrimaryLink() {
|
|
return false;
|
|
}
|
|
|
|
protected function getHeaderMessageKey() {
|
|
$data = $this->event->getExtra();
|
|
$section = $data['section'] == 'message' ? 'notice' : $data['section'];
|
|
|
|
// notification-header-foreign-alert
|
|
// notification-header-foreign-notice
|
|
return "notification-header-{$this->type}-{$section}";
|
|
}
|
|
|
|
public function getHeaderMessage() {
|
|
$msg = parent::getHeaderMessage();
|
|
|
|
$data = $this->event->getExtra();
|
|
$firstWiki = reset( $data['wikis'] );
|
|
$names = $this->getWikiNames( [ $firstWiki ] );
|
|
$msg->params( $names[0] );
|
|
$msg->numParams( count( $data['wikis'] ) - 1 );
|
|
$msg->numParams( count( $data['wikis'] ) );
|
|
|
|
return $msg;
|
|
}
|
|
|
|
public function getBodyMessage() {
|
|
$data = $this->event->getExtra();
|
|
$msg = wfMessage( "notification-body-{$this->type}" );
|
|
$msg->params( $this->language->listToText( $this->getWikiNames( $data['wikis'] ) ) );
|
|
return $msg;
|
|
}
|
|
|
|
protected function getWikiNames( array $wikis ) {
|
|
$data = EchoForeignNotifications::getApiEndpoints( $wikis );
|
|
$names = [];
|
|
foreach ( $wikis as $wiki ) {
|
|
$names[] = $data[$wiki]['title'];
|
|
}
|
|
return $names;
|
|
}
|
|
}
|