2015-11-17 15:10:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EchoRevertedPresentationModel extends EchoEventPresentationModel {
|
|
|
|
|
|
|
|
public function getIconType() {
|
|
|
|
return 'revert';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canRender() {
|
|
|
|
return (bool)$this->event->getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeaderMessage() {
|
|
|
|
$msg = parent::getHeaderMessage();
|
2016-01-20 21:19:54 +00:00
|
|
|
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
|
2015-11-17 15:10:33 +00:00
|
|
|
$msg->params( $this->getNumberOfEdits() );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
2016-01-14 19:58:21 +00:00
|
|
|
public function getBodyMessage() {
|
|
|
|
$summary = $this->event->getExtraParam( 'summary' );
|
|
|
|
if ( !$this->isAutomaticSummary( $summary ) && $this->userCan( Revision::DELETED_COMMENT ) ) {
|
|
|
|
$msg = $this->msg( "notification-body-{$this->type}" );
|
|
|
|
$msg->params( $this->formatSummary( $summary ) );
|
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function formatSummary( $wikitext ) {
|
2016-03-30 02:16:31 +00:00
|
|
|
return EchoDiscussionParser::getTextSnippetFromSummary( $wikitext, $this->language );
|
2016-01-14 19:58:21 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 15:10:33 +00:00
|
|
|
public function getPrimaryLink() {
|
|
|
|
$url = $this->event->getTitle()->getLocalURL( array(
|
|
|
|
'oldid' => 'prev',
|
|
|
|
'diff' => $this->event->getExtraParam( 'revid' )
|
|
|
|
) );
|
|
|
|
return array(
|
2015-12-16 16:52:02 +00:00
|
|
|
'url' => $url,
|
2016-02-23 16:55:07 +00:00
|
|
|
'label' => $this->msg( 'notification-link-text-view-changes', $this->getViewingUserForGender() )->text()
|
2015-11-17 15:10:33 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-12-22 15:57:13 +00:00
|
|
|
public function getSecondaryLinks() {
|
2016-02-17 17:27:49 +00:00
|
|
|
$revertedTitleLink = $this->getPageLink(
|
|
|
|
$this->event->getTitle()->getTalkPage(), null, true
|
|
|
|
);
|
|
|
|
|
|
|
|
return array( $this->getAgentLink(), $revertedTitleLink );
|
2015-12-22 15:57:13 +00:00
|
|
|
}
|
2015-11-17 15:10:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a number that represents if one or multiple edits
|
|
|
|
* have been reverted for formatting purposes.
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
private function getNumberOfEdits() {
|
|
|
|
$method = $this->event->getExtraParam( 'method' );
|
|
|
|
if ( $method && $method === 'rollback' ) {
|
|
|
|
return 2;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-01-14 19:58:21 +00:00
|
|
|
|
|
|
|
private function isAutomaticSummary( $summary ) {
|
|
|
|
$autoSummaryMsg = wfMessage( 'undo-summary' )->inContentLanguage();
|
|
|
|
$autoSummaryMsg->params( $this->event->getExtraParam( 'reverted-revision-id' ) );
|
|
|
|
$autoSummaryMsg->params( $this->getViewingUserForGender() );
|
|
|
|
$autoSummary = $autoSummaryMsg->text();
|
|
|
|
|
|
|
|
return $summary === $autoSummary;
|
|
|
|
}
|
2015-11-17 15:10:33 +00:00
|
|
|
}
|