Add initial implementation of database and HTML loader classes

This commit is contained in:
marc-go committed 2026-09-29 14:38:06 +02:00
commit 210f27e7c7
4 files changed
+54

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
<?php
class HTMLLoader {
private $template;
function __construct() {
// Check if Paths variables exists
if (!defined(TEMPLATE_PATH) || !defined(TEMPLATE_CONF)) {
die("TEMPLATE_PATH or TEMPLATE_CONF are not defined at " . __FILE__);
}
}
function setTemplate($template) {
// Check if template exists
$file = file_get_contents(TEMPLATE_CONF);
$json = json_decode($file, true);
if (!array_key_exists($template, $json) && array_key_exists("error", $json)) {
$this->showError('Template "' . $template . '" was not found.');
}
}
}
+7
View File
@@ -0,0 +1,7 @@
<?php
// Load GB Libary
require "main.php";
// Init GB Class
$gb = new gb();
+25
View File
@@ -0,0 +1,25 @@
<?php
class gb {
function __construct() {
// Define Paths
define("APP_PATH", __DIR__ . "/..");
define("FRONTEND_PATH", __DIR__ . "/");
define("TEMPLATE_PATH", FRONTEND_PATH . "templates/");
define("TEMPLATE_CONF", TEMPLATE_PATH . "templates.json");
// Check Database and show setup if database not exists
if (!file_exists(APP_PATH . "database.db")) {
$this->initSetup();
}
}
function initSetup() {
// Load and init the HTML Loader
require "html_loader.php";
$html = new HTMLLoader();
// Set template to Setup an show it
$html->setTemplate("setup");
$html->show();
}
}