2013-07-26 22:52:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PonderAnswerTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
|
2013-07-29 02:23:04 +02:00
|
|
|
const TYPE_CONTENT = 'ponder.answer:content';
|
|
|
|
|
2013-07-26 22:52:57 +02:00
|
|
|
public function getApplicationName() {
|
|
|
|
return 'ponder';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTableName() {
|
|
|
|
return 'ponder_answertransaction';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
2014-07-24 00:05:46 +02:00
|
|
|
return PonderAnswerPHIDType::TYPECONST;
|
2013-07-26 22:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
|
|
return new PonderAnswerTransactionComment();
|
|
|
|
}
|
|
|
|
|
2013-09-19 00:15:25 +02:00
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = parent::getRequiredHandlePHIDs();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_CONTENT:
|
|
|
|
$phids[] = $this->getObjectPHID();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
2013-07-29 15:30:07 +02:00
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_CONTENT:
|
|
|
|
return pht(
|
2013-09-19 00:15:25 +02:00
|
|
|
'%s edited %s.',
|
2013-07-29 15:30:07 +02:00
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
}
|
|
|
|
|
2013-09-19 00:15:25 +02:00
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitleForFeed(PhabricatorFeedStory $story) {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_CONTENT:
|
|
|
|
return pht(
|
2014-08-12 21:25:58 +02:00
|
|
|
'%s updated %s.',
|
2013-09-19 00:15:25 +02:00
|
|
|
$this->renderHandleLink($author_phid),
|
2014-08-12 21:25:58 +02:00
|
|
|
$this->renderHandleLink($object_phid));
|
2013-09-19 00:15:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitleForFeed($story);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBodyForFeed(PhabricatorFeedStory $story) {
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$body = null;
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_CONTENT:
|
|
|
|
return phutil_escape_html_newlines(
|
2014-08-30 00:15:13 +02:00
|
|
|
id(new PhutilUTF8StringTruncator())
|
|
|
|
->setMaximumGlyphs(128)
|
|
|
|
->truncateString($new));
|
2013-09-19 00:15:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return parent::getBodyForFeed($story);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function hasChangeDetails() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_CONTENT:
|
|
|
|
return $old !== null;
|
|
|
|
}
|
|
|
|
return parent::hasChangeDetails();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
Allow CustomField to provide ApplicationTransaction change details
Summary:
Ref T3886. Ref T418. For fields like "Summary" and "Test Plan" where changes can't be summarized in one line, allow CustomField to provide a "(Show Details)" link and render a diff.
Also consolidate some of the existing copy/paste, and simplify this featuer slightly now that we've move to dialogs.
Test Plan:
{F115918}
- Viewed "description"-style field changes in phlux, pholio, legalpad, maniphest, differential, ponder (questions), ponder (answers), and repositories.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3886, T418
Differential Revision: https://secure.phabricator.com/D8284
2014-02-21 20:53:04 +01:00
|
|
|
return $this->renderTextCorpusChangeDetails(
|
|
|
|
$viewer,
|
|
|
|
$this->getOldValue(),
|
|
|
|
$this->getNewValue());
|
2013-07-29 15:30:07 +02:00
|
|
|
}
|
2013-07-26 22:52:57 +02:00
|
|
|
|
|
|
|
}
|