Differential D21277 Diff 50671 src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
<?php | <?php | ||||
final class DifferentialChangesetOneUpRenderer | final class DifferentialChangesetOneUpRenderer | ||||
extends DifferentialChangesetHTMLRenderer { | extends DifferentialChangesetHTMLRenderer { | ||||
private $simpleMode; | |||||
public function setSimpleMode($simple_mode) { | |||||
$this->simpleMode = $simple_mode; | |||||
return $this; | |||||
} | |||||
public function getSimpleMode() { | |||||
return $this->simpleMode; | |||||
} | |||||
public function isOneUpRenderer() { | public function isOneUpRenderer() { | ||||
return true; | return true; | ||||
} | } | ||||
protected function getRendererTableClass() { | protected function getRendererTableClass() { | ||||
return 'diff-1up'; | return 'diff-1up'; | ||||
} | } | ||||
Show All 17 Lines | public function renderTextChange( | ||||
$primitives = $this->buildPrimitives($range_start, $range_len); | $primitives = $this->buildPrimitives($range_start, $range_len); | ||||
return $this->renderPrimitives($primitives, $rows); | return $this->renderPrimitives($primitives, $rows); | ||||
} | } | ||||
protected function renderPrimitives(array $primitives, $rows) { | protected function renderPrimitives(array $primitives, $rows) { | ||||
list($left_prefix, $right_prefix) = $this->getLineIDPrefixes(); | list($left_prefix, $right_prefix) = $this->getLineIDPrefixes(); | ||||
$is_simple = $this->getSimpleMode(); | |||||
$no_copy = phutil_tag('td', array('class' => 'copy')); | $no_copy = phutil_tag('td', array('class' => 'copy')); | ||||
$no_coverage = null; | $no_coverage = null; | ||||
$column_width = 4; | $column_width = 4; | ||||
$aural_minus = javelin_tag( | $aural_minus = javelin_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | foreach ($primitives as $k => $p) { | ||||
'class' => $class, | 'class' => $class, | ||||
'data-copy-mode' => 'copy-unified', | 'data-copy-mode' => 'copy-unified', | ||||
), | ), | ||||
$render); | $render); | ||||
$cells[] = $no_coverage; | $cells[] = $no_coverage; | ||||
} | } | ||||
// In simple mode, only render the text. This is used to render | |||||
// "Edit Suggestions" in inline comments. | |||||
if ($is_simple) { | |||||
$cells = array($cells[3]); | |||||
} | |||||
$out[] = phutil_tag('tr', array(), $cells); | $out[] = phutil_tag('tr', array(), $cells); | ||||
break; | break; | ||||
case 'inline': | case 'inline': | ||||
$inline = $this->buildInlineComment( | $inline = $this->buildInlineComment( | ||||
$p['comment'], | $p['comment'], | ||||
$p['right']); | $p['right']); | ||||
$out[] = $this->getRowScaffoldForInline($inline); | $out[] = $this->getRowScaffoldForInline($inline); | ||||
Show All 30 Lines | foreach ($primitives as $k => $p) { | ||||
$links)); | $links)); | ||||
break; | break; | ||||
default: | default: | ||||
$out[] = hsprintf('<tr><th /><th /><td>%s</td></tr>', $type); | $out[] = hsprintf('<tr><th /><th /><td>%s</td></tr>', $type); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
$result = null; | |||||
if ($out) { | if ($out) { | ||||
return $this->wrapChangeInTable(phutil_implode_html('', $out)); | if ($is_simple) { | ||||
$result = $this->newSimpleTable($out); | |||||
} else { | |||||
$result = $this->wrapChangeInTable(phutil_implode_html('', $out)); | |||||
} | |||||
} | } | ||||
return null; | return $result; | ||||
} | } | ||||
public function renderDocumentEngineBlocks( | public function renderDocumentEngineBlocks( | ||||
PhabricatorDocumentEngineBlocks $block_list, | PhabricatorDocumentEngineBlocks $block_list, | ||||
$old_changeset_key, | $old_changeset_key, | ||||
$new_changeset_key) { | $new_changeset_key) { | ||||
$engine = $this->getDocumentEngine(); | $engine = $this->getDocumentEngine(); | ||||
▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | public function renderDocumentEngineBlocks( | ||||
return $this->renderChangesetTable($output); | return $this->renderChangesetTable($output); | ||||
} | } | ||||
public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) { | public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) { | ||||
return id(new PHUIDiffOneUpInlineCommentRowScaffold()) | return id(new PHUIDiffOneUpInlineCommentRowScaffold()) | ||||
->addInlineView($view); | ->addInlineView($view); | ||||
} | } | ||||
private function newSimpleTable($content) { | |||||
return phutil_tag( | |||||
'table', | |||||
array( | |||||
'class' => 'diff-1up-simple-table', | |||||
), | |||||
$content); | |||||
} | |||||
} | } |