Differential D19918 Diff 47542 src/applications/transactions/view/PhabricatorApplicationTransactionView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/view/PhabricatorApplicationTransactionView.php
Show All 9 Lines | class PhabricatorApplicationTransactionView extends AphrontView { | ||||
private $showEditActions = true; | private $showEditActions = true; | ||||
private $isPreview; | private $isPreview; | ||||
private $objectPHID; | private $objectPHID; | ||||
private $shouldTerminate = false; | private $shouldTerminate = false; | ||||
private $quoteTargetID; | private $quoteTargetID; | ||||
private $quoteRef; | private $quoteRef; | ||||
private $pager; | private $pager; | ||||
private $renderAsFeed; | private $renderAsFeed; | ||||
private $renderData = array(); | |||||
private $hideCommentOptions = false; | private $hideCommentOptions = false; | ||||
private $viewData = array(); | |||||
public function setRenderAsFeed($feed) { | public function setRenderAsFeed($feed) { | ||||
$this->renderAsFeed = $feed; | $this->renderAsFeed = $feed; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setQuoteRef($quote_ref) { | public function setQuoteRef($quote_ref) { | ||||
$this->quoteRef = $quote_ref; | $this->quoteRef = $quote_ref; | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | public function setPager(AphrontCursorPagerView $pager) { | ||||
$this->pager = $pager; | $this->pager = $pager; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPager() { | public function getPager() { | ||||
return $this->pager; | return $this->pager; | ||||
} | } | ||||
/** | public function setHideCommentOptions($hide_comment_options) { | ||||
* This is additional data that may be necessary to render the next set | $this->hideCommentOptions = $hide_comment_options; | ||||
* of transactions. Objects that implement | |||||
* PhabricatorApplicationTransactionInterface use this data in | |||||
* willRenderTimeline. | |||||
*/ | |||||
public function setRenderData(array $data) { | |||||
$this->renderData = $data; | |||||
return $this; | return $this; | ||||
} | } | ||||
public function getRenderData() { | public function getHideCommentOptions() { | ||||
return $this->renderData; | return $this->hideCommentOptions; | ||||
} | } | ||||
public function setHideCommentOptions($hide_comment_options) { | public function setViewData(array $view_data) { | ||||
$this->hideCommentOptions = $hide_comment_options; | $this->viewData = $view_data; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getHideCommentOptions() { | public function getViewData() { | ||||
return $this->hideCommentOptions; | return $this->viewData; | ||||
} | } | ||||
public function buildEvents($with_hiding = false) { | public function buildEvents($with_hiding = false) { | ||||
$user = $this->getUser(); | $user = $this->getUser(); | ||||
$xactions = $this->transactions; | $xactions = $this->transactions; | ||||
$xactions = $this->filterHiddenTransactions($xactions); | $xactions = $this->filterHiddenTransactions($xactions); | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | class PhabricatorApplicationTransactionView extends AphrontView { | ||||
} | } | ||||
public function buildPHUITimelineView($with_hiding = true) { | public function buildPHUITimelineView($with_hiding = true) { | ||||
if (!$this->getObjectPHID()) { | if (!$this->getObjectPHID()) { | ||||
throw new PhutilInvalidStateException('setObjectPHID'); | throw new PhutilInvalidStateException('setObjectPHID'); | ||||
} | } | ||||
$view = id(new PHUITimelineView()) | $view = id(new PHUITimelineView()) | ||||
->setUser($this->getUser()) | ->setViewer($this->getViewer()) | ||||
->setShouldTerminate($this->shouldTerminate) | ->setShouldTerminate($this->shouldTerminate) | ||||
->setQuoteTargetID($this->getQuoteTargetID()) | ->setQuoteTargetID($this->getQuoteTargetID()) | ||||
->setQuoteRef($this->getQuoteRef()); | ->setQuoteRef($this->getQuoteRef()) | ||||
->setViewData($this->getViewData()); | |||||
$events = $this->buildEvents($with_hiding); | $events = $this->buildEvents($with_hiding); | ||||
foreach ($events as $event) { | foreach ($events as $event) { | ||||
$view->addEvent($event); | $view->addEvent($event); | ||||
} | } | ||||
if ($this->getPager()) { | if ($this->getPager()) { | ||||
$view->setPager($this->getPager()); | $view->setPager($this->getPager()); | ||||
} | } | ||||
if ($this->getRenderData()) { | |||||
$view->setRenderData($this->getRenderData()); | |||||
} | |||||
return $view; | return $view; | ||||
} | } | ||||
public function isTimelineEmpty() { | public function isTimelineEmpty() { | ||||
return !count($this->buildEvents(true)); | return !count($this->buildEvents(true)); | ||||
} | } | ||||
protected function getOrBuildEngine() { | protected function getOrBuildEngine() { | ||||
if (!$this->engine) { | if (!$this->engine) { | ||||
$field = PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT; | $field = PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT; | ||||
$engine = id(new PhabricatorMarkupEngine()) | $engine = id(new PhabricatorMarkupEngine()) | ||||
->setViewer($this->getUser()); | ->setViewer($this->getViewer()); | ||||
foreach ($this->transactions as $xaction) { | foreach ($this->transactions as $xaction) { | ||||
if (!$xaction->hasComment()) { | if (!$xaction->hasComment()) { | ||||
continue; | continue; | ||||
} | } | ||||
$engine->addObject($xaction->getComment(), $field); | $engine->addObject($xaction->getComment(), $field); | ||||
} | } | ||||
$engine->process(); | $engine->process(); | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | private function groupDisplayTransactions(array $xactions) { | ||||
} | } | ||||
return $groups; | return $groups; | ||||
} | } | ||||
private function renderEvent( | private function renderEvent( | ||||
PhabricatorApplicationTransaction $xaction, | PhabricatorApplicationTransaction $xaction, | ||||
array $group) { | array $group) { | ||||
$viewer = $this->getUser(); | $viewer = $this->getViewer(); | ||||
$event = id(new PHUITimelineEventView()) | $event = id(new PHUITimelineEventView()) | ||||
->setUser($viewer) | ->setViewer($viewer) | ||||
->setAuthorPHID($xaction->getAuthorPHID()) | ->setAuthorPHID($xaction->getAuthorPHID()) | ||||
->setTransactionPHID($xaction->getPHID()) | ->setTransactionPHID($xaction->getPHID()) | ||||
->setUserHandle($xaction->getHandle($xaction->getAuthorPHID())) | ->setUserHandle($xaction->getHandle($xaction->getAuthorPHID())) | ||||
->setIcon($xaction->getIcon()) | ->setIcon($xaction->getIcon()) | ||||
->setColor($xaction->getColor()) | ->setColor($xaction->getColor()) | ||||
->setHideCommentOptions($this->getHideCommentOptions()) | ->setHideCommentOptions($this->getHideCommentOptions()) | ||||
->setIsSilent($xaction->getIsSilentTransaction()) | ->setIsSilent($xaction->getIsSilentTransaction()) | ||||
->setIsMFA($xaction->getIsMFATransaction()); | ->setIsMFA($xaction->getIsMFATransaction()); | ||||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |