mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 09:26:05 +00:00
335fc1fab0
Specifying the class directly is much less confusing and fragile. Plus we have way too many things named 'type'. Also changing MWEchoArticleLinkedFormatter to EchoArticleLinkedFormatter to match the convention of the other formatter classes. Also making EchoBasicFormatter the default, so that the Hello World case is easier to implement. Change-Id: Ibd9b15008d37ad815e466ab81ba9a5b668ee2791
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Formatter for 'article-linked' notifications
|
|
*/
|
|
class EchoArticleLinkedFormatter 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;
|
|
}
|
|
}
|
|
|
|
}
|