Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/phui/PHUIObjectItemListView.php
12249 views
1
<?php
2
3
final class PHUIObjectItemListView extends AphrontTagView {
4
5
private $header;
6
private $items;
7
private $pager;
8
private $noDataString;
9
private $flush;
10
private $simple;
11
private $big;
12
private $drag;
13
private $allowEmptyList;
14
private $itemClass = 'phui-oi-standard';
15
private $tail = array();
16
17
public function setAllowEmptyList($allow_empty_list) {
18
$this->allowEmptyList = $allow_empty_list;
19
return $this;
20
}
21
22
public function getAllowEmptyList() {
23
return $this->allowEmptyList;
24
}
25
26
public function setFlush($flush) {
27
$this->flush = $flush;
28
return $this;
29
}
30
31
public function setHeader($header) {
32
$this->header = $header;
33
return $this;
34
}
35
36
public function setPager($pager) {
37
$this->pager = $pager;
38
return $this;
39
}
40
41
public function setSimple($simple) {
42
$this->simple = $simple;
43
return $this;
44
}
45
46
public function setBig($big) {
47
$this->big = $big;
48
return $this;
49
}
50
51
public function setDrag($drag) {
52
$this->drag = $drag;
53
$this->setItemClass('phui-oi-drag');
54
return $this;
55
}
56
57
public function setNoDataString($no_data_string) {
58
$this->noDataString = $no_data_string;
59
return $this;
60
}
61
62
public function addItem(PHUIObjectItemView $item) {
63
$this->items[] = $item;
64
return $this;
65
}
66
67
public function setItemClass($item_class) {
68
$this->itemClass = $item_class;
69
return $this;
70
}
71
72
protected function getTagName() {
73
return 'ul';
74
}
75
76
public function newTailButton() {
77
$button = id(new PHUIButtonView())
78
->setTag('a')
79
->setColor(PHUIButtonView::GREY)
80
->setIcon('fa-chevron-down')
81
->setText(pht('View All Results'));
82
83
$this->tail[] = $button;
84
85
return $button;
86
}
87
88
protected function getTagAttributes() {
89
$classes = array();
90
$classes[] = 'phui-oi-list-view';
91
92
if ($this->flush) {
93
$classes[] = 'phui-oi-list-flush';
94
require_celerity_resource('phui-oi-flush-ui-css');
95
}
96
97
if ($this->simple) {
98
$classes[] = 'phui-oi-list-simple';
99
require_celerity_resource('phui-oi-simple-ui-css');
100
}
101
102
if ($this->big) {
103
$classes[] = 'phui-oi-list-big';
104
require_celerity_resource('phui-oi-big-ui-css');
105
}
106
107
if ($this->drag) {
108
$classes[] = 'phui-oi-list-drag';
109
require_celerity_resource('phui-oi-drag-ui-css');
110
}
111
112
return array(
113
'class' => $classes,
114
);
115
}
116
117
protected function getTagContent() {
118
$viewer = $this->getUser();
119
require_celerity_resource('phui-oi-list-view-css');
120
require_celerity_resource('phui-oi-color-css');
121
122
$header = null;
123
if ($this->header !== null && strlen($this->header)) {
124
$header = phutil_tag(
125
'h1',
126
array(
127
'class' => 'phui-oi-list-header',
128
),
129
$this->header);
130
}
131
132
if ($this->items) {
133
if ($viewer) {
134
foreach ($this->items as $item) {
135
$item->setUser($viewer);
136
}
137
}
138
139
foreach ($this->items as $item) {
140
$item->addClass($this->itemClass);
141
}
142
143
$items = $this->items;
144
} else if ($this->getAllowEmptyList()) {
145
$items = null;
146
} else {
147
$string = nonempty($this->noDataString, pht('No data.'));
148
$string = id(new PHUIInfoView())
149
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
150
->appendChild($string);
151
$items = phutil_tag(
152
'li',
153
array(
154
'class' => 'phui-oi-empty',
155
),
156
$string);
157
158
}
159
160
$pager = null;
161
if ($this->pager) {
162
$pager = $this->pager;
163
}
164
165
$tail = array();
166
foreach ($this->tail as $tail_item) {
167
$tail[] = phutil_tag(
168
'li',
169
array(
170
'class' => 'phui-oi-tail',
171
),
172
$tail_item);
173
}
174
175
return array(
176
$header,
177
$items,
178
$tail,
179
$pager,
180
$this->renderChildren(),
181
);
182
}
183
184
}
185
186