2012-07-27 22:16:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EchoCommentFormatter extends EchoEditFormatter {
|
2012-07-31 00:29:49 +00:00
|
|
|
public function __construct( $params ) {
|
|
|
|
parent::__construct( $params );
|
|
|
|
|
|
|
|
if ( isset( $params['title-message-yours'] ) ) {
|
|
|
|
$this->title['message-yours'] = $params['title-message-yours'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isset( $params['content-message-yours'] ) ) {
|
|
|
|
$this->content['message-yours'] = $params['content-message-yours'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isset( $params['email-subject-message-yours'] ) ) {
|
|
|
|
$this->email['subject']['message-yours'] = $params['email-subject-message-yours'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isset( $params['email-body-message-yours'] ) ) {
|
|
|
|
$this->email['body']['message-yours'] = $params['email-body-message-yours'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-14 21:52:17 +00:00
|
|
|
/**
|
|
|
|
* @param $details
|
|
|
|
* @param $event EchoEvent
|
|
|
|
* @param $user User
|
|
|
|
* @return Message
|
|
|
|
*/
|
2012-10-23 21:57:22 +00:00
|
|
|
protected function formatFragment( $details, $event, $user ) {
|
2012-07-31 00:29:49 +00:00
|
|
|
$userTalkPage = $user->getUserPage()->getTalkPage();
|
|
|
|
|
2012-11-14 21:52:17 +00:00
|
|
|
$title = $event->getTitle();
|
|
|
|
if ( $title && $title->equals( $userTalkPage ) &&
|
2012-07-31 00:29:49 +00:00
|
|
|
isset( $details['message-yours'] )
|
|
|
|
) {
|
|
|
|
$details['message'] = $details['message-yours'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::formatFragment( $details, $event, $user );
|
|
|
|
}
|
|
|
|
|
2012-09-26 05:09:43 +00:00
|
|
|
/**
|
|
|
|
* @param EchoEvent $event
|
|
|
|
* @param $param
|
|
|
|
* @param Message $message
|
|
|
|
* @param User $user
|
|
|
|
*/
|
2012-07-27 22:16:19 +00:00
|
|
|
protected function processParam( $event, $param, $message, $user ) {
|
|
|
|
$extra = $event->getExtra();
|
|
|
|
if ( $param === 'subject' ) {
|
|
|
|
if ( isset( $extra['section-title'] ) && $extra['section-title'] ) {
|
|
|
|
$message->params( $extra['section-title'] );
|
|
|
|
} else {
|
|
|
|
$message->params( '' );
|
|
|
|
}
|
|
|
|
} elseif ( $param === 'commentText' ) {
|
|
|
|
if ( isset( $extra['content'] ) && $extra['content'] ) {
|
|
|
|
$content = $extra['content'];
|
|
|
|
$content = EchoDiscussionParser::stripHeader( $content );
|
2012-07-31 00:29:49 +00:00
|
|
|
$content = EchoDiscussionParser::stripSignature( $content );
|
|
|
|
$content = EchoDiscussionParser::stripIndents( $content );
|
2012-11-07 01:41:06 +00:00
|
|
|
$content = EchoDiscussionParser::getTextSnippet( $content, 200 );
|
2012-07-27 22:16:19 +00:00
|
|
|
|
|
|
|
$message->params( $content );
|
|
|
|
} else {
|
|
|
|
$message->params( '' );
|
|
|
|
}
|
2012-08-01 21:23:37 +00:00
|
|
|
} elseif ( $param === 'content-page' ) {
|
|
|
|
if ( $event->getTitle() ) {
|
|
|
|
$message->params( $event->getTitle()->getSubjectPage()->getPrefixedText() );
|
|
|
|
} else {
|
|
|
|
$message->params( '' );
|
|
|
|
}
|
2012-10-28 16:47:41 +00:00
|
|
|
} elseif ( $param === 'subject-link' ) {
|
|
|
|
$prop = array();
|
|
|
|
if ( isset( $extra['section-title'] ) && $extra['section-title'] ) {
|
|
|
|
$prop['fragment'] = $extra['section-title'];
|
|
|
|
}
|
|
|
|
$this->setTitleLink( $event, $message, $prop );
|
2012-07-27 22:16:19 +00:00
|
|
|
} else {
|
|
|
|
parent::processParam( $event, $param, $message, $user );
|
|
|
|
}
|
|
|
|
}
|
2012-08-30 16:04:39 +00:00
|
|
|
}
|