mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 02:02:41 +01:00
b1dfbda741
Summary: Also some random cleanup now and again. Note reply handler stuff is kind of bojangles bad right now. It didn't work before though either so hey. Test Plan: asked questions, answered questions, edited answers... the feed pleased my eye Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T3653 Differential Revision: https://secure.phabricator.com/D7027
110 lines
2.6 KiB
PHP
110 lines
2.6 KiB
PHP
<?php
|
|
|
|
final class PonderAnswerTransaction
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
const TYPE_CONTENT = 'ponder.answer:content';
|
|
|
|
public function getApplicationName() {
|
|
return 'ponder';
|
|
}
|
|
|
|
public function getTableName() {
|
|
return 'ponder_answertransaction';
|
|
}
|
|
|
|
public function getApplicationTransactionType() {
|
|
return PonderPHIDTypeAnswer::TYPECONST;
|
|
}
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
return new PonderAnswerTransactionComment();
|
|
}
|
|
|
|
public function getRequiredHandlePHIDs() {
|
|
$phids = parent::getRequiredHandlePHIDs();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_CONTENT:
|
|
$phids[] = $this->getObjectPHID();
|
|
break;
|
|
}
|
|
|
|
return $phids;
|
|
}
|
|
|
|
public function getTitle() {
|
|
$author_phid = $this->getAuthorPHID();
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_CONTENT:
|
|
return pht(
|
|
'%s edited %s.',
|
|
$this->renderHandleLink($author_phid),
|
|
$this->renderHandleLink($object_phid));
|
|
}
|
|
|
|
return parent::getTitle();
|
|
}
|
|
|
|
public function getTitleForFeed(PhabricatorFeedStory $story) {
|
|
$author_phid = $this->getAuthorPHID();
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_CONTENT:
|
|
$answer = $story->getObject($object_phid);
|
|
$question = $answer->getQuestion();
|
|
$answer_handle = $this->getHandle($object_phid);
|
|
$link = $answer_handle->renderLink(
|
|
$question->getFullTitle());
|
|
|
|
return pht(
|
|
'%s updated their answer to %s',
|
|
$this->renderHandleLink($author_phid),
|
|
$link);
|
|
}
|
|
|
|
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(
|
|
phutil_utf8_shorten($new, 128));
|
|
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) {
|
|
$old = $this->getOldValue();
|
|
$new = $this->getNewValue();
|
|
|
|
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
|
->setUser($viewer)
|
|
->setOldText($old)
|
|
->setNewText($new);
|
|
|
|
return $view->render();
|
|
}
|
|
|
|
}
|
|
|