2015-11-25 04:07:54 +00:00
|
|
|
<?php
|
|
|
|
|
2022-11-01 22:01:23 +00:00
|
|
|
namespace MediaWiki\Extension\Notifications\Formatters;
|
|
|
|
|
2022-11-13 07:53:42 +00:00
|
|
|
use MediaWiki\Extension\Notifications\ForeignNotifications;
|
2022-11-01 22:01:23 +00:00
|
|
|
|
2015-11-25 04:07:54 +00:00
|
|
|
class EchoForeignPresentationModel extends EchoEventPresentationModel {
|
|
|
|
public function getIconType() {
|
2016-01-15 22:19:01 +00:00
|
|
|
return 'global';
|
2015-11-25 04:07:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPrimaryLink() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getHeaderMessageKey() {
|
|
|
|
$data = $this->event->getExtra();
|
2016-07-07 22:05:56 +00:00
|
|
|
$section = $data['section'] == 'message' ? 'notice' : $data['section'];
|
2015-11-25 04:07:54 +00:00
|
|
|
|
2016-07-07 22:05:56 +00:00
|
|
|
// notification-header-foreign-alert
|
|
|
|
// notification-header-foreign-notice
|
2019-04-10 01:00:53 +00:00
|
|
|
// notification-header-foreign-all
|
2019-04-06 00:33:28 +00:00
|
|
|
return "notification-header-foreign-{$section}";
|
2015-11-25 04:07:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeaderMessage() {
|
|
|
|
$msg = parent::getHeaderMessage();
|
|
|
|
|
|
|
|
$data = $this->event->getExtra();
|
2016-03-01 07:11:09 +00:00
|
|
|
$firstWiki = reset( $data['wikis'] );
|
2016-12-05 18:51:07 +00:00
|
|
|
$names = $this->getWikiNames( [ $firstWiki ] );
|
2016-03-01 07:11:09 +00:00
|
|
|
$msg->params( $names[0] );
|
2015-11-25 04:07:54 +00:00
|
|
|
$msg->numParams( count( $data['wikis'] ) - 1 );
|
2016-03-01 07:11:09 +00:00
|
|
|
$msg->numParams( count( $data['wikis'] ) );
|
2015-11-25 04:07:54 +00:00
|
|
|
|
|
|
|
return $msg;
|
|
|
|
}
|
2016-01-26 08:23:32 +00:00
|
|
|
|
2016-03-01 07:11:09 +00:00
|
|
|
public function getBodyMessage() {
|
|
|
|
$data = $this->event->getExtra();
|
2021-08-19 22:31:10 +00:00
|
|
|
$msg = $this->msg( 'notification-body-foreign' );
|
2016-03-01 07:11:09 +00:00
|
|
|
$msg->params( $this->language->listToText( $this->getWikiNames( $data['wikis'] ) ) );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
2024-03-15 08:27:36 +00:00
|
|
|
/**
|
|
|
|
* @param string[] $wikis
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
protected function getWikiNames( array $wikis ): array {
|
2022-11-13 07:53:42 +00:00
|
|
|
$data = ForeignNotifications::getApiEndpoints( $wikis );
|
2016-12-05 18:51:07 +00:00
|
|
|
$names = [];
|
2016-03-01 07:11:09 +00:00
|
|
|
foreach ( $wikis as $wiki ) {
|
|
|
|
$names[] = $data[$wiki]['title'];
|
|
|
|
}
|
|
|
|
return $names;
|
2016-01-26 08:23:32 +00:00
|
|
|
}
|
2015-11-25 04:07:54 +00:00
|
|
|
}
|