Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/diff/view/PHUIDiffTwoUpInlineCommentRowScaffold.php
12242 views
1
<?php
2
3
/**
4
* Row scaffold for 2up (side-by-side) changeset views.
5
*
6
* Although this scaffold is normally straightforward, it may also accept
7
* two inline comments and display them adjacently.
8
*/
9
final class PHUIDiffTwoUpInlineCommentRowScaffold
10
extends PHUIDiffInlineCommentRowScaffold {
11
12
public function render() {
13
$inlines = $this->getInlineViews();
14
15
if (!$inlines) {
16
throw new Exception(
17
pht('Two-up inline row scaffold must have at least one inline view.'));
18
}
19
20
if (count($inlines) > 2) {
21
throw new Exception(
22
pht('Two-up inline row scaffold must have at most two inline views.'));
23
}
24
25
if (count($inlines) == 1) {
26
$inline = head($inlines);
27
if ($inline->getIsOnRight()) {
28
$left_side = null;
29
$right_side = $inline;
30
31
$left_hidden = null;
32
$right_hidden = $inline->newHiddenIcon();
33
} else {
34
$left_side = $inline;
35
$right_side = null;
36
37
$left_hidden = $inline->newHiddenIcon();
38
$right_hidden = null;
39
}
40
} else {
41
list($u, $v) = $inlines;
42
43
if ($u->getIsOnRight() == $v->getIsOnRight()) {
44
throw new Exception(
45
pht(
46
'Two-up inline row scaffold must have one comment on the left and '.
47
'one comment on the right when showing two comments.'));
48
}
49
50
if ($v->getIsOnRight()) {
51
$left_side = $u;
52
$right_side = $v;
53
} else {
54
$left_side = $v;
55
$right_side = $u;
56
}
57
58
$left_hidden = null;
59
$right_hidden = null;
60
}
61
62
$left_attrs = array(
63
'class' => 'left',
64
'id' => ($left_side ? $left_side->getScaffoldCellID() : null),
65
);
66
67
$right_attrs = array(
68
'colspan' => 2,
69
'id' => ($right_side ? $right_side->getScaffoldCellID() : null),
70
);
71
72
$cells = array(
73
phutil_tag('td', array('class' => 'n'), $left_hidden),
74
phutil_tag('td', $left_attrs, $left_side),
75
phutil_tag('td', array('class' => 'n'), $right_hidden),
76
phutil_tag('td', array('class' => 'copy')),
77
phutil_tag('td', $right_attrs, $right_side),
78
);
79
80
return javelin_tag('tr', $this->getRowAttributes(), $cells);
81
}
82
83
}
84
85