3 final class ConpherenceTransactionView
extends AphrontView
{
5 private $conpherenceThread;
6 private $conpherenceTransaction;
9 private $classes = array();
10 private $searchResult;
13 public function setConpherenceThread(ConpherenceThread
$t) {
14 $this->conpherenceThread
= $t;
18 private function getConpherenceThread() {
19 return $this->conpherenceThread
;
22 public function setConpherenceTransaction(ConpherenceTransaction
$tx) {
23 $this->conpherenceTransaction
= $tx;
27 private function getConpherenceTransaction() {
28 return $this->conpherenceTransaction
;
31 public function setHandles(array $handles) {
32 assert_instances_of($handles, 'PhabricatorObjectHandle');
33 $this->handles
= $handles;
37 public function getHandles() {
38 return $this->handles
;
41 public function setMarkupEngine(PhabricatorMarkupEngine
$markup_engine) {
42 $this->markupEngine
= $markup_engine;
46 private function getMarkupEngine() {
47 return $this->markupEngine
;
50 public function addClass($class) {
51 $this->classes
[] = $class;
55 public function setSearchResult($result) {
56 $this->searchResult
= $result;
60 public function render() {
61 $viewer = $this->getUser();
63 throw new PhutilInvalidStateException('setUser');
66 require_celerity_resource('conpherence-transaction-css');
68 $transaction = $this->getConpherenceTransaction();
69 switch ($transaction->getTransactionType()) {
70 case ConpherenceThreadDateMarkerTransaction
::TRANSACTIONTYPE
:
74 'class' => 'conpherence-transaction-view date-marker',
75 'sigil' => 'conpherence-transaction-view',
77 'id' => $transaction->getID() +
0.5,
86 phabricator_format_local_time(
87 $transaction->getDateCreated(),
94 $info = $this->renderTransactionInfo();
95 $actions = $this->renderTransactionActions();
96 $image = $this->renderTransactionImage();
97 $content = $this->renderTransactionContent();
98 $classes = implode(' ', $this->classes
);
99 $transaction_dom_id = 'anchor-'.$transaction->getID();
101 $header = phutil_tag_div(
102 'conpherence-transaction-header grouped',
103 array($actions, $info));
108 'class' => 'conpherence-transaction-view '.$classes,
109 'id' => $transaction_dom_id,
110 'sigil' => 'conpherence-transaction-view',
112 'id' => $transaction->getID(),
117 phutil_tag_div('conpherence-transaction-detail grouped',
118 array($header, $content)),
122 private function renderTransactionInfo() {
123 $viewer = $this->getUser();
124 $thread = $this->getConpherenceThread();
125 $transaction = $this->getConpherenceTransaction();
128 Javelin
::initBehavior('phabricator-tooltips');
129 $tip = phabricator_datetime($transaction->getDateCreated(), $viewer);
130 $label = phabricator_time($transaction->getDateCreated(), $viewer);
133 Javelin
::initBehavior('phabricator-watch-anchor');
134 $anchor = id(new PhabricatorAnchorView())
135 ->setAnchorName($transaction->getID())
138 if ($this->searchResult
) {
139 $uri = $thread->getMonogram();
145 'href' => '/'.$uri.'#'.$transaction->getID(),
146 'class' => 'transaction-date',
147 'sigil' => 'conpherence-search-result-jump',
157 'href' => '#'.$transaction->getID(),
158 'class' => 'transaction-date anchor-link',
159 'sigil' => 'has-tooltip',
171 'class' => 'conpherence-transaction-info',
176 private function renderTransactionActions() {
177 $transaction = $this->getConpherenceTransaction();
179 switch ($transaction->getTransactionType()) {
180 case PhabricatorTransactions
::TYPE_COMMENT
:
181 $handles = $this->getHandles();
182 $author = $handles[$transaction->getAuthorPHID()];
183 $actions = array($author->renderLink());
193 private function renderTransactionImage() {
195 $transaction = $this->getConpherenceTransaction();
196 switch ($transaction->getTransactionType()) {
197 case PhabricatorTransactions
::TYPE_COMMENT
:
198 $handles = $this->getHandles();
199 $author = $handles[$transaction->getAuthorPHID()];
200 $image_uri = $author->getImageURI();
204 'class' => 'conpherence-transaction-image',
205 'style' => 'background-image: url('.$image_uri.');',
212 private function renderTransactionContent() {
213 $transaction = $this->getConpherenceTransaction();
215 $content_class = null;
217 $handles = $this->getHandles();
218 switch ($transaction->getTransactionType()) {
219 case PhabricatorTransactions
::TYPE_COMMENT
:
220 $this->addClass('conpherence-comment');
221 $author = $handles[$transaction->getAuthorPHID()];
222 $comment = $transaction->getComment();
223 $content = $this->getMarkupEngine()->getOutput(
225 PhabricatorApplicationTransactionComment
::MARKUP_FIELD_COMMENT
);
226 $content_class = 'conpherence-message';
229 $content = $transaction->getTitle();
230 $this->addClass('conpherence-edited');
237 'class' => $content_class,
241 return phutil_tag_div('conpherence-transaction-content', $view);