Remove product literal strings in "pht()", part 5
[phabricator.git] / src / applications / differential / render / DifferentialChangesetTestRenderer.php
blobb4b2122e5913ac38cc5ebb272d7ee74a2658b8e4
1 <?php
3 abstract class DifferentialChangesetTestRenderer
4 extends DifferentialChangesetRenderer {
6 protected function renderChangeTypeHeader($force) {
7 $changeset = $this->getChangeset();
9 $old = nonempty($changeset->getOldFile(), '-');
10 $current = nonempty($changeset->getFilename(), '-');
11 $away = nonempty(implode(', ', $changeset->getAwayPaths()), '-');
13 $ctype = $changeset->getChangeType();
14 $ftype = $changeset->getFileType();
15 $force = ($force ? '(forced)' : '(unforced)');
17 return "CTYPE {$ctype} {$ftype} {$force}\n".
18 "{$old}\n".
19 "{$current}\n".
20 "{$away}\n";
23 protected function renderUndershieldHeader() {
24 return null;
27 public function renderShield($message, $force = 'default') {
28 return "SHIELD ({$force}) {$message}\n";
31 protected function renderPropertyChangeHeader() {
32 $changeset = $this->getChangeset();
33 list($old, $new) = $this->getChangesetProperties($changeset);
35 foreach (array_keys($old) as $key) {
36 if ($old[$key] === idx($new, $key)) {
37 unset($old[$key]);
38 unset($new[$key]);
42 if (!$old && !$new) {
43 return null;
46 $props = '';
47 foreach ($old as $key => $value) {
48 $props .= "P - {$key} {$value}~\n";
50 foreach ($new as $key => $value) {
51 $props .= "P + {$key} {$value}~\n";
54 return "PROPERTIES\n".$props;
57 public function renderTextChange(
58 $range_start,
59 $range_len,
60 $rows) {
62 $out = array();
64 $any_old = false;
65 $any_new = false;
66 $primitives = $this->buildPrimitives($range_start, $range_len);
67 foreach ($primitives as $p) {
68 $type = $p['type'];
69 switch ($type) {
70 case 'old':
71 case 'new':
72 if ($type == 'old') {
73 $any_old = true;
75 if ($type == 'new') {
76 $any_new = true;
78 $num = nonempty($p['line'], '-');
79 $render = (string)$p['render'];
80 $htype = nonempty($p['htype'], '.');
82 // TODO: This should probably happen earlier, whenever we deal with
83 // \r and \t normalization?
84 $render = str_replace(
85 array(
86 "\r",
87 "\n",
89 array(
90 '\\r',
91 '\\n',
93 $render);
95 $render = str_replace(
96 array(
97 '<span class="bright">',
98 '</span>',
99 '<span class="depth-out">',
100 '<span class="depth-in">',
102 array(
103 '{(',
104 ')}',
105 '{<',
106 '{>',
108 $render);
110 $render = html_entity_decode($render, ENT_QUOTES);
112 $t = ($type == 'old') ? 'O' : 'N';
114 $out[] = "{$t} {$num} {$htype} {$render}~";
115 break;
116 case 'no-context':
117 $out[] = 'X <MISSING-CONTEXT>';
118 break;
119 default:
120 $out[] = $type;
121 break;
125 if (!$any_old) {
126 $out[] = 'O X <EMPTY>';
129 if (!$any_new) {
130 $out[] = 'N X <EMPTY>';
133 $out = implode("\n", $out)."\n";
134 return phutil_safe_html($out);