mediawiki-extensions-Echo/formatters/EditFormatter.php
bsitu 2c74f66f18 Add HTML email support to Echo notification
To test the HTML email:

1. install the latest version of php-mail and php-mail-mime package, they are required
   by the core sendmail function to send HTML email
2. set $wgAllowHTMLEmail = true before loading Echo in LocalSetting.php

Change-Id: Ia4b98b14e135742b84f1b0e04589b0efdd24e954
2013-07-23 13:20:33 +02:00

50 lines
1.6 KiB
PHP

<?php
class EchoEditFormatter extends EchoBasicFormatter {
/**
* @param EchoEvent $event
* @param $param
* @param $message Message
* @param $user User
*/
protected function processParam( $event, $param, $message, $user ) {
if ( $param === 'subject-anchor' ) {
$message->params( $this->formatSubjectAnchor( $event ) );
} elseif ( $param === 'difflink' ) {
$revid = $event->getExtraParam( 'revid' );
if ( !$revid ) {
$message->params( '' );
return;
}
$props = array(
'attribs' => array( 'class' => 'mw-echo-diff' ),
'linkText' => wfMessage( 'parentheses', wfMessage( 'showdiff' )->text() )->escaped(),
'param' => array(
'oldid' => $revid,
'diff' => 'prev',
),
// Set fragment to empty string for diff links
'fragment' => ''
);
$this->setTitleLink( $event, $message, $props );
} elseif ( $param === 'summary' ) {
$message->params( $this->formatRevisionComment( $event, $user ) );
} elseif ( $param === 'number' ) {
$eventData = $event->getExtra();
// The folliwing is a bit of a hack...
// If the edit is a rollback, we want to say 'your edits' in the
// notification. If the edit is an undo, we want to say 'your edit'
// in the notification. To accomplish this, we pass a 'number' param
// to the message which is set to 1 or 2 and formatted with {{PLURAL}}.
if ( isset( $eventData['method'] ) && $eventData['method'] === 'rollback' ) {
$message->params( 2 );
} else {
$message->params( 1 );
}
} else {
parent::processParam( $event, $param, $message, $user );
}
}
}