2015-11-17 13:37:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EchoEditUserTalkPresentationModel extends EchoEventPresentationModel {
|
2019-04-05 20:50:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var EchoPresentationModelSection
|
|
|
|
*/
|
|
|
|
private $section;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
protected function __construct( EchoEvent $event, Language $language, User $user, $distributionType ) {
|
|
|
|
parent::__construct( $event, $language, $user, $distributionType );
|
|
|
|
$this->section = new EchoPresentationModelSection( $event, $user, $language );
|
|
|
|
}
|
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
|
2019-04-05 20:50:03 +00:00
|
|
|
'url' => $this->section->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;
|
2019-04-05 20:50:03 +00:00
|
|
|
} elseif ( $this->section->exists() ) {
|
2015-11-17 13:37:39 +00:00
|
|
|
$msg = $this->getMessageWithAgent( "notification-header-{$this->type}-with-section" );
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
2019-04-05 20:50:03 +00:00
|
|
|
$msg->plaintextParams( $this->section->getTruncatedSectionTitle() );
|
2015-11-17 13:37:39 +00:00
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
$msg = parent::getHeaderMessage();
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-20 09:26:24 +00:00
|
|
|
public function getCompactHeaderMessage() {
|
2019-04-05 20:50:03 +00:00
|
|
|
$hasSection = $this->section->exists();
|
2017-10-20 09:26:24 +00:00
|
|
|
$key = $hasSection
|
|
|
|
? "notification-compact-header-{$this->type}-with-section"
|
|
|
|
: "notification-compact-header-{$this->type}";
|
|
|
|
$msg = $this->getMessageWithAgent( $key );
|
|
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
|
|
if ( $hasSection ) {
|
2019-04-05 20:50:03 +00:00
|
|
|
$msg->params( $this->section->getTruncatedSectionTitle() );
|
2017-10-20 09:26:24 +00:00
|
|
|
}
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
2015-11-17 13:37:39 +00:00
|
|
|
public function getBodyMessage() {
|
2016-05-13 23:37:34 +00:00
|
|
|
$sectionText = $this->event->getExtraParam( 'section-text' );
|
2019-04-05 20:50:03 +00:00
|
|
|
if ( !$this->isBundled() && $this->section->exists() && $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
|
|
|
}
|