@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 PHUIWorkpanelView extends AphrontTagView {
4
5 private $cards = array();
6 private $header;
7 private $subheader = null;
8 private $footerAction;
9 private $headerActions = array();
10 private $headerTag;
11 private $headerIcon;
12 private $href;
13
14 public function setHeaderIcon($icon) {
15 $this->headerIcon = $icon;
16 return $this;
17 }
18
19 public function getHeaderIcon() {
20 return $this->headerIcon;
21 }
22
23 public function setCards(PHUIObjectItemListView $cards) {
24 $this->cards[] = $cards;
25 return $this;
26 }
27
28 public function setHeader($header) {
29 $this->header = $header;
30 return $this;
31 }
32
33 public function setSubheader($subheader) {
34 $this->subheader = $subheader;
35 return $this;
36 }
37
38 public function setFooterAction(PHUIListItemView $footer_action) {
39 $this->footerAction = $footer_action;
40 return $this;
41 }
42
43 public function addHeaderAction(PHUIIconView $action) {
44 $this->headerActions[] = $action;
45 return $this;
46 }
47
48 public function setHeaderTag(PHUITagView $tag) {
49 $this->headerTag = $tag;
50 return $this;
51 }
52
53 public function setHref($href) {
54 $this->href = $href;
55 return $this;
56 }
57
58 public function getHref() {
59 return $this->href;
60 }
61
62 protected function getTagAttributes() {
63 return array(
64 'class' => 'phui-workpanel-view',
65 );
66 }
67
68 protected function getTagContent() {
69 require_celerity_resource('phui-workpanel-view-css');
70
71 $footer = '';
72 if ($this->footerAction) {
73 $footer_tag = $this->footerAction;
74 $footer = phutil_tag(
75 'ul',
76 array(
77 'class' => 'phui-workpanel-footer-action mst ps',
78 ),
79 $footer_tag);
80 }
81
82 $header = id(new PHUIHeaderView())
83 ->setHeader($this->header)
84 ->setSubheader($this->subheader)
85 ->setCollapsible(true);
86
87 foreach ($this->headerActions as $action) {
88 $header->addActionItem($action);
89 }
90
91 if ($this->headerTag) {
92 $header->addActionItem($this->headerTag);
93 }
94
95 if ($this->headerIcon) {
96 $header->setHeaderIcon($this->headerIcon);
97 }
98
99 $href = $this->getHref();
100 if ($href !== null) {
101 $header->setHref($href);
102 }
103
104 $body = phutil_tag(
105 'div',
106 array(
107 'class' => 'phui-workpanel-body-content',
108 ),
109 $this->cards);
110
111 $body = phutil_tag_div('phui-workpanel-body', $body);
112
113 $view = id(new PHUIBoxView())
114 ->setColor(PHUIBoxView::GREY)
115 ->addClass('phui-workpanel-view-inner')
116 ->setCollapsible(true)
117 ->appendChild(
118 array(
119 $header,
120 $body,
121 $footer,
122 ));
123
124 return $view;
125 }
126}