Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/diff/view/PHUIDiffInlineCommentRowScaffold.php
12242 views
1
<?php
2
3
/**
4
* Wraps an inline comment in a table row.
5
*
6
* Inline comments need different wrapping cells when shown in unified vs
7
* side-by-side diffs, as the two tables have different layouts. This wraps
8
* an inline comment element in an appropriate table row.
9
*/
10
abstract class PHUIDiffInlineCommentRowScaffold extends AphrontView {
11
12
private $views = array();
13
private $isUndoTemplate;
14
15
final public function setIsUndoTemplate($is_undo_template) {
16
$this->isUndoTemplate = $is_undo_template;
17
return $this;
18
}
19
20
final public function getIsUndoTemplate() {
21
return $this->isUndoTemplate;
22
}
23
24
public function getInlineViews() {
25
return $this->views;
26
}
27
28
public function addInlineView(PHUIDiffInlineCommentView $view) {
29
$this->views[] = $view;
30
return $this;
31
}
32
33
protected function getRowAttributes() {
34
$is_undo_template = $this->getIsUndoTemplate();
35
36
$is_hidden = false;
37
if ($is_undo_template) {
38
39
// NOTE: When this scaffold is turned into an "undo" template, it is
40
// important it not have any metadata: the metadata reference will be
41
// copied to each instance of the row. This is a complicated mess; for
42
// now, just sneak by without generating metadata when rendering undo
43
// templates.
44
45
$metadata = null;
46
} else {
47
foreach ($this->getInlineViews() as $view) {
48
if ($view->isHidden()) {
49
$is_hidden = true;
50
}
51
}
52
53
$metadata = array(
54
'hidden' => $is_hidden,
55
);
56
}
57
58
$classes = array();
59
$classes[] = 'inline';
60
if ($is_hidden) {
61
$classes[] = 'inline-hidden';
62
}
63
64
$result = array(
65
'class' => implode(' ', $classes),
66
'sigil' => 'inline-row',
67
'meta' => $metadata,
68
);
69
70
return $result;
71
}
72
73
}
74
75