Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / view / phui / PHUIObjectItemListView.php
blob3cf703de4c905e5b4690f0e7ae875902b4318894
1 <?php
3 final class PHUIObjectItemListView extends AphrontTagView {
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();
17 public function setAllowEmptyList($allow_empty_list) {
18 $this->allowEmptyList = $allow_empty_list;
19 return $this;
22 public function getAllowEmptyList() {
23 return $this->allowEmptyList;
26 public function setFlush($flush) {
27 $this->flush = $flush;
28 return $this;
31 public function setHeader($header) {
32 $this->header = $header;
33 return $this;
36 public function setPager($pager) {
37 $this->pager = $pager;
38 return $this;
41 public function setSimple($simple) {
42 $this->simple = $simple;
43 return $this;
46 public function setBig($big) {
47 $this->big = $big;
48 return $this;
51 public function setDrag($drag) {
52 $this->drag = $drag;
53 $this->setItemClass('phui-oi-drag');
54 return $this;
57 public function setNoDataString($no_data_string) {
58 $this->noDataString = $no_data_string;
59 return $this;
62 public function addItem(PHUIObjectItemView $item) {
63 $this->items[] = $item;
64 return $this;
67 public function setItemClass($item_class) {
68 $this->itemClass = $item_class;
69 return $this;
72 protected function getTagName() {
73 return 'ul';
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'));
83 $this->tail[] = $button;
85 return $button;
88 protected function getTagAttributes() {
89 $classes = array();
90 $classes[] = 'phui-oi-list-view';
92 if ($this->flush) {
93 $classes[] = 'phui-oi-list-flush';
94 require_celerity_resource('phui-oi-flush-ui-css');
97 if ($this->simple) {
98 $classes[] = 'phui-oi-list-simple';
99 require_celerity_resource('phui-oi-simple-ui-css');
102 if ($this->big) {
103 $classes[] = 'phui-oi-list-big';
104 require_celerity_resource('phui-oi-big-ui-css');
107 if ($this->drag) {
108 $classes[] = 'phui-oi-list-drag';
109 require_celerity_resource('phui-oi-drag-ui-css');
112 return array(
113 'class' => $classes,
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');
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',
129 $this->header);
132 if ($this->items) {
133 if ($viewer) {
134 foreach ($this->items as $item) {
135 $item->setUser($viewer);
139 foreach ($this->items as $item) {
140 $item->addClass($this->itemClass);
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',
156 $string);
160 $pager = null;
161 if ($this->pager) {
162 $pager = $this->pager;
165 $tail = array();
166 foreach ($this->tail as $tail_item) {
167 $tail[] = phutil_tag(
168 'li',
169 array(
170 'class' => 'phui-oi-tail',
172 $tail_item);
175 return array(
176 $header,
177 $items,
178 $tail,
179 $pager,
180 $this->renderChildren(),