Differential D20833 Diff 49674 src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
Show First 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | public function renderTextChange( | ||||
return $this->wrapChangeInTable(phutil_implode_html('', $html)); | return $this->wrapChangeInTable(phutil_implode_html('', $html)); | ||||
} | } | ||||
public function renderDocumentEngineBlocks( | public function renderDocumentEngineBlocks( | ||||
PhabricatorDocumentEngineBlocks $block_list, | PhabricatorDocumentEngineBlocks $block_list, | ||||
$old_changeset_key, | $old_changeset_key, | ||||
$new_changeset_key) { | $new_changeset_key) { | ||||
$old_view = null; | $old_comments = $this->getOldComments(); | ||||
$new_view = null; | $new_comments = $this->getNewComments(); | ||||
$rows = array(); | |||||
foreach ($block_list->newTwoUpLayout() as $row) { | foreach ($block_list->newTwoUpLayout() as $row) { | ||||
list($old, $new) = $row; | list($old, $new) = $row; | ||||
if ($old) { | if ($old) { | ||||
$old_view = $old->newContentView(); | $old_content = $old->newContentView(); | ||||
} else { | $old_key = $old->getBlockKey(); | ||||
$old_view = null; | $old_classes = implode(' ', $old->getClasses()); | ||||
} else { | |||||
$old_content = null; | |||||
$old_key = null; | |||||
$old_classes = null; | |||||
} | } | ||||
if ($new) { | if ($new) { | ||||
$new_view = $new->newContentView(); | $new_content = $new->newContentView(); | ||||
} else { | $new_key = $new->getBlockKey(); | ||||
$new_view = null; | $new_classes = implode(' ', $new->getClasses()); | ||||
} | } else { | ||||
$new_content = null; | |||||
$new_key = null; | |||||
$new_classes = null; | |||||
} | } | ||||
$html_old = array(); | $old_inline_rows = array(); | ||||
$html_new = array(); | if ($old_key !== null) { | ||||
foreach ($this->getOldComments() as $on_line => $comment_group) { | $old_inlines = idx($old_comments, $old_key, array()); | ||||
foreach ($comment_group as $comment) { | foreach ($old_inlines as $inline) { | ||||
$inline = $this->buildInlineComment( | $inline = $this->buildInlineComment( | ||||
$comment, | $inline, | ||||
$on_right = false); | $on_right = false); | ||||
$html_old[] = $this->getRowScaffoldForInline($inline); | $old_inline_rows[] = $this->getRowScaffoldForInline($inline); | ||||
} | } | ||||
} | } | ||||
foreach ($this->getNewComments() as $lin_line => $comment_group) { | |||||
foreach ($comment_group as $comment) { | $new_inline_rows = array(); | ||||
if ($new_key !== null) { | |||||
$new_inlines = idx($new_comments, $new_key, array()); | |||||
foreach ($new_inlines as $inline) { | |||||
$inline = $this->buildInlineComment( | $inline = $this->buildInlineComment( | ||||
$comment, | $inline, | ||||
$on_right = true); | $on_right = true); | ||||
$html_new[] = $this->getRowScaffoldForInline($inline); | $new_inline_rows[] = $this->getRowScaffoldForInline($inline); | ||||
} | } | ||||
} | } | ||||
if ($old_view === null) { | if ($old_content === null) { | ||||
$old_id = null; | $old_id = null; | ||||
$old_label = null; | $old_label = null; | ||||
} else { | } else { | ||||
$old_id = "C{$old_changeset_key}OL1"; | $old_id = "C{$old_changeset_key}OL{$old_key}"; | ||||
$old_label = '1'; | $old_label = $old_key; | ||||
} | } | ||||
$old_cell = phutil_tag( | $old_line_cell = phutil_tag( | ||||
'td', | 'td', | ||||
array( | array( | ||||
'id' => $old_id, | 'id' => $old_id, | ||||
'class' => 'n', | 'class' => 'n', | ||||
), | ), | ||||
$old_label); | $old_label); | ||||
if ($new_view === null) { | $old_content_cell = phutil_tag( | ||||
'td', | |||||
array( | |||||
'class' => $old_classes, | |||||
), | |||||
$old_content); | |||||
if ($new_content === null) { | |||||
$new_id = null; | $new_id = null; | ||||
$new_label = null; | $new_label = null; | ||||
} else { | } else { | ||||
$new_id = "C{$new_changeset_key}NL1"; | $new_id = "C{$new_changeset_key}NL{$new_key}"; | ||||
$new_label = '1'; | $new_label = $new_key; | ||||
} | } | ||||
$new_cell = phutil_tag( | $new_line_cell = phutil_tag( | ||||
'td', | 'td', | ||||
array( | array( | ||||
'id' => $new_id, | 'id' => $new_id, | ||||
'class' => 'n', | 'class' => 'n', | ||||
), | ), | ||||
$new_label); | $new_label); | ||||
$output = hsprintf( | $new_content_cell = phutil_tag( | ||||
'<tr class="differential-image-diff">'. | 'td', | ||||
'%s'. | array( | ||||
'<td class="differential-old-image diff-image-cell">%s</td>'. | 'class' => $new_classes, | ||||
'%s'. | 'colspan' => '3', | ||||
'<td class="differential-new-image diff-image-cell" '. | ), | ||||
'colspan="3">%s</td>'. | $new_content); | ||||
'</tr>'. | |||||
'%s'. | $row_view = phutil_tag( | ||||
'%s', | 'tr', | ||||
$old_cell, | array(), | ||||
$old_view, | array( | ||||
$new_cell, | $old_line_cell, | ||||
$new_view, | $old_content_cell, | ||||
phutil_implode_html('', $html_old), | $new_line_cell, | ||||
phutil_implode_html('', $html_new)); | $new_content_cell, | ||||
)); | |||||
$rows[] = array( | |||||
$row_view, | |||||
$old_inline_rows, | |||||
$new_inline_rows, | |||||
); | |||||
} | |||||
$output = $this->wrapChangeInTable($output); | $output = $this->wrapChangeInTable($rows); | ||||
return $this->renderChangesetTable($output); | return $this->renderChangesetTable($output); | ||||
} | } | ||||
public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) { | public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) { | ||||
return id(new PHUIDiffTwoUpInlineCommentRowScaffold()) | return id(new PHUIDiffTwoUpInlineCommentRowScaffold()) | ||||
->addInlineView($view); | ->addInlineView($view); | ||||
} | } | ||||
Show All 26 Lines |