public function reduceProxyResponse() { if ($this->transactionView) { $view = $this->transactionView; } else { if ($this->getTransactions()) { $view = head($this->getTransactions())->getApplicationTransactionViewObject(); } else { $view = new PhabricatorApplicationTransactionView(); } } $view->setUser($this->getViewer())->setTransactions($this->getTransactions())->setIsPreview($this->isPreview); if ($this->isPreview) { $xactions = mpull($view->buildEvents(), 'render'); } else { $xactions = mpull($view->buildEvents(), 'render', 'getTransactionPHID'); } // Force whatever the underlying views built to render into HTML for // the Javascript. foreach ($xactions as $key => $xaction) { $xactions[$key] = hsprintf('%s', $xaction); } $content = array('xactions' => $xactions, 'spacer' => PHUITimelineView::renderSpacer()); return $this->getProxy()->setContent($content); }
public function reduceProxyResponse() { if ($this->transactionView) { $view = $this->transactionView; } else { if ($this->getTransactions()) { $view = head($this->getTransactions())->getApplicationTransactionViewObject(); } else { $view = new PhabricatorApplicationTransactionView(); } } $view->setUser($this->getViewer())->setTransactions($this->getTransactions())->setIsPreview($this->isPreview); if ($this->isPreview) { $xactions = mpull($view->buildEvents(), 'render'); } else { $xactions = mpull($view->buildEvents(), 'render', 'getTransactionPHID'); } $content = array('xactions' => $xactions, 'spacer' => PHUITimelineView::renderSpacer()); return $this->getProxy()->setContent($content); }
public function willRenderTimeline(PhabricatorApplicationTransactionView $timeline, AphrontRequest $request) { $xactions = $timeline->getTransactions(); $path_ids = array(); foreach ($xactions as $xaction) { if ($xaction->hasComment()) { $path_id = $xaction->getComment()->getPathID(); if ($path_id) { $path_ids[] = $path_id; } } } $path_map = array(); if ($path_ids) { $path_map = id(new DiffusionPathQuery())->withPathIDs($path_ids)->execute(); $path_map = ipull($path_map, 'path', 'id'); } return $timeline->setPathMap($path_map); }
public function willRenderTimeline(PhabricatorApplicationTransactionView $timeline, AphrontRequest $request) { $viewer = $request->getViewer(); $render_data = $timeline->getRenderData(); $left = $request->getInt('left', idx($render_data, 'left')); $right = $request->getInt('right', idx($render_data, 'right')); $diffs = id(new DifferentialDiffQuery())->setViewer($request->getUser())->withIDs(array($left, $right))->execute(); $diffs = mpull($diffs, null, 'getID'); $left_diff = $diffs[$left]; $right_diff = $diffs[$right]; $old_ids = $request->getStr('old', idx($render_data, 'old')); $new_ids = $request->getStr('new', idx($render_data, 'new')); $old_ids = array_filter(explode(',', $old_ids)); $new_ids = array_filter(explode(',', $new_ids)); $type_inline = DifferentialTransaction::TYPE_INLINE; $changeset_ids = array_merge($old_ids, $new_ids); $inlines = array(); foreach ($timeline->getTransactions() as $xaction) { if ($xaction->getTransactionType() == $type_inline) { $inlines[] = $xaction->getComment(); $changeset_ids[] = $xaction->getComment()->getChangesetID(); } } if ($changeset_ids) { $changesets = id(new DifferentialChangesetQuery())->setViewer($request->getUser())->withIDs($changeset_ids)->execute(); $changesets = mpull($changesets, null, 'getID'); } else { $changesets = array(); } foreach ($inlines as $key => $inline) { $inlines[$key] = DifferentialInlineComment::newFromModernComment($inline); } $query = id(new DifferentialInlineCommentQuery())->needHidden(true)->setViewer($viewer); // NOTE: This is a bit sketchy: this method adjusts the inlines as a // side effect, which means it will ultimately adjust the transaction // comments and affect timeline rendering. $query->adjustInlinesForChangesets($inlines, array_select_keys($changesets, $old_ids), array_select_keys($changesets, $new_ids), $this); return $timeline->setChangesets($changesets)->setRevision($this)->setLeftDiff($left_diff)->setRightDiff($right_diff); }
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; }
public function willRenderTimeline(PhabricatorApplicationTransactionView $timeline, AphrontRequest $request) { PholioMockQuery::loadImages($request->getUser(), array($this), $need_inline_comments = true); $timeline->setMock($this); return $timeline; }
public function setTransactionTimeline(PhabricatorApplicationTransactionView $timeline) { $timeline->setQuoteTargetID($this->getCommentID()); if ($this->getNoPermission()) { $timeline->setShouldTerminate(true); } $this->transactionTimeline = $timeline; return $this; }
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)); }