-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
58 lines (47 loc) · 1.85 KB
/
view.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
<?php
namespace oohtml;
require_once('element.php');
require_once('contentlessElement.php');
require_once('plainText.php');
if (!class_exists('View', false)) {
class View {
private static $html;
public static $styleFolder;
public static $scriptFolder;
public static $suffix;
public static $head;
public static $body;
public static $foot;
public static function init () {
self::$html = new Element('html');
self::$head = self::$html->createElement('head');
self::$body = self::$html->createElement('body');
self::$foot = new Element('footer');
}
public static function addStyle ($style) {
$tmp = self::$head->createContentlessElement('link');
$tmp->rel = 'stylesheet';
$tmp->href = self::$styleFolder . $style . '.css' . (isset(self::$suffix) ? "?" . self::$suffix : "");
}
public static function addScript ($script, array $options = []) {
extract (array_merge(
[
"location" => self::$foot,
"type" => "text/javascript"
],
$options
));
$tmp = $location->createElement("script", [
"type" => $type,
"src" => self::$scriptFolder . $script . '.js' . (isset(self::$suffix) ? "?" . self::$suffix : "")
]);
}
public static function render () {
self::$body->addContent(self::$foot);
echo ('<!doctype html>');
echo self::$html->generateHTML();
}
}
View::init();
}
?>