2012-12-11 14:00:21 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @concrete-extensible
|
|
|
|
*/
|
|
|
|
class PhabricatorApplicationTransactionFeedStory
|
|
|
|
extends PhabricatorFeedStory {
|
|
|
|
|
|
|
|
public function getPrimaryObjectPHID() {
|
|
|
|
return $this->getValue('objectPHID');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredObjectPHIDs() {
|
2013-11-05 09:03:59 -08:00
|
|
|
return $this->getValue('transactionPHIDs');
|
2012-12-11 14:00:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = array();
|
2013-11-05 09:03:59 -08: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 14:00:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getPrimaryTransactionPHID() {
|
|
|
|
return head($this->getValue('transactionPHIDs'));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getPrimaryTransaction() {
|
|
|
|
return $this->getObject($this->getPrimaryTransactionPHID());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderView() {
|
2013-07-12 17:04:02 -07:00
|
|
|
$view = $this->newStoryView();
|
2012-12-11 14:00:21 -08:00
|
|
|
|
2013-05-26 07:54:29 -07:00
|
|
|
$handle = $this->getHandle($this->getPrimaryObjectPHID());
|
|
|
|
$view->setHref($handle->getURI());
|
|
|
|
|
|
|
|
$view->setAppIconFromPHID($handle->getPHID());
|
2012-12-11 14:00:21 -08:00
|
|
|
|
|
|
|
$xaction_phids = $this->getValue('transactionPHIDs');
|
2013-11-05 09:03:59 -08:00
|
|
|
$xaction = $this->getPrimaryTransaction();
|
2012-12-11 14:00:21 -08:00
|
|
|
|
|
|
|
$xaction->setHandles($this->getHandles());
|
2013-09-18 15:15:25 -07:00
|
|
|
$view->setTitle($xaction->getTitleForFeed($this));
|
2013-11-05 09:03:59 -08: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 10:10:33 -07:00
|
|
|
}
|
2012-12-11 14:00:21 -08:00
|
|
|
|
2013-05-26 07:54:29 -07:00
|
|
|
$view->setImage(
|
2013-11-05 09:03:59 -08:00
|
|
|
$this->getHandle($xaction->getAuthorPHID())->getImageURI());
|
2013-05-26 07:54:29 -07:00
|
|
|
|
2012-12-11 14:00:21 -08:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-02-15 17:10:51 -08:00
|
|
|
public function renderText() {
|
|
|
|
// TODO: This is grotesque; the feed notification handler relies on it.
|
2014-02-03 17:05:16 -08:00
|
|
|
return htmlspecialchars_decode(
|
|
|
|
strip_tags(
|
|
|
|
hsprintf(
|
|
|
|
'%s',
|
|
|
|
$this->renderView()->render())));
|
2013-02-15 17:10:51 -08:00
|
|
|
}
|
|
|
|
|
2012-12-11 14:00:21 -08:00
|
|
|
}
|