add templates error and setup
This commit is contained in:
1 parent
7dffa95fed
commit
f8a40bb668
4 files changed
+43
-6
No files matched your search
+29
-2
@@ -16,9 +16,36 @@ class HTMLLoader {
|
|||||||
|
|
||||||
if (!array_key_exists($template, $json) && array_key_exists("error", $json)) {
|
if (!array_key_exists($template, $json) && array_key_exists("error", $json)) {
|
||||||
$this->showError('Template "' . $template . '" was not found.');
|
$this->showError('Template "' . $template . '" was not found.');
|
||||||
|
exit;
|
||||||
}else{
|
}elseif (!array_key_exists("error", $json)){
|
||||||
die("Error Template was not found.");
|
die("Error Template was not found.");
|
||||||
}
|
}
|
||||||
|
$this->template = $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showError($error) {
|
||||||
|
$file = file_get_contents(TEMPLATE_CONF);
|
||||||
|
$json = json_decode($file, true);
|
||||||
|
|
||||||
|
$error_page = $json["error"];
|
||||||
|
$error_html = file_get_contents(TEMPLATE_PATH . $error_page["dir_name"] . "/" . $error_page["html_file"]);
|
||||||
|
|
||||||
|
// Write error
|
||||||
|
$replace = str_replace("%error%", $error, $error_html);
|
||||||
|
|
||||||
|
die($replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
$template = $this->template;
|
||||||
|
|
||||||
|
$file = file_get_contents(TEMPLATE_CONF);
|
||||||
|
$json = json_decode($file, true);
|
||||||
|
|
||||||
|
$page = $json[$template];
|
||||||
|
$html = file_get_contents(TEMPLATE_PATH . $page["dir_name"] . "/" . $page["html"]);
|
||||||
|
|
||||||
|
// Get CSS
|
||||||
|
foreach ($page[""])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>%error%</h1>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Setup</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>La setup</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"templates":[
|
"error":{
|
||||||
{
|
|
||||||
"name":"error",
|
"name":"error",
|
||||||
"dir_name":"error",
|
"dir_name":"error",
|
||||||
"html_file":"error.html",
|
"html_file":"error.html",
|
||||||
@@ -8,7 +7,7 @@
|
|||||||
"error.css"
|
"error.css"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
"setup":{
|
||||||
"name":"setup",
|
"name":"setup",
|
||||||
"dir_name":"setup",
|
"dir_name":"setup",
|
||||||
"html_file":"setup.html",
|
"html_file":"setup.html",
|
||||||
@@ -16,5 +15,4 @@
|
|||||||
"setup.css"
|
"setup.css"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user