2012-04-27 15:14:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EchoEditFormatter extends EchoBasicFormatter {
|
2012-09-26 05:09:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param EchoEvent $event
|
|
|
|
* @param $param
|
|
|
|
* @param $message Message
|
|
|
|
* @param $user User
|
|
|
|
*/
|
2012-10-23 21:57:22 +00:00
|
|
|
protected function processParam( $event, $param, $message, $user ) {
|
2013-05-14 22:22:52 +00:00
|
|
|
if ( $param === 'subject-anchor' ) {
|
|
|
|
$message->params( $this->formatSubjectAnchor( $event ) );
|
2013-07-24 03:50:43 +00:00
|
|
|
} elseif ( $param === 'section-title' ) {
|
|
|
|
$message->params( $this->getSectionTitle( $event, $user ) );
|
2013-05-14 22:22:52 +00:00
|
|
|
} elseif ( $param === 'difflink' ) {
|
2013-05-08 18:11:44 +00:00
|
|
|
$revid = $event->getExtraParam( 'revid' );
|
|
|
|
if ( !$revid ) {
|
2012-08-30 16:04:39 +00:00
|
|
|
$message->params( '' );
|
2012-04-27 15:14:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-11-19 18:44:01 +00:00
|
|
|
$diff = $event->getExtraParam( 'diffid', 'prev' );
|
2012-12-18 01:50:00 +00:00
|
|
|
$props = array(
|
2013-06-24 00:22:08 +00:00
|
|
|
'attribs' => array( 'class' => 'mw-echo-diff' ),
|
2013-08-27 00:55:45 +00:00
|
|
|
'linkText' => $this->getMessage( 'parentheses' )
|
|
|
|
->params(
|
|
|
|
$this->getMessage( 'showdiff' )->text()
|
|
|
|
)->escaped(),
|
2012-12-18 01:50:00 +00:00
|
|
|
'param' => array(
|
2013-05-08 18:11:44 +00:00
|
|
|
'oldid' => $revid,
|
2013-11-19 18:44:01 +00:00
|
|
|
'diff' => $diff,
|
2013-07-02 21:20:01 +00:00
|
|
|
),
|
|
|
|
// Set fragment to empty string for diff links
|
|
|
|
'fragment' => ''
|
2012-12-18 01:50:00 +00:00
|
|
|
);
|
2012-10-28 16:47:41 +00:00
|
|
|
$this->setTitleLink( $event, $message, $props );
|
2012-07-18 19:39:33 +00:00
|
|
|
} elseif ( $param === 'summary' ) {
|
2013-07-24 03:50:43 +00:00
|
|
|
$message->params( $this->getRevisionSnippet( $event, $user ) );
|
2012-07-18 19:39:33 +00:00
|
|
|
} 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 );
|
|
|
|
}
|
2012-05-17 15:36:18 +00:00
|
|
|
} else {
|
|
|
|
parent::processParam( $event, $param, $message, $user );
|
2012-04-27 15:14:24 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-24 03:50:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the section title for a talk page post
|
|
|
|
* @param $event EchoEvent
|
|
|
|
* @param $user User
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getSectionTitle( $event, $user ) {
|
|
|
|
$extra = $event->getExtra();
|
|
|
|
|
|
|
|
if ( !empty( $extra['section-title'] ) ) {
|
|
|
|
if ( $event->userCan( Revision::DELETED_TEXT, $user ) ) {
|
2015-09-02 18:09:11 +00:00
|
|
|
return EchoDiscussionParser::getTextSnippet(
|
|
|
|
$extra['section-title'],
|
|
|
|
$this->getLanguage(),
|
|
|
|
30
|
|
|
|
);
|
2013-11-20 21:52:14 +00:00
|
|
|
} else {
|
|
|
|
return $this->getMessage( 'echo-rev-deleted-text-view' )->text();
|
2013-07-24 03:50:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
2012-07-26 17:23:18 +00:00
|
|
|
}
|