protected function renderTransactionContent(PhabricatorApplicationTransaction $xaction)
 {
     $out = array();
     $type_inline = DifferentialTransaction::TYPE_INLINE;
     $group = $xaction->getTransactionGroup();
     if ($xaction->getTransactionType() == $type_inline) {
         array_unshift($group, $xaction);
     } else {
         $out[] = parent::renderTransactionContent($xaction);
     }
     if (!$group) {
         return $out;
     }
     $inlines = array();
     foreach ($group as $xaction) {
         switch ($xaction->getTransactionType()) {
             case DifferentialTransaction::TYPE_INLINE:
                 $inlines[] = $xaction;
                 break;
             default:
                 throw new Exception('Unknown grouped transaction type!');
         }
     }
     if ($inlines) {
         $inline_view = new PhabricatorInlineSummaryView();
         $changesets = $this->getChangesets();
         $inline_groups = DifferentialTransactionComment::sortAndGroupInlines($inlines, $changesets);
         foreach ($inline_groups as $changeset_id => $group) {
             $changeset = $changesets[$changeset_id];
             $items = array();
             foreach ($group as $inline) {
                 $comment = $inline->getComment();
                 $item = array('id' => $comment->getID(), 'line' => $comment->getLineNumber(), 'length' => $comment->getLineLength(), 'content' => parent::renderTransactionContent($inline));
                 $changeset_diff_id = $changeset->getDiffID();
                 if ($comment->getIsNewFile()) {
                     $visible_diff_id = $this->getRightDiff()->getID();
                 } else {
                     $visible_diff_id = $this->getLeftDiff()->getID();
                 }
                 // TODO: We still get one edge case wrong here, when we have a
                 // versus diff and the file didn't exist in the old version. The
                 // comment is visible because we show the left side of the target
                 // diff when there's no corresponding file in the versus diff, but
                 // we incorrectly link it off-page.
                 $is_visible = $changeset_diff_id == $visible_diff_id;
                 if (!$is_visible) {
                     $item['where'] = pht('(On Diff #%d)', $changeset_diff_id);
                     $revision_id = $this->getRevision()->getID();
                     $comment_id = $comment->getID();
                     $item['href'] = '/D' . $revision_id . '?id=' . $changeset_diff_id . '#inline-' . $comment_id;
                 }
                 $items[] = $item;
             }
             $inline_view->addCommentGroup($changeset->getFilename(), $items);
         }
         $out[] = $inline_view;
     }
     return $out;
 }
 protected function renderTransactionContent(PhabricatorApplicationTransaction $xaction)
 {
     $out = array();
     $type_inline = PhabricatorAuditActionConstants::INLINE;
     $group = $xaction->getTransactionGroup();
     if ($xaction->getTransactionType() == $type_inline) {
         array_unshift($group, $xaction);
     } else {
         $out[] = parent::renderTransactionContent($xaction);
     }
     if (!$group) {
         return $out;
     }
     $inlines = array();
     foreach ($group as $xaction) {
         switch ($xaction->getTransactionType()) {
             case PhabricatorAuditActionConstants::INLINE:
                 $inlines[] = $xaction;
                 break;
             default:
                 throw new Exception('Unknown grouped transaction type!');
         }
     }
     if ($inlines) {
         // TODO: This should do something similar to sortAndGroupInlines() to get
         // a stable ordering.
         $inlines_by_path = array();
         foreach ($inlines as $key => $inline) {
             $comment = $inline->getComment();
             if (!$comment) {
                 // TODO: Migrate these away? They probably do not exist on normal
                 // non-development installs.
                 unset($inlines[$key]);
                 continue;
             }
             $path_id = $comment->getPathID();
             $inlines_by_path[$path_id][] = $inline;
         }
         $inline_view = new PhabricatorInlineSummaryView();
         foreach ($inlines_by_path as $path_id => $group) {
             $path = idx($this->pathMap, $path_id);
             if ($path === null) {
                 continue;
             }
             $items = array();
             foreach ($group as $inline) {
                 $comment = $inline->getComment();
                 $item = array('id' => $comment->getID(), 'line' => $comment->getLineNumber(), 'length' => $comment->getLineLength(), 'content' => parent::renderTransactionContent($inline));
                 $items[] = $item;
             }
             $inline_view->addCommentGroup($path, $items);
         }
         $out[] = $inline_view;
     }
     return $out;
 }
 private function renderInlineContent(PholioTransaction $inline)
 {
     $comment = $inline->getComment();
     $mock = $this->getMock();
     $images = $mock->getAllImages();
     $images = mpull($images, null, 'getID');
     $image = idx($images, $comment->getImageID());
     if (!$image) {
         throw new Exception(pht('No image attached!'));
     }
     $file = $image->getFile();
     if (!$file->isViewableImage()) {
         throw new Exception(pht('File is not viewable.'));
     }
     $image_uri = $file->getBestURI();
     $thumb = id(new PHUIImageMaskView())->addClass('mrl')->setImage($image_uri)->setDisplayHeight(100)->setDisplayWidth(200)->withMask(true)->centerViewOnPoint($comment->getX(), $comment->getY(), $comment->getHeight(), $comment->getWidth());
     $link = phutil_tag('a', array('href' => '#', 'class' => 'pholio-transaction-inline-image-anchor'), $thumb);
     $inline_comment = parent::renderTransactionContent($inline);
     return phutil_tag('div', array('class' => 'pholio-transaction-inline-comment'), array($link, $inline_comment));
 }