@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 PHUIDocumentView extends AphrontTagView {
4
5 private $header;
6 private $bookname;
7 private $bookdescription;
8 private $fluid;
9 private $toc;
10 private $foot;
11 private $curtain;
12 private $banner;
13
14 public function setHeader(PHUIHeaderView $header) {
15 $header->setTall(true);
16 $this->header = $header;
17 return $this;
18 }
19
20 public function setBook($name, $description) {
21 $this->bookname = $name;
22 $this->bookdescription = $description;
23 return $this;
24 }
25
26 public function setFluid($fluid) {
27 $this->fluid = $fluid;
28 return $this;
29 }
30
31 public function setToc($toc) {
32 $this->toc = $toc;
33 return $this;
34 }
35
36 public function setFoot($foot) {
37 $this->foot = $foot;
38 return $this;
39 }
40
41 public function setCurtain(PHUICurtainView $curtain) {
42 $this->curtain = $curtain;
43 return $this;
44 }
45
46 public function getCurtain() {
47 return $this->curtain;
48 }
49
50 public function setBanner($banner) {
51 $this->banner = $banner;
52 return $this;
53 }
54
55 public function getBanner() {
56 return $this->banner;
57 }
58
59 protected function getTagAttributes() {
60 $classes = array();
61
62 $classes[] = 'phui-document-container';
63 if ($this->fluid) {
64 $classes[] = 'phui-document-fluid';
65 }
66 if ($this->foot) {
67 $classes[] = 'document-has-foot';
68 }
69
70 return array(
71 'class' => implode(' ', $classes),
72 );
73 }
74
75 protected function getTagContent() {
76 require_celerity_resource('phui-document-view-css');
77 require_celerity_resource('phui-document-view-pro-css');
78 Javelin::initBehavior('phabricator-reveal-content');
79
80 $classes = array();
81 $classes[] = 'phui-document-view';
82 $classes[] = 'phui-document-view-pro';
83
84 if ($this->curtain) {
85 $classes[] = 'has-curtain';
86 } else {
87 $classes[] = 'has-no-curtain';
88 }
89
90 if ($this->curtain) {
91 $action_list = $this->curtain->getActionList();
92 $this->header->setActionListID($action_list->getID());
93 }
94
95 $book = null;
96 if ($this->bookname) {
97 $book = pht('%s (%s)', $this->bookname, $this->bookdescription);
98 }
99
100 $main_content = $this->renderChildren();
101
102 if ($book) {
103 $this->header->setSubheader($book);
104 }
105
106 $table_of_contents = null;
107 if ($this->toc) {
108 $toc = array();
109 $toc_id = celerity_generate_unique_node_id();
110 $toc[] = id(new PHUIButtonView())
111 ->setTag('a')
112 ->setIcon('fa-align-left')
113 ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
114 ->addClass('phui-document-toc')
115 ->addSigil('jx-toggle-class')
116 ->setAuralLabel(pht('Table of Contents'))
117 ->setMetaData(array(
118 'map' => array(
119 $toc_id => 'phui-document-toc-open',
120 ),
121 ));
122
123 $toc[] = phutil_tag(
124 'div',
125 array(
126 'class' => 'phui-list-sidenav phui-document-toc-list',
127 ),
128 $this->toc);
129
130 $table_of_contents = phutil_tag(
131 'div',
132 array(
133 'class' => 'phui-document-toc-container',
134 'id' => $toc_id,
135 ),
136 $toc);
137 }
138
139 $foot_content = null;
140 if ($this->foot) {
141 $foot_content = phutil_tag(
142 'div',
143 array(
144 'class' => 'phui-document-foot-content',
145 ),
146 $this->foot);
147 }
148
149 $curtain = null;
150 if ($this->curtain) {
151 $curtain = phutil_tag(
152 'div',
153 array(
154 'class' => 'phui-document-curtain',
155 ),
156 $this->curtain);
157 }
158
159 $main_content = phutil_tag(
160 'div',
161 array(
162 'class' => 'phui-document-content-view',
163 ),
164 $main_content);
165
166 $content_inner = phutil_tag(
167 'div',
168 array(
169 'class' => 'phui-document-inner',
170 ),
171 array(
172 $table_of_contents,
173 $this->header,
174 $this->banner,
175 phutil_tag(
176 'div',
177 array(
178 'class' => 'phui-document-content-outer',
179 ),
180 phutil_tag(
181 'div',
182 array(
183 'class' => 'phui-document-content-inner',
184 ),
185 array(
186 $main_content,
187 $curtain,
188 ))),
189 $foot_content,
190 ));
191
192 $content = phutil_tag(
193 'div',
194 array(
195 'class' => 'phui-document-content',
196 ),
197 $content_inner);
198
199 return phutil_tag(
200 'div',
201 array(
202 'class' => implode(' ', $classes),
203 ),
204 $content);
205 }
206
207}