forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPage.php
163 lines (141 loc) · 4.88 KB
/
Page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
class Page {
private $title;
private $bodyClass = '';
private $extraScripts = array();
private $extraStyles = array();
private $inlineStyles = '';
private $inlineScripts = '';
private $bodyContent = '';
private $includeNavbar = true;
private $includeFooter = true;
private $includeInHead = array();
private $includeInFooter = array();
public function __construct($title, $bodyClass='') {
$this->title = $title;
$this->bodyClass = $bodyClass;
_ob_start();
}
public function setTitle(string $title) {
$this->title = $title;
}
public function setBodyClass(string $bodyClass) {
$this->bodyClass = $bodyClass;
}
public function setExtraScripts(array $extraScripts) {
$this->extraScripts = $extraScripts;
}
public function setExtraStyles(array $extraStyles) {
$this->extraStyles = $extraStyles;
}
public function setInlineStyles(string $inlineStyles) {
$this->inlineStyles = $inlineStyles;
}
public function setInlineScripts(string $inlineScripts) {
$this->inlineScripts = $inlineScripts;
}
public function setBodyContent(string $bodyContent) {
$this->bodyContent = $bodyContent;
}
public function setIncludeNavbar(bool $includeNavbar) {
$this->includeNavbar = $includeNavbar;
}
public function setIncludeFooter(bool $includeFooter) {
$this->includeFooter = $includeFooter;
}
public function setIncludeInHead(array $includeInHead) {
$this->includeInHead = $includeInHead;
}
public function setIncludeInFooter(array $includeInFooter) {
$this->includeInFooter = $includeInFooter;
}
public function getHead() {
global $config, $global;
if(!is_array($this->title)){
$this->title = array($this->title);
}
foreach ($this->title as $key => $value) {
$this->title[$key] = __($value);
}
echo "<head>";
echo "<title>" . implode($config->getPageTitleSeparator(), $this->title) . getSEOComplement() . $config->getPageTitleSeparator() . $config->getWebSiteTitle() . "</title>";
include $global['systemRootPath'] . 'view/include/head.php';
if(!empty($this->includeInHead)){
foreach ($this->includeInHead as $value) {
include $global['systemRootPath'] . $value;
}
}
if(!empty($this->extraStyles)){
foreach ($this->extraStyles as $style) {
echo "<link href=\"" . $global['webSiteRootURL'].$style . "\" rel=\"stylesheet\" type=\"text/css\" />";
}
}
if (!empty($this->inlineStyles)) {
echo "<style>" . $this->inlineStyles . "</style>";
}
echo "</head>";
}
public function getNavBar() {
global $global;
if ($this->includeNavbar) {
// Your navbar HTML
include $global['systemRootPath'] . 'view/include/navbar.php';
}
}
public function getFooter() {
global $config, $global;
if ($this->includeFooter) {
// Your footer HTML
include $global['systemRootPath'] . 'view/include/footer.php';
}
if(!empty($this->includeInFooter)){
foreach ($this->includeInFooter as $value) {
include $global['systemRootPath'] . $value;
}
}
if(!empty($this->extraScripts)){
foreach ($this->extraScripts as $script) {
echo "<script src=\"" . $global['webSiteRootURL'].$script . "\" type=\"text/javascript\"></script>";
}
}
if (!empty($this->inlineScripts)) {
echo "<script>" . $this->inlineScripts . "</script>";
}
}
public function getContent() {
global $global;
$rtl = '';
if (isRTL()) {
$rtl = 'rtl';
}
echo "<body class=\"{$global['bodyClass']} {$rtl} {$this->bodyClass}\">";
//echo '<div id="_avideoPageLoader">';
//$loaderParts = Layout::getLoaderDefault();
//echo $loaderParts['css'];
//echo $loaderParts['html'];
//echo '</div>';
//echo '<div style="display: none;" id="_avideoPageContent">';
$this->getNavBar();
echo $this->bodyContent;
$this->getFooter();
//echo '</div>';
echo "</body>";
}
public function getPage() {
echo "<!DOCTYPE html>";
echo "<html lang=\"" . getLanguage() . "\">";
$this->getHead();
$this->getContent();
echo "</html>";
}
public function print($include_end = true){
global $config, $global;
$html = _ob_get_clean();
_ob_start();
$this->bodyContent = $html;
$this->getPage();
if($include_end){
include $global['systemRootPath'].'objects/include_end.php';
}
}
}