mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-24 13:44:40 +00:00
05e186c7a3
This is replacing the implementation I did for 'html-light'. The reason html-light doesn't work is that we don't have any way of reliably determining which parameter should be the one that is linked to in the notification title (flyout notifications are only supposed to have one link). With this system, the notification definer can specify a separate message/params combination to use specifically for the notification flyout. If they don't specify these, it falls back to the normal title message/params. Change-Id: I35394849cf99307eba4a76e079333d19514fdb5d
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Formatter for 'article-linked' notifications
|
|
*/
|
|
class MWEchoArticleLinkedFormatter extends EchoEditFormatter {
|
|
|
|
/**
|
|
* @param $event EchoEvent
|
|
* @param $param string
|
|
* @param $message Message
|
|
* @param $user User
|
|
*/
|
|
protected function processParam( $event, $param, $message, $user ) {
|
|
$extra = $event->getExtra();
|
|
|
|
switch ( $param ) {
|
|
// title of the page that gets linked in other page
|
|
case 'title-linked':
|
|
if ( isset( $extra['notif-list'][$user->getID()] ) && $extra['notif-list'][$user->getID()] ) {
|
|
global $wgLang;
|
|
$list = array();
|
|
|
|
foreach ( $extra['notif-list'][$user->getID()] as $page ) {
|
|
$title = Title::makeTitle( $page['pl_namespace'], $page['pl_title'] );
|
|
if ( $this->outputFormat === 'html' ) {
|
|
$list[] = '[[' . $title->getPrefixedText() . ']]';
|
|
} else {
|
|
$list[] = $title->getPrefixedText();
|
|
}
|
|
}
|
|
$message->params( $wgLang->commaList( $list ) );
|
|
$message->params( count( $extra['notif-list'][$user->getID()] ) );
|
|
} else {
|
|
$message->params( '' );
|
|
}
|
|
break;
|
|
|
|
default:
|
|
parent::processParam( $event, $param, $message, $user );
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|