@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 PHUIStatusItemView extends AphrontTagView {
4
5 private $icon;
6 private $iconLabel;
7 private $iconColor;
8 private $target;
9 private $note;
10 private $highlighted;
11 private $isExiled;
12
13 const ICON_ACCEPT = 'fa-check-circle';
14 const ICON_REJECT = 'fa-times-circle';
15 const ICON_LEFT = 'fa-chevron-circle-left';
16 const ICON_RIGHT = 'fa-chevron-circle-right';
17 const ICON_UP = 'fa-chevron-circle-up';
18 const ICON_DOWN = 'fa-chevron-circle-down';
19 const ICON_QUESTION = 'fa-question-circle';
20 const ICON_WARNING = 'fa-exclamation-circle';
21 const ICON_INFO = 'fa-info-circle';
22 const ICON_ADD = 'fa-plus-circle';
23 const ICON_MINUS = 'fa-minus-circle';
24 const ICON_OPEN = 'fa-circle-o';
25 const ICON_CLOCK = 'fa-clock-o';
26 const ICON_STAR = 'fa-star';
27
28 public function setIcon($icon, $color = null, $label = null) {
29 $this->icon = $icon;
30 $this->iconLabel = $label;
31 $this->iconColor = $color;
32 return $this;
33 }
34
35 public function setTarget($target) {
36 $this->target = $target;
37 return $this;
38 }
39
40 public function setNote($note) {
41 $this->note = $note;
42 return $this;
43 }
44
45 public function setHighlighted($highlighted) {
46 $this->highlighted = $highlighted;
47 return $this;
48 }
49
50 public function setIsExiled($is_exiled) {
51 $this->isExiled = $is_exiled;
52 return $this;
53 }
54
55 protected function canAppendChild() {
56 return false;
57 }
58
59 protected function getTagName() {
60 return 'tr';
61 }
62
63 protected function getTagAttributes() {
64 $classes = array();
65 if ($this->highlighted) {
66 $classes[] = 'phui-status-item-highlighted';
67 }
68
69 if ($this->isExiled) {
70 $classes[] = 'phui-status-item-exiled';
71 }
72
73 return array(
74 'class' => $classes,
75 );
76 }
77
78 protected function getTagContent() {
79
80 $icon = null;
81 if ($this->icon) {
82 $icon = id(new PHUIIconView())
83 ->setIcon($this->icon.' '.$this->iconColor);
84
85 if ($this->iconLabel) {
86 Javelin::initBehavior('phabricator-tooltips');
87 $icon->addSigil('has-tooltip');
88 $icon->setMetadata(
89 array(
90 'tip' => $this->iconLabel,
91 'size' => 240,
92 ));
93 }
94 }
95
96 $target_cell = phutil_tag(
97 'td',
98 array(
99 'class' => 'phui-status-item-target',
100 ),
101 array(
102 $icon,
103 $this->target,
104 ));
105
106 $note_cell = phutil_tag(
107 'td',
108 array(
109 'class' => 'phui-status-item-note',
110 ),
111 $this->note);
112
113 return array(
114 $target_cell,
115 $note_cell,
116 );
117 }
118}