showError('Template "' . $template . '" was not found.');
exit;
}elseif (!array_key_exists("error", $json)){
die("Error Template was not found.");
}
$this->page = $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($args = []) {
$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"]);
$app_name = file_get_contents("http://" . APP_DOMAIN . "/api/settings/appname.php");
$app_name = json_decode($app_name, true);
$app_name = $app_name["data"]["application_name"];
$html = str_replace("%appname%", $app_name, $html);
// 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);
// Insert Args
foreach ($args as $key => $value) {
$html = str_replace($key, $value, $html);
}
die($html);
}
}