Differential D21243 Diff 50591 src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
| Show First 20 Lines • Show All 490 Lines • ▼ Show 20 Lines | abstract class DifferentialChangesetHTMLRenderer | ||||
| /** | /** | ||||
| * Build links which users can click to show more context in a changeset. | * Build links which users can click to show more context in a changeset. | ||||
| * | * | ||||
| * @param int Beginning of the line range to build links for. | * @param int Beginning of the line range to build links for. | ||||
| * @param int Length of the line range to build links for. | * @param int Length of the line range to build links for. | ||||
| * @param int Total number of lines in the changeset. | * @param int Total number of lines in the changeset. | ||||
| * @return markup Rendered links. | * @return markup Rendered links. | ||||
| */ | */ | ||||
| protected function renderShowContextLinks($top, $len, $changeset_length) { | protected function renderShowContextLinks( | ||||
| $top, | |||||
| $len, | |||||
| $changeset_length, | |||||
| $is_blocks = false) { | |||||
| $block_size = 20; | $block_size = 20; | ||||
| $end = ($top + $len) - $block_size; | $end = ($top + $len) - $block_size; | ||||
| // If this is a large block, such that the "top" and "bottom" ranges are | // If this is a large block, such that the "top" and "bottom" ranges are | ||||
| // non-overlapping, we'll provide options to show the top, bottom or entire | // non-overlapping, we'll provide options to show the top, bottom or entire | ||||
| // block. For smaller blocks, we only provide an option to show the entire | // block. For smaller blocks, we only provide an option to show the entire | ||||
| // block, since it would be silly to show the bottom 20 lines of a 25-line | // block, since it would be silly to show the bottom 20 lines of a 25-line | ||||
| // block. | // block. | ||||
| $is_large_block = ($len > ($block_size * 2)); | $is_large_block = ($len > ($block_size * 2)); | ||||
| $links = array(); | $links = array(); | ||||
| $block_display = new PhutilNumber($block_size); | |||||
| if ($is_large_block) { | if ($is_large_block) { | ||||
| $is_first_block = ($top == 0); | $is_first_block = ($top == 0); | ||||
| if ($is_first_block) { | if ($is_first_block) { | ||||
| $text = pht('Show First %d Line(s)', $block_size); | if ($is_blocks) { | ||||
| $text = pht('Show First %s Block(s)', $block_display); | |||||
| } else { | } else { | ||||
| $text = pht("\xE2\x96\xB2 Show %d Line(s)", $block_size); | $text = pht('Show First %s Line(s)', $block_display); | ||||
| } | |||||
| } else { | |||||
| if ($is_blocks) { | |||||
| $text = pht("\xE2\x96\xB2 Show %s Block(s)", $block_display); | |||||
| } else { | |||||
| $text = pht("\xE2\x96\xB2 Show %s Line(s)", $block_display); | |||||
| } | |||||
| } | } | ||||
| $links[] = $this->renderShowContextLink( | $links[] = $this->renderShowContextLink( | ||||
| false, | false, | ||||
| "{$top}-{$len}/{$top}-20", | "{$top}-{$len}/{$top}-20", | ||||
| $text); | $text); | ||||
| } | } | ||||
| if ($is_blocks) { | |||||
| $text = pht('Show All %s Block(s)', new PhutilNumber($len)); | |||||
| } else { | |||||
| $text = pht('Show All %s Line(s)', new PhutilNumber($len)); | |||||
| } | |||||
| $links[] = $this->renderShowContextLink( | $links[] = $this->renderShowContextLink( | ||||
| true, | true, | ||||
| "{$top}-{$len}/{$top}-{$len}", | "{$top}-{$len}/{$top}-{$len}", | ||||
| pht('Show All %d Line(s)', $len)); | $text); | ||||
| if ($is_large_block) { | if ($is_large_block) { | ||||
| $is_last_block = (($top + $len) >= $changeset_length); | $is_last_block = (($top + $len) >= $changeset_length); | ||||
| if ($is_last_block) { | if ($is_last_block) { | ||||
| $text = pht('Show Last %d Line(s)', $block_size); | if ($is_blocks) { | ||||
| $text = pht('Show Last %s Block(s)', $block_display); | |||||
| } else { | } else { | ||||
| $text = "\xE2\x96\xBC ".pht('Show %d Line(s)', $block_size); | $text = pht('Show Last %s Line(s)', $block_display); | ||||
| } | |||||
| } else { | |||||
| if ($is_blocks) { | |||||
| $text = pht("\xE2\x96\xBC Show %s Block(s)", $block_display); | |||||
| } else { | |||||
| $text = pht("\xE2\x96\xBC Show %s Line(s)", $block_display); | |||||
| } | |||||
| } | } | ||||
| $links[] = $this->renderShowContextLink( | $links[] = $this->renderShowContextLink( | ||||
| false, | false, | ||||
| "{$top}-{$len}/{$end}-20", | "{$top}-{$len}/{$end}-20", | ||||
| $text); | $text); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines | |||||