Enhance API error handling, add lastError tracking, and implement admin home template

This commit is contained in:
marc-go committed 2026-10-11 14:37:56 +02:00
1 parent ce0777bb33
commit 205f2e2f73
9 files changed
+257 -33

No files matched your search

+16 -11
View File
@@ -4,7 +4,7 @@ class HTMLLoader {
private $page;
private $templates;
private $tempalte_conf;
private $template_conf;
function __construct() {
// Check if Paths variables exists
@@ -13,6 +13,7 @@ class HTMLLoader {
}
$this->templates = json_decode(file_get_contents(TEMPLATE_CONF), true);
$this->getTemplate();
}
function setTemplate($template) {
@@ -26,6 +27,7 @@ class HTMLLoader {
}
$this->template = $template;
$this->template_conf = file_get_contents(TEMPLATE_PATH . $this->templates[$template]["dir_name"] . "/template.json");
}
function getTemplate() {
@@ -38,19 +40,26 @@ class HTMLLoader {
$this->showError("Template API Returned an error: " . $response["error_text"]);
}
$this->template = $response["data"]["template_name"];
$template = $response["data"]["template_name"];
$this->template_conf = json_decode(file_get_contents(TEMPLATE_PATH . $this->templates[$template]["dir_name"] . "/template.json"), true);
$this->template = $template;
}
function setPage($page) {
$this->page = $page;
if (!array_key_exists($page, $this->template_conf)) {
$this->showError("Page " . $page . " for template " . $this->template . " not found.");
}else{
$this->page = $page;
}
}
function showError($error) {
$template_dir = $this->templates[$this->template]["dir_name"];
$template_conf = json_decode(file_get_contents(TEMPLATE_DIR . $template_dir));
$template_conf = json_decode(file_get_contents(TEMPLATE_PATH . $template_dir . "/template.json"), true);
$page = $tempalte_conf["error"];
$html = file_get_contents(TEMPLATE_PATH . $page["dir_name"] . "/" . $page["html_file"]);
$page = $template_conf["error"];
$html = file_get_contents(TEMPLATE_PATH . $template_dir . "/" . $page["dir_name"] . "/" . $page["html_file"]);
$css = "";
@@ -79,12 +88,8 @@ class HTMLLoader {
}
$template = $this->template;
$tempalte_conf = $this->template_conf;
$template_dir = $this->templates[$template]["dir_name"];
$template_conf = TEMPLATE_PATH . $template_dir . "/template.json";
$file = file_get_contents($template_conf);
$tempalte_conf = json_decode($file, true);
$page = $tempalte_conf[$this->page];