2012-12-11 23:00:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @concrete-extensible
|
|
|
|
*/
|
|
|
|
class PhabricatorApplicationTransactionFeedStory
|
|
|
|
extends PhabricatorFeedStory {
|
|
|
|
|
|
|
|
public function getPrimaryObjectPHID() {
|
|
|
|
return $this->getValue('objectPHID');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredObjectPHIDs() {
|
2013-11-05 18:03:59 +01:00
|
|
|
return $this->getValue('transactionPHIDs');
|
2012-12-11 23:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = array();
|
2013-11-05 18:03:59 +01:00
|
|
|
$phids[] = $this->getValue('objectPHID');
|
|
|
|
foreach ($this->getValue('transactionPHIDs') as $xaction_phid) {
|
|
|
|
$xaction = $this->getObject($xaction_phid);
|
|
|
|
foreach ($xaction->getRequiredHandlePHIDs() as $handle_phid) {
|
|
|
|
$phids[] = $handle_phid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $phids;
|
2012-12-11 23:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getPrimaryTransactionPHID() {
|
|
|
|
return head($this->getValue('transactionPHIDs'));
|
|
|
|
}
|
|
|
|
|
2014-08-02 09:06:56 +02:00
|
|
|
public function getPrimaryTransaction() {
|
2012-12-11 23:00:21 +01:00
|
|
|
return $this->getObject($this->getPrimaryTransactionPHID());
|
|
|
|
}
|
|
|
|
|
2014-08-26 23:36:35 +02:00
|
|
|
public function getFieldStoryMarkupFields() {
|
|
|
|
$xaction_phids = $this->getValue('transactionPHIDs');
|
|
|
|
|
|
|
|
$fields = array();
|
|
|
|
foreach ($xaction_phids as $xaction_phid) {
|
|
|
|
$xaction = $this->getObject($xaction_phid);
|
|
|
|
foreach ($xaction->getMarkupFieldsForFeed($this) as $field) {
|
|
|
|
$fields[] = $field;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMarkupText($field) {
|
|
|
|
$xaction_phids = $this->getValue('transactionPHIDs');
|
|
|
|
|
|
|
|
foreach ($xaction_phids as $xaction_phid) {
|
|
|
|
$xaction = $this->getObject($xaction_phid);
|
|
|
|
foreach ($xaction->getMarkupFieldsForFeed($this) as $xaction_field) {
|
|
|
|
if ($xaction_field == $field) {
|
|
|
|
return $xaction->getMarkupTextForFeed($this, $field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:00:21 +01:00
|
|
|
public function renderView() {
|
2013-07-13 02:04:02 +02:00
|
|
|
$view = $this->newStoryView();
|
2012-12-11 23:00:21 +01:00
|
|
|
|
2013-05-26 16:54:29 +02:00
|
|
|
$handle = $this->getHandle($this->getPrimaryObjectPHID());
|
|
|
|
$view->setHref($handle->getURI());
|
|
|
|
|
|
|
|
$view->setAppIconFromPHID($handle->getPHID());
|
2012-12-11 23:00:21 +01:00
|
|
|
|
|
|
|
$xaction_phids = $this->getValue('transactionPHIDs');
|
2013-11-05 18:03:59 +01:00
|
|
|
$xaction = $this->getPrimaryTransaction();
|
2012-12-11 23:00:21 +01:00
|
|
|
|
|
|
|
$xaction->setHandles($this->getHandles());
|
2013-09-19 00:15:25 +02:00
|
|
|
$view->setTitle($xaction->getTitleForFeed($this));
|
2013-11-05 18:03:59 +01:00
|
|
|
|
|
|
|
foreach ($xaction_phids as $xaction_phid) {
|
|
|
|
$secondary_xaction = $this->getObject($xaction_phid);
|
|
|
|
$secondary_xaction->setHandles($this->getHandles());
|
|
|
|
|
|
|
|
$body = $secondary_xaction->getBodyForFeed($this);
|
|
|
|
if (nonempty($body)) {
|
|
|
|
$view->appendChild($body);
|
|
|
|
}
|
2013-08-05 19:10:33 +02:00
|
|
|
}
|
2012-12-11 23:00:21 +01:00
|
|
|
|
2013-05-26 16:54:29 +02:00
|
|
|
$view->setImage(
|
2013-11-05 18:03:59 +01:00
|
|
|
$this->getHandle($xaction->getAuthorPHID())->getImageURI());
|
2013-05-26 16:54:29 +02:00
|
|
|
|
2012-12-11 23:00:21 +01:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-02-16 02:10:51 +01:00
|
|
|
public function renderText() {
|
2014-04-10 22:46:02 +02:00
|
|
|
$xaction = $this->getPrimaryTransaction();
|
|
|
|
$old_target = $xaction->getRenderingTarget();
|
|
|
|
$new_target = PhabricatorApplicationTransaction::TARGET_TEXT;
|
|
|
|
$xaction->setRenderingTarget($new_target);
|
2014-04-18 00:57:18 +02:00
|
|
|
$xaction->setHandles($this->getHandles());
|
2014-04-10 22:46:02 +02:00
|
|
|
$text = $xaction->getTitleForFeed($this);
|
|
|
|
$xaction->setRenderingTarget($old_target);
|
|
|
|
return $text;
|
2013-02-16 02:10:51 +01:00
|
|
|
}
|
|
|
|
|
2012-12-11 23:00:21 +01:00
|
|
|
}
|