mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 12:42:43 +01:00
69b0ac724a
Summary: Fixes T4057. This sort of sidesteps the trickiest (but very rare) case of things like embedded slowvotes. We might be able to refine that later. In the common bad case (macros, large images) it gets reasonable results by using `overflow: hidden` with `max-height`. We use `PhabriatorMarkupEngine::summarize()` to try to just render the first paragraph. Test Plan: {F195093} Reviewers: chad, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4057 Differential Revision: https://secure.phabricator.com/D10355
107 lines
2.9 KiB
PHP
107 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @concrete-extensible
|
|
*/
|
|
class PhabricatorApplicationTransactionFeedStory
|
|
extends PhabricatorFeedStory {
|
|
|
|
public function getPrimaryObjectPHID() {
|
|
return $this->getValue('objectPHID');
|
|
}
|
|
|
|
public function getRequiredObjectPHIDs() {
|
|
return $this->getValue('transactionPHIDs');
|
|
}
|
|
|
|
public function getRequiredHandlePHIDs() {
|
|
$phids = array();
|
|
$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;
|
|
}
|
|
|
|
protected function getPrimaryTransactionPHID() {
|
|
return head($this->getValue('transactionPHIDs'));
|
|
}
|
|
|
|
public function getPrimaryTransaction() {
|
|
return $this->getObject($this->getPrimaryTransactionPHID());
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public function renderView() {
|
|
$view = $this->newStoryView();
|
|
|
|
$handle = $this->getHandle($this->getPrimaryObjectPHID());
|
|
$view->setHref($handle->getURI());
|
|
|
|
$view->setAppIconFromPHID($handle->getPHID());
|
|
|
|
$xaction_phids = $this->getValue('transactionPHIDs');
|
|
$xaction = $this->getPrimaryTransaction();
|
|
|
|
$xaction->setHandles($this->getHandles());
|
|
$view->setTitle($xaction->getTitleForFeed($this));
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
$view->setImage(
|
|
$this->getHandle($xaction->getAuthorPHID())->getImageURI());
|
|
|
|
return $view;
|
|
}
|
|
|
|
public function renderText() {
|
|
$xaction = $this->getPrimaryTransaction();
|
|
$old_target = $xaction->getRenderingTarget();
|
|
$new_target = PhabricatorApplicationTransaction::TARGET_TEXT;
|
|
$xaction->setRenderingTarget($new_target);
|
|
$xaction->setHandles($this->getHandles());
|
|
$text = $xaction->getTitleForFeed($this);
|
|
$xaction->setRenderingTarget($old_target);
|
|
return $text;
|
|
}
|
|
|
|
}
|