diff --git a/src/applications/conpherence/ConpherenceTransactionRenderer.php b/src/applications/conpherence/ConpherenceTransactionRenderer.php index 1b14f5f0d6..54801332d2 100644 --- a/src/applications/conpherence/ConpherenceTransactionRenderer.php +++ b/src/applications/conpherence/ConpherenceTransactionRenderer.php @@ -74,7 +74,8 @@ final class ConpherenceTransactionRenderer { ->setUser($user) ->setConpherenceThread($conpherence) ->setHandles($handles) - ->setMarkupEngine($engine); + ->setMarkupEngine($engine) + ->setFullDisplay($full_display); foreach ($transactions as $transaction) { if ($previous_transaction) { @@ -96,21 +97,6 @@ final class ConpherenceTransactionRenderer { } $transaction_view = id(clone $transaction_view_template) ->setConpherenceTransaction($transaction); - if ($full_display) { - $transaction_view - ->setAnchor( - $transaction->getID(), - phabricator_time($transaction->getDateCreated(), $user)); - $transaction_view->setContentSource($transaction->getContentSource()); - $transaction_view->setShowImages(true); - } else { - $transaction_view - ->setEpoch( - $transaction->getDateCreated(), - '/'.$conpherence->getMonogram().'#'.$transaction->getID()) - ->setTimeOnly(true); - $transaction_view->setShowImages(false); - } $rendered_transactions[] = $transaction_view->render(); $previous_transaction = $transaction; diff --git a/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php b/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php index f2a2d920bd..d647248c87 100644 --- a/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php +++ b/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php @@ -227,15 +227,13 @@ final class ConpherenceThreadSearchEngine continue; } - $history_href = '/'.$monogram.'#'.$xaction->getID(); - $view = id(new ConpherenceTransactionView()) ->setUser($viewer) ->setHandles($handles) ->setMarkupEngine($engines[$conpherence_phid]) ->setConpherenceThread($conpherence) ->setConpherenceTransaction($xaction) - ->setEpoch($xaction->getDateCreated(), $history_href) + ->setFullDisplay(false) ->addClass('conpherence-fulltext-result'); if ($message['match']) { diff --git a/src/applications/conpherence/view/ConpherenceTransactionView.php b/src/applications/conpherence/view/ConpherenceTransactionView.php index 2dba770e54..a7a311ce28 100644 --- a/src/applications/conpherence/view/ConpherenceTransactionView.php +++ b/src/applications/conpherence/view/ConpherenceTransactionView.php @@ -6,14 +6,9 @@ final class ConpherenceTransactionView extends AphrontView { private $conpherenceTransaction; private $handles; private $markupEngine; - private $epoch; - private $epochHref; - private $contentSource; - private $anchorName; - private $anchorText; + private $fullDisplay; private $classes = array(); private $timeOnly; - private $showImages = true; public function setConpherenceThread(ConpherenceThread $t) { $this->conpherenceThread = $t; @@ -52,25 +47,13 @@ final class ConpherenceTransactionView extends AphrontView { return $this->markupEngine; } - public function setEpoch($epoch, $epoch_href = null) { - $this->epoch = $epoch; - $this->epochHref = $epoch_href; + public function setFullDisplay($bool) { + $this->fullDisplay = $bool; return $this; } - public function setContentSource(PhabricatorContentSource $source) { - $this->contentSource = $source; - return $this; - } - - private function getContentSource() { - return $this->contentSource; - } - - public function setAnchor($anchor_name, $anchor_text) { - $this->anchorName = $anchor_name; - $this->anchorText = $anchor_text; - return $this; + private function getFullDisplay() { + return $this->fullDisplay; } public function addClass($class) { @@ -78,23 +61,9 @@ final class ConpherenceTransactionView extends AphrontView { return $this; } - public function setTimeOnly($time) { - $this->timeOnly = $time; - return $this; - } - - public function setShowImages($bool) { - $this->showImages = $bool; - return $this; - } - - private function getShowImages() { - return $this->showImages; - } - public function render() { - $user = $this->getUser(); - if (!$user) { + $viewer = $this->getUser(); + if (!$viewer) { throw new Exception(pht('Call setUser() before render()!')); } @@ -120,7 +89,7 @@ final class ConpherenceTransactionView extends AphrontView { ), phabricator_format_local_time( $transaction->getDateCreated(), - $user, + $viewer, 'M jS, Y')), )); break; @@ -132,7 +101,10 @@ final class ConpherenceTransactionView extends AphrontView { $content = $this->renderTransactionContent(); $classes = implode(' ', $this->classes); - $transaction_id = $this->anchorName ? 'anchor-'.$this->anchorName : null; + $transaction_dom_id = null; + if ($this->getFullDisplay()) { + $transaction_dom_id = 'anchor-'.$transaction->getID(); + } $header = phutil_tag_div( 'conpherence-transaction-header grouped', @@ -142,7 +114,7 @@ final class ConpherenceTransactionView extends AphrontView { 'div', array( 'class' => 'conpherence-transaction-view '.$classes, - 'id' => $transaction_id, + 'id' => $transaction_dom_id, 'sigil' => 'conpherence-transaction-view', 'meta' => array( 'id' => $transaction->getID(), @@ -156,53 +128,60 @@ final class ConpherenceTransactionView extends AphrontView { } private function renderTransactionInfo() { + $viewer = $this->getUser(); + $thread = $this->getConpherenceThread(); + $transaction = $this->getConpherenceTransaction(); $info = array(); - if ($this->getContentSource()) { + if ($this->getFullDisplay() && $transaction->getContentSource()) { $content_source = id(new PhabricatorContentSourceView()) - ->setContentSource($this->getContentSource()) - ->setUser($this->user) + ->setContentSource($transaction->getContentSource()) + ->setUser($viewer) ->render(); if ($content_source) { $info[] = $content_source; } } - if ($this->epoch) { - if ($this->timeOnly) { - $epoch = phabricator_time($this->epoch, $this->user); - } else { - $epoch = phabricator_datetime($this->epoch, $this->user); - } - if ($this->epochHref) { - $epoch = phutil_tag( - 'a', - array( - 'href' => $this->epochHref, - 'class' => 'epoch-link', - ), - $epoch); - } - $info[] = $epoch; - } - - if ($this->anchorName) { + Javelin::initBehavior('phabricator-tooltips'); + $tip = phabricator_datetime($transaction->getDateCreated(), $viewer); + $label = phabricator_time($transaction->getDateCreated(), $viewer); + $width = 360; + if ($this->getFullDisplay()) { Javelin::initBehavior('phabricator-watch-anchor'); - $anchor = id(new PhabricatorAnchorView()) - ->setAnchorName($this->anchorName) + ->setAnchorName($transaction->getID()) ->render(); $info[] = hsprintf( '%s%s', $anchor, - phutil_tag( + javelin_tag( 'a', array( - 'href' => '#'.$this->anchorName, + 'href' => '#'.$transaction->getID(), 'class' => 'anchor-link', + 'sigil' => 'has-tooltip', + 'meta' => array( + 'tip' => $tip, + 'size' => $width, + ), ), - $this->anchorText)); + $label)); + } else { + $href = '/'.$thread->getMonogram().'#'.$transaction->getID(); + $info[] = javelin_tag( + 'a', + array( + 'href' => $href, + 'class' => 'epoch-link', + 'sigil' => 'has-tooltip', + 'meta' => array( + 'tip' => $tip, + 'size' => $width, + ), + ), + $label); } $info = phutil_implode_html(" \xC2\xB7 ", $info); @@ -234,7 +213,7 @@ final class ConpherenceTransactionView extends AphrontView { private function renderTransactionImage() { $image = null; - if ($this->getShowImages()) { + if ($this->getFullDisplay()) { $transaction = $this->getConpherenceTransaction(); switch ($transaction->getTransactionType()) { case PhabricatorTransactions::TYPE_COMMENT: @@ -282,7 +261,7 @@ final class ConpherenceTransactionView extends AphrontView { $comment, PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); $content_class = 'conpherence-message'; - break; + break; } $this->appendChild(