Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/page/AphrontPageView.php
12241 views
1
<?php
2
3
abstract class AphrontPageView extends AphrontView {
4
5
private $title;
6
7
public function setTitle($title) {
8
$this->title = $title;
9
return $this;
10
}
11
12
public function getTitle() {
13
$title = $this->title;
14
if (is_array($title)) {
15
$title = implode(" \xC2\xB7 ", $title);
16
}
17
return $title;
18
}
19
20
protected function getHead() {
21
return '';
22
}
23
24
protected function getBody() {
25
return phutil_implode_html('', $this->renderChildren());
26
}
27
28
protected function getTail() {
29
return '';
30
}
31
32
protected function willRenderPage() {
33
return;
34
}
35
36
protected function willSendResponse($response) {
37
return $response;
38
}
39
40
protected function getBodyClasses() {
41
return null;
42
}
43
44
public function render() {
45
46
$this->willRenderPage();
47
48
$title = $this->getTitle();
49
$head = $this->getHead();
50
$body = $this->getBody();
51
$tail = $this->getTail();
52
53
$body_classes = $this->getBodyClasses();
54
55
$body = phutil_tag(
56
'body',
57
array(
58
'class' => nonempty($body_classes, null),
59
),
60
array($body, $tail));
61
62
if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode')) {
63
$data_fragment = phutil_safe_html(' data-developer-mode="1"');
64
} else {
65
$data_fragment = null;
66
}
67
68
$response = hsprintf(
69
'<!DOCTYPE html>'.
70
'<html%s>'.
71
'<head>'.
72
'<meta charset="UTF-8" />'.
73
'<title>%s</title>'.
74
'%s'.
75
'</head>'.
76
'%s'.
77
'</html>',
78
$data_fragment,
79
$title,
80
$head,
81
$body);
82
83
$response = $this->willSendResponse($response);
84
85
return $response;
86
87
}
88
89
}
90
91