2015-10-28 07:23:38 +00:00
|
|
|
<?php
|
|
|
|
class EchoThanksPresentationModel extends EchoEventPresentationModel {
|
|
|
|
public function canRender() {
|
|
|
|
return (bool)$this->event->getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIconType() {
|
|
|
|
return 'thanks';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeaderMessage() {
|
2016-06-16 16:12:38 +00:00
|
|
|
if ( $this->isBundled() ) {
|
|
|
|
$msg = $this->msg( 'notification-bundle-header-edit-thank' );
|
|
|
|
$msg->params( $this->getBundleCount() );
|
|
|
|
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
$msg = $this->getMessageWithAgent( 'notification-header-edit-thank' );
|
|
|
|
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-29 10:42:53 +00:00
|
|
|
public function getCompactHeaderMessage() {
|
|
|
|
$msg = parent::getCompactHeaderMessage();
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
2016-06-16 16:12:38 +00:00
|
|
|
public function getBodyMessage() {
|
|
|
|
$comment = $this->getEditComment();
|
|
|
|
if ( $comment ) {
|
|
|
|
$msg = new RawMessage( '$1' );
|
|
|
|
$msg->plaintextParams( $comment );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getRevisionEditSummary() {
|
|
|
|
if ( !$this->userCan( Revision::DELETED_COMMENT ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revId = $this->event->getExtraParam( 'revid', false );
|
|
|
|
if ( !$revId ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revision = Revision::newFromId( $revId );
|
|
|
|
if ( !$revision ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$summary = $revision->getComment( Revision::RAW );
|
|
|
|
return $summary ?: false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getEditComment() {
|
|
|
|
// try to get edit summary
|
|
|
|
$summary = $this->getRevisionEditSummary();
|
|
|
|
if ( $summary ) {
|
|
|
|
return $summary;
|
|
|
|
}
|
|
|
|
|
|
|
|
// fallback on edit excerpt
|
|
|
|
if ( $this->userCan( Revision::DELETED_TEXT ) ) {
|
|
|
|
return $this->event->getExtraParam( 'excerpt', false );
|
|
|
|
}
|
2015-10-28 07:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPrimaryLink() {
|
2016-04-22 20:13:56 +00:00
|
|
|
return [
|
|
|
|
'url' => $this->event->getTitle()->getLocalURL( [
|
2015-10-28 07:23:38 +00:00
|
|
|
'oldid' => 'prev',
|
|
|
|
'diff' => $this->event->getExtraParam( 'revid' )
|
2016-04-22 20:13:56 +00:00
|
|
|
] ),
|
2016-01-12 21:45:42 +00:00
|
|
|
'label' => $this->msg( 'notification-link-text-view-edit' )->text(),
|
2016-04-22 20:13:56 +00:00
|
|
|
];
|
2015-10-28 07:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSecondaryLinks() {
|
2016-06-16 16:12:38 +00:00
|
|
|
$pageLink = $this->getPageLink( $this->event->getTitle(), null, true );
|
|
|
|
if ( $this->isBundled() ) {
|
|
|
|
return [ $pageLink ];
|
|
|
|
} else {
|
|
|
|
return [ $this->getAgentLink(), $pageLink ];
|
|
|
|
}
|
2015-10-28 07:23:38 +00:00
|
|
|
}
|
|
|
|
}
|