3 final class PholioTransactionView
4 extends PhabricatorApplicationTransactionView
{
8 public function setMock($mock) {
13 public function getMock() {
17 protected function shouldGroupTransactions(
18 PhabricatorApplicationTransaction
$u,
19 PhabricatorApplicationTransaction
$v) {
21 if ($u->getAuthorPHID() != $v->getAuthorPHID()) {
22 // Don't group transactions by different authors.
26 if (($v->getDateCreated() - $u->getDateCreated()) > 60) {
27 // Don't group if transactions happened more than 60s apart.
31 switch ($u->getTransactionType()) {
32 case PhabricatorTransactions
::TYPE_COMMENT
:
33 case PholioMockInlineTransaction
::TRANSACTIONTYPE
:
39 switch ($v->getTransactionType()) {
40 case PholioMockInlineTransaction
::TRANSACTIONTYPE
:
44 return parent
::shouldGroupTransactions($u, $v);
47 protected function renderTransactionContent(
48 PhabricatorApplicationTransaction
$xaction) {
52 $group = $xaction->getTransactionGroup();
53 $type = $xaction->getTransactionType();
54 if ($type == PholioMockInlineTransaction
::TRANSACTIONTYPE
) {
55 array_unshift($group, $xaction);
57 $out[] = parent
::renderTransactionContent($xaction);
65 foreach ($group as $xaction) {
66 switch ($xaction->getTransactionType()) {
67 case PholioMockInlineTransaction
::TRANSACTIONTYPE
:
68 $inlines[] = $xaction;
71 throw new Exception(pht('Unknown grouped transaction type!'));
76 $icon = id(new PHUIIconView())
77 ->setIcon('fa-comment bluegrey msr');
81 'class' => 'phabricator-transaction-subheader',
83 array($icon, pht('Inline Comments')));
86 foreach ($inlines as $inline) {
87 if (!$inline->getComment()) {
90 $out[] = $this->renderInlineContent($inline);
97 private function renderInlineContent(PholioTransaction
$inline) {
98 $comment = $inline->getComment();
99 $mock = $this->getMock();
100 $images = $mock->getImages();
101 $images = mpull($images, null, 'getID');
103 $image = idx($images, $comment->getImageID());
105 throw new Exception(pht('No image attached!'));
108 $file = $image->getFile();
109 if (!$file->isViewableImage()) {
110 throw new Exception(pht('File is not viewable.'));
113 $image_uri = $file->getBestURI();
115 $thumb = id(new PHUIImageMaskView())
117 ->setImage($image_uri)
118 ->setDisplayHeight(100)
119 ->setDisplayWidth(200)
122 $comment->getX(), $comment->getY(),
123 $comment->getHeight(), $comment->getWidth());
129 'class' => 'pholio-transaction-inline-image-anchor',
133 $inline_comment = parent
::renderTransactionContent($inline);
137 array('class' => 'pholio-transaction-inline-comment'),
138 array($link, $inline_comment));