mediawiki-extensions-Echo/formatters/ArticleLinkedFormatter.php
Kaldari 05e186c7a3 Setting up flyout formatting as a separate formatting option
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
2013-01-08 09:53:31 -08:00

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;
}
}
}