Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/diff/view/PhabricatorInlineSummaryView.php
12242 views
1
<?php
2
3
final class PhabricatorInlineSummaryView extends AphrontView {
4
5
private $groups = array();
6
7
public function addCommentGroup($name, array $items) {
8
if (!isset($this->groups[$name])) {
9
$this->groups[$name] = $items;
10
} else {
11
$this->groups[$name] = array_merge($this->groups[$name], $items);
12
}
13
return $this;
14
}
15
16
public function render() {
17
require_celerity_resource('inline-comment-summary-css');
18
return hsprintf('%s', $this->renderTable());
19
}
20
21
private function renderTable() {
22
$rows = array();
23
foreach ($this->groups as $group => $items) {
24
25
$has_where = false;
26
foreach ($items as $item) {
27
if (!empty($item['where'])) {
28
$has_where = true;
29
break;
30
}
31
}
32
33
$icon = id(new PHUIIconView())
34
->setIcon('fa-file-code-o darkbluetext mmr');
35
$header = phutil_tag(
36
'th',
37
array(
38
'colspan' => 3,
39
'class' => 'inline-comment-summary-table-header',
40
),
41
array(
42
$icon,
43
$group,
44
));
45
$rows[] = phutil_tag('tr', array(), $header);
46
47
foreach ($items as $item) {
48
$line = $item['line'];
49
$length = $item['length'];
50
if ($length) {
51
$lines = $line."\xE2\x80\x93".($line + $length);
52
} else {
53
$lines = $line;
54
}
55
56
if (isset($item['href'])) {
57
$href = $item['href'];
58
$target = '_blank';
59
$tail = " \xE2\x86\x97";
60
} else {
61
$href = '#inline-'.$item['id'];
62
$target = null;
63
$tail = null;
64
}
65
66
if ($href) {
67
$icon = id(new PHUIIconView())
68
->setIcon('fa-share darkbluetext mmr');
69
70
$lines = phutil_tag(
71
'a',
72
array(
73
'href' => $href,
74
'target' => $target,
75
'class' => 'num',
76
),
77
array(
78
$icon,
79
$lines,
80
$tail,
81
));
82
}
83
84
$where = idx($item, 'where');
85
86
$colspan = ($has_where ? null : 2);
87
$rows[] = phutil_tag(
88
'tr',
89
array(),
90
array(
91
phutil_tag('td',
92
array('class' => 'inline-line-number inline-table-dolumn'),
93
$lines),
94
($has_where
95
? phutil_tag('td',
96
array('class' => 'inline-which-diff inline-table-dolumn'),
97
$where)
98
: null),
99
phutil_tag(
100
'td',
101
array(
102
'class' => 'inline-summary-content inline-table-dolumn',
103
'colspan' => $colspan,
104
),
105
phutil_tag_div('phabricator-remarkup', $item['content'])),
106
));
107
}
108
}
109
110
return phutil_tag(
111
'table',
112
array(
113
'class' => 'phabricator-inline-summary-table',
114
),
115
phutil_implode_html("\n", $rows));
116
}
117
118
}
119
120