Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/phui/PHUIDocumentView.php
12249 views
1
<?php
2
3
final 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
->setMetaData(array(
117
'map' => array(
118
$toc_id => 'phui-document-toc-open',
119
),
120
));
121
122
$toc[] = phutil_tag(
123
'div',
124
array(
125
'class' => 'phui-list-sidenav phui-document-toc-list',
126
),
127
$this->toc);
128
129
$table_of_contents = phutil_tag(
130
'div',
131
array(
132
'class' => 'phui-document-toc-container',
133
'id' => $toc_id,
134
),
135
$toc);
136
}
137
138
$foot_content = null;
139
if ($this->foot) {
140
$foot_content = phutil_tag(
141
'div',
142
array(
143
'class' => 'phui-document-foot-content',
144
),
145
$this->foot);
146
}
147
148
$curtain = null;
149
if ($this->curtain) {
150
$curtain = phutil_tag(
151
'div',
152
array(
153
'class' => 'phui-document-curtain',
154
),
155
$this->curtain);
156
}
157
158
$main_content = phutil_tag(
159
'div',
160
array(
161
'class' => 'phui-document-content-view',
162
),
163
$main_content);
164
165
$content_inner = phutil_tag(
166
'div',
167
array(
168
'class' => 'phui-document-inner',
169
),
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',
178
),
179
phutil_tag(
180
'div',
181
array(
182
'class' => 'phui-document-content-inner',
183
),
184
array(
185
$main_content,
186
$curtain,
187
))),
188
$foot_content,
189
));
190
191
$content = phutil_tag(
192
'div',
193
array(
194
'class' => 'phui-document-content',
195
),
196
$content_inner);
197
198
return phutil_tag(
199
'div',
200
array(
201
'class' => implode(' ', $classes),
202
),
203
$content);
204
}
205
206
}
207
208