2015-11-17 13:37:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EchoEditUserTalkPresentationModel extends EchoEventPresentationModel {
|
2016-04-22 02:33:35 +00:00
|
|
|
use EchoPresentationModelSectionTrait;
|
2016-04-22 01:31:12 +00:00
|
|
|
|
2015-11-17 13:37:39 +00:00
|
|
|
public function canRender() {
|
|
|
|
return (bool)$this->event->getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIconType() {
|
2016-01-13 04:24:11 +00:00
|
|
|
return 'edit-user-talk';
|
2015-11-17 13:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPrimaryLink() {
|
2016-12-05 18:51:07 +00:00
|
|
|
return [
|
2016-04-22 01:31:12 +00:00
|
|
|
// Need FullURL so the section is included
|
2016-04-22 02:33:35 +00:00
|
|
|
'url' => $this->getTitleWithSection()->getFullURL(),
|
2015-11-17 13:37:39 +00:00
|
|
|
'label' => $this->msg( 'notification-link-text-view-message' )->text()
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2015-11-17 13:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSecondaryLinks() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$diffLink = [
|
2015-11-17 13:37:39 +00:00
|
|
|
'url' => $this->getDiffLinkUrl(),
|
2016-02-23 16:55:07 +00:00
|
|
|
'label' => $this->msg( 'notification-link-text-view-changes', $this->getViewingUserForGender() )->text(),
|
2015-12-16 16:52:02 +00:00
|
|
|
'description' => '',
|
2016-01-15 06:34:04 +00:00
|
|
|
'icon' => 'changes',
|
2015-11-17 13:37:39 +00:00
|
|
|
'prioritized' => true
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2016-01-14 19:33:21 +00:00
|
|
|
|
|
|
|
if ( $this->isBundled() ) {
|
2016-12-05 18:51:07 +00:00
|
|
|
return [ $diffLink ];
|
2016-01-14 19:33:21 +00:00
|
|
|
} else {
|
2016-12-05 18:51:07 +00:00
|
|
|
return [ $this->getAgentLink(), $diffLink ];
|
2016-01-14 19:33:21 +00:00
|
|
|
}
|
2015-11-17 13:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeaderMessage() {
|
2016-01-14 19:33:21 +00:00
|
|
|
if ( $this->isBundled() ) {
|
|
|
|
$msg = $this->msg( "notification-bundle-header-{$this->type}-v2" );
|
2016-03-09 04:50:31 +00:00
|
|
|
$count = $this->getNotificationCountForOutput();
|
|
|
|
|
|
|
|
// Repeat is B/C until unused parameter is removed from translations
|
|
|
|
$msg->numParams( $count, $count );
|
2016-01-14 19:33:21 +00:00
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
2015-11-17 13:37:39 +00:00
|
|
|
return $msg;
|
|
|
|
} elseif ( $this->hasSection() ) {
|
|
|
|
$msg = $this->getMessageWithAgent( "notification-header-{$this->type}-with-section" );
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
2016-09-27 23:04:44 +00:00
|
|
|
$msg->plaintextParams( $this->getTruncatedSectionTitle() );
|
2015-11-17 13:37:39 +00:00
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
$msg = parent::getHeaderMessage();
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBodyMessage() {
|
2016-05-13 23:37:34 +00:00
|
|
|
$sectionText = $this->event->getExtraParam( 'section-text' );
|
|
|
|
if ( !$this->isBundled() && $this->hasSection() && $sectionText !== null ) {
|
2015-11-17 13:37:39 +00:00
|
|
|
$msg = $this->msg( 'notification-body-edit-user-talk-with-section' );
|
2016-04-22 01:31:12 +00:00
|
|
|
// section-text is safe to use here, because hasSection() returns false if the revision is deleted
|
2016-05-13 23:37:34 +00:00
|
|
|
$msg->plaintextParams( $sectionText );
|
2015-11-17 13:37:39 +00:00
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getDiffLinkUrl() {
|
|
|
|
$revId = $this->event->getExtraParam( 'revid' );
|
|
|
|
$oldId = $this->isBundled() ? $this->getRevBeforeFirstNotification() : 'prev';
|
2016-12-05 18:51:07 +00:00
|
|
|
$query = [
|
2015-11-17 13:37:39 +00:00
|
|
|
'oldid' => $oldId,
|
|
|
|
'diff' => $revId,
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2015-11-17 13:37:39 +00:00
|
|
|
return $this->event->getTitle()->getFullURL( $query );
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getRevBeforeFirstNotification() {
|
2016-01-14 19:58:21 +00:00
|
|
|
$events = $this->getBundledEvents();
|
|
|
|
$firstNotificationRevId = end( $events )->getExtraParam( 'revid' );
|
2015-11-17 13:37:39 +00:00
|
|
|
return $this->event->getTitle()->getPreviousRevisionID( $firstNotificationRevId );
|
|
|
|
}
|
2016-05-05 13:05:03 +00:00
|
|
|
|
|
|
|
protected function getSubjectMessageKey() {
|
|
|
|
return 'notification-edit-talk-page-email-subject2';
|
|
|
|
}
|
2015-11-17 13:37:39 +00:00
|
|
|
}
|