showError('Template "' . $template . '" was not found.');
exit;
}elseif (!array_key_exists("error", $json)){
die("Error Template was not found.");
}
$this->template = $template;
}
function showError($error) {
$file = file_get_contents(TEMPLATE_CONF);
$json = json_decode($file, true);
$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__ . " not found.");
}
// Add CSS Files to HTML
$css .= '';
}
$html = str_replace("%css%", $css, $html);
// Write error
$replace = str_replace("%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_file"]);
// Get CSS
$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 ' . $this->template . ' in ' . __FILE__ . " not found.");
}
// Add CSS Files to HTML
$css .= '';
}
$html = str_replace("%css%", $css, $html);
die($html);
}
}