Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / view / phui / PHUIDocumentView.php
blobf57152833e2aded14cf3f6a15faeeb376c670f3a
1 <?php
3 final class PHUIDocumentView extends AphrontTagView {
5 private $header;
6 private $bookname;
7 private $bookdescription;
8 private $fluid;
9 private $toc;
10 private $foot;
11 private $curtain;
12 private $banner;
14 public function setHeader(PHUIHeaderView $header) {
15 $header->setTall(true);
16 $this->header = $header;
17 return $this;
20 public function setBook($name, $description) {
21 $this->bookname = $name;
22 $this->bookdescription = $description;
23 return $this;
26 public function setFluid($fluid) {
27 $this->fluid = $fluid;
28 return $this;
31 public function setToc($toc) {
32 $this->toc = $toc;
33 return $this;
36 public function setFoot($foot) {
37 $this->foot = $foot;
38 return $this;
41 public function setCurtain(PHUICurtainView $curtain) {
42 $this->curtain = $curtain;
43 return $this;
46 public function getCurtain() {
47 return $this->curtain;
50 public function setBanner($banner) {
51 $this->banner = $banner;
52 return $this;
55 public function getBanner() {
56 return $this->banner;
59 protected function getTagAttributes() {
60 $classes = array();
62 $classes[] = 'phui-document-container';
63 if ($this->fluid) {
64 $classes[] = 'phui-document-fluid';
66 if ($this->foot) {
67 $classes[] = 'document-has-foot';
70 return array(
71 'class' => implode(' ', $classes),
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');
80 $classes = array();
81 $classes[] = 'phui-document-view';
82 $classes[] = 'phui-document-view-pro';
84 if ($this->curtain) {
85 $classes[] = 'has-curtain';
86 } else {
87 $classes[] = 'has-no-curtain';
90 if ($this->curtain) {
91 $action_list = $this->curtain->getActionList();
92 $this->header->setActionListID($action_list->getID());
95 $book = null;
96 if ($this->bookname) {
97 $book = pht('%s (%s)', $this->bookname, $this->bookdescription);
100 $main_content = $this->renderChildren();
102 if ($book) {
103 $this->header->setSubheader($book);
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 ->setMetaData(array(
117 'map' => array(
118 $toc_id => 'phui-document-toc-open',
122 $toc[] = phutil_tag(
123 'div',
124 array(
125 'class' => 'phui-list-sidenav phui-document-toc-list',
127 $this->toc);
129 $table_of_contents = phutil_tag(
130 'div',
131 array(
132 'class' => 'phui-document-toc-container',
133 'id' => $toc_id,
135 $toc);
138 $foot_content = null;
139 if ($this->foot) {
140 $foot_content = phutil_tag(
141 'div',
142 array(
143 'class' => 'phui-document-foot-content',
145 $this->foot);
148 $curtain = null;
149 if ($this->curtain) {
150 $curtain = phutil_tag(
151 'div',
152 array(
153 'class' => 'phui-document-curtain',
155 $this->curtain);
158 $main_content = phutil_tag(
159 'div',
160 array(
161 'class' => 'phui-document-content-view',
163 $main_content);
165 $content_inner = phutil_tag(
166 'div',
167 array(
168 'class' => 'phui-document-inner',
170 array(
171 $table_of_contents,
172 $this->header,
173 $this->banner,
174 phutil_tag(
175 'div',
176 array(
177 'class' => 'phui-document-content-outer',
179 phutil_tag(
180 'div',
181 array(
182 'class' => 'phui-document-content-inner',
184 array(
185 $main_content,
186 $curtain,
187 ))),
188 $foot_content,
191 $content = phutil_tag(
192 'div',
193 array(
194 'class' => 'phui-document-content',
196 $content_inner);
198 return phutil_tag(
199 'div',
200 array(
201 'class' => implode(' ', $classes),
203 $content);