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;
 }
 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;
 }
 private function renderInlines()
 {
     if (!$this->inlineComments) {
         return null;
     }
     $inlines_by_path = mgroup($this->inlineComments, 'getPathID');
     $view = new PhabricatorInlineSummaryView();
     foreach ($inlines_by_path as $path_id => $inlines) {
         $path = idx($this->pathMap, $path_id);
         if ($path === null) {
             continue;
         }
         $items = array();
         foreach ($inlines as $inline) {
             $items[] = array('id' => $inline->getID(), 'line' => $inline->getLineNumber(), 'length' => $inline->getLineLength(), 'content' => PhabricatorInlineSummaryView::renderCommentContent($inline, $this->getEngine()));
         }
         $view->addCommentGroup($path, $items);
     }
     return $view;
 }
 private function renderInlineComments()
 {
     if (!$this->inlines) {
         return null;
     }
     $inlines = $this->inlines;
     $changesets = $this->changesets;
     $inlines_by_changeset = mgroup($inlines, 'getChangesetID');
     $inlines_by_changeset = array_select_keys($inlines_by_changeset, array_keys($this->changesets));
     $view = new PhabricatorInlineSummaryView();
     foreach ($inlines_by_changeset as $changeset_id => $inlines) {
         $changeset = $changesets[$changeset_id];
         $items = array();
         foreach ($inlines as $inline) {
             $on_target = $this->target && $this->target->getID() == $changeset->getDiffID();
             $is_visible = false;
             if ($inline->getIsNewFile()) {
                 // This comment is on the right side of the versus diff, and visible
                 // on the left side of the page.
                 if ($this->versusDiffID) {
                     if ($changeset->getDiffID() == $this->versusDiffID) {
                         $is_visible = true;
                     }
                 }
                 // This comment is on the right side of the target diff, and visible
                 // on the right side of the page.
                 if ($on_target) {
                     $is_visible = true;
                 }
             } else {
                 // Ths comment is on the left side of the target diff, and visible
                 // on the left side of the page.
                 if (!$this->versusDiffID) {
                     if ($on_target) {
                         $is_visible = true;
                     }
                 }
                 // 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.
             }
             $item = array('id' => $inline->getID(), 'line' => $inline->getLineNumber(), 'length' => $inline->getLineLength(), 'content' => PhabricatorInlineSummaryView::renderCommentContent($inline, $this->markupEngine));
             if (!$is_visible) {
                 $diff_id = $changeset->getDiffID();
                 $item['where'] = '(On Diff #' . $diff_id . ')';
                 $item['href'] = 'D' . $this->comment->getRevisionID() . '?id=' . $diff_id . '&large=true' . '#inline-' . $inline->getID();
             }
             $items[] = $item;
         }
         $view->addCommentGroup($changeset->getFilename(), $items);
     }
     return $view;
 }