Differential D10887 Diff 26226 src/applications/transactions/view/PhabricatorApplicationTransactionView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/view/PhabricatorApplicationTransactionView.php
<?php | <?php | ||||
/** | /** | ||||
* @concrete-extensible | * @concrete-extensible | ||||
*/ | */ | ||||
class PhabricatorApplicationTransactionView extends AphrontView { | class PhabricatorApplicationTransactionView extends AphrontView { | ||||
private $transactions; | private $transactions; | ||||
private $engine; | private $engine; | ||||
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; | |||||
public function setQuoteRef($quote_ref) { | public function setQuoteRef($quote_ref) { | ||||
$this->quoteRef = $quote_ref; | $this->quoteRef = $quote_ref; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getQuoteRef() { | public function getQuoteRef() { | ||||
return $this->quoteRef; | return $this->quoteRef; | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public function setTransactions(array $transactions) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setShouldTerminate($term) { | public function setShouldTerminate($term) { | ||||
$this->shouldTerminate = $term; | $this->shouldTerminate = $term; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setPager(AphrontCursorPagerView $pager) { | |||||
$this->pager = $pager; | |||||
return $this; | |||||
} | |||||
public function getPager() { | |||||
return $this->pager; | |||||
} | |||||
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); | ||||
$xactions = $this->groupRelatedTransactions($xactions); | $xactions = $this->groupRelatedTransactions($xactions); | ||||
$groups = $this->groupDisplayTransactions($xactions); | $groups = $this->groupDisplayTransactions($xactions); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | foreach ($groups as $group_key => $group) { | ||||
foreach ($group as $xaction) { | foreach ($group as $xaction) { | ||||
$event = $this->renderEvent($xaction, $group); | $event = $this->renderEvent($xaction, $group); | ||||
$event->setHideByDefault($hide_by_default); | $event->setHideByDefault($hide_by_default); | ||||
if (!$group_event) { | if (!$group_event) { | ||||
$group_event = $event; | $group_event = $event; | ||||
} else { | } else { | ||||
$group_event->addEventToGroup($event); | $group_event->addEventToGroup($event); | ||||
} | } | ||||
if ($hide_by_default) { | |||||
$pager = $this->getPager(); | |||||
if ($pager) { | |||||
$pager->setNextPageID($xaction->getID()); | |||||
} | |||||
} | |||||
} | } | ||||
$events[] = $group_event; | $events[] = $group_event; | ||||
} | } | ||||
return $events; | return $events; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
if (!$this->getObjectPHID()) { | if (!$this->getObjectPHID()) { | ||||
throw new Exception('Call setObjectPHID() before render()!'); | throw new Exception('Call setObjectPHID() before render()!'); | ||||
} | } | ||||
$view = $this->buildPHUITimelineView(); | |||||
if ($this->getShowEditActions()) { | |||||
Javelin::initBehavior('phabricator-transaction-list'); | |||||
} | |||||
return $view->render(); | |||||
} | |||||
public function buildPHUITimelineView($with_hiding = true) { | |||||
if (!$this->getObjectPHID()) { | |||||
throw new Exception( | |||||
'Call setObjectPHID() before buildPHUITimelineView()!'); | |||||
} | |||||
$view = new PHUITimelineView(); | $view = new PHUITimelineView(); | ||||
$view->setShouldTerminate($this->shouldTerminate); | $view->setShouldTerminate($this->shouldTerminate); | ||||
$events = $this->buildEvents($with_hiding = true); | $events = $this->buildEvents($with_hiding); | ||||
foreach ($events as $event) { | foreach ($events as $event) { | ||||
$view->addEvent($event); | $view->addEvent($event); | ||||
} | } | ||||
if ($this->getPager()) { | |||||
if ($this->getShowEditActions()) { | $view->setPager($this->getPager()); | ||||
Javelin::initBehavior('phabricator-transaction-list'); | |||||
} | } | ||||
return $view->render(); | return $view; | ||||
} | } | ||||
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->getUser()); | ||||
▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines |