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