@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PHUIBadgeBoxView extends AphrontTagView {
4
5 private $items = array();
6 private $collapsed;
7
8 public function addItem($item) {
9 $this->items[] = $item;
10 return $this;
11 }
12
13 public function setCollapsed($collapsed) {
14 $this->collapsed = $collapsed;
15 return $this;
16 }
17
18 public function addItems($items) {
19 foreach ($items as $item) {
20 $this->items[] = $item;
21 }
22 return $this;
23 }
24
25 protected function getTagName() {
26 return 'ul';
27 }
28
29 protected function getTagAttributes() {
30 require_celerity_resource('phui-badge-view-css');
31
32 $classes = array();
33 $classes[] = 'phui-badge-flex-view';
34 $classes[] = 'grouped';
35 if ($this->collapsed) {
36 $classes[] = 'flex-view-collapsed';
37 }
38
39 return array(
40 'class' => implode(' ', $classes),
41 );
42 }
43
44 protected function getTagContent() {
45 $items = array();
46 foreach ($this->items as $item) {
47 $items[] = phutil_tag(
48 'li',
49 array(
50 'class' => 'phui-badge-flex-item',
51 ),
52 $item);
53 }
54 return $items;
55
56 }
57}