add templates error and setup

This commit is contained in:
admin committed 2026-10-02 16:05:50 +00:00
1 parent 7dffa95fed
commit f8a40bb668
4 files changed
+57 -20

No files matched your search

+29 -2
View File
@@ -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[""])
} }
} }
+1
View File
@@ -0,0 +1 @@
<h1>%error%</h1>
+11
View File
@@ -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>
+16 -18
View File
@@ -1,20 +1,18 @@
{ {
"templates":[ "error":{
{ "name":"error",
"name":"error", "dir_name":"error",
"dir_name":"error", "html_file":"error.html",
"html_file":"error.html", "css_files":[
"css_files":[ "error.css"
"error.css" ]
] },
}, "setup":{
{ "name":"setup",
"name":"setup", "dir_name":"setup",
"dir_name":"setup", "html_file":"setup.html",
"html_file":"setup.html", "css_files":[
"css_files":[ "setup.css"
"setup.css" ]
] }
}
]
} }