diff --git a/public/html_loader.php b/public/html_loader.php index 3dd1396..1a08962 100755 --- a/public/html_loader.php +++ b/public/html_loader.php @@ -4,7 +4,7 @@ class HTMLLoader { function __construct() { // Check if Paths variables exists - if (!defined("TEMPLATE_PATH") || !defined("TEMPLATE_CONF")) { + if (!defined("TEMPLATE_PATH") || !defined("TEMPLATE_CONF") || !defined("APP_DOMAIN")) { die("TEMPLATE_PATH or TEMPLATE_CONF are not defined at " . __FILE__); } } @@ -27,11 +27,26 @@ class HTMLLoader { $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"]); + $page = $json["error"]; + $html = file_get_contents(TEMPLATE_PATH . $page["dir_name"] . "/" . $page["html_file"]); + $css = ""; + + // Get CSS + foreach ($page["css_files"] as $file) { + // Check if File exists + if (!is_file(TEMPLATE_PATH . $page["dir_name"] . "/" . $file)) { + $this->showError('CSS File ' . $file . ' for Template error in ' . __FILE__ . ""); + } + + // Add CSS Files to HTML + $css .= ''; + } + + $html = str_replace("%css%", $css, $html); + // Write error - $replace = str_replace("%error%", $error, $error_html); + $replace = str_replace("%error%", $error, $html); die($replace); } @@ -43,9 +58,19 @@ class HTMLLoader { $json = json_decode($file, true); $page = $json[$template]; - $html = file_get_contents(TEMPLATE_PATH . $page["dir_name"] . "/" . $page["html"]); + $html = file_get_contents(TEMPLATE_PATH . $page["dir_name"] . "/" . $page["html_file"]); // Get CSS - foreach ($page[""]) + foreach ($page["css_files"] as $file) { + // Check if File exists + if (!is_file(TEMPLATE_PATH . $page["dir_name"] . "/" . $file)) { + $this->showError('CSS File ' . $file . ' for Template ' . $this->template . ' in ' . __FILE__ . ""); + } + + // Add CSS Files to HTML + $css .= ''; + } + + $html = str_replace("%css%", $css, $html); } } \ No newline at end of file diff --git a/public/main.php b/public/main.php index c4ee940..117fca4 100755 --- a/public/main.php +++ b/public/main.php @@ -9,6 +9,7 @@ class gb { } // Define Paths + define("APP_DOMAIN", $_SERVER["SERVER_NAME"]); define("APP_PATH", __DIR__ . "/.."); define("FRONTEND_PATH", __DIR__ . "/"); define("TEMPLATE_PATH", FRONTEND_PATH . "templates/"); diff --git a/public/templates/error/error.css b/public/templates/error/error.css new file mode 100644 index 0000000..3c2875c --- /dev/null +++ b/public/templates/error/error.css @@ -0,0 +1,3 @@ +.icon { + font-size: 100pt; +} \ No newline at end of file diff --git a/public/templates/error/error.html b/public/templates/error/error.html index 5b42496..6534d4f 100644 --- a/public/templates/error/error.html +++ b/public/templates/error/error.html @@ -1 +1,16 @@ -

%error%

\ No newline at end of file + + + + + + Error + %css% + + +
+
+ ⚠️ +
+
+ + \ No newline at end of file diff --git a/public/test.php b/public/test.php new file mode 100644 index 0000000..adb4924 --- /dev/null +++ b/public/test.php @@ -0,0 +1,5 @@ + $value) { + echo $key . " === " . $value . "
"; +} \ No newline at end of file