Refactor API structure: add internal handling, update templates, and remove deprecated files
This commit is contained in:
1 parent
313ffec92c
commit
a33de15f0c
16 files changed
+91
-29
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
class HTMLLoader {
|
||||
private $template;
|
||||
private $page;
|
||||
|
||||
function __construct() {
|
||||
// Check if Paths variables exists
|
||||
@@ -20,7 +20,7 @@ class HTMLLoader {
|
||||
}elseif (!array_key_exists("error", $json)){
|
||||
die("Error Template was not found.");
|
||||
}
|
||||
$this->template = $template;
|
||||
$this->page = $template;
|
||||
}
|
||||
|
||||
function showError($error) {
|
||||
|
||||
@@ -12,6 +12,7 @@ class gb {
|
||||
define("APP_DOMAIN", $_SERVER["SERVER_NAME"]);
|
||||
define("APP_PATH", __DIR__ . "/../");
|
||||
define("FRONTEND_PATH", __DIR__ . "/");
|
||||
define("API_PATH", __DIR__ . "/../api/");
|
||||
define("TEMPLATE_PATH", FRONTEND_PATH . "templates/");
|
||||
define("TEMPLATE_CONF", TEMPLATE_PATH . "templates.json");
|
||||
|
||||
@@ -30,4 +31,30 @@ class gb {
|
||||
$html->setTemplate("setup");
|
||||
$html->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Internal API Call Library
|
||||
class APICall {
|
||||
private $response;
|
||||
private $error;
|
||||
|
||||
function __construct($path, $data) {
|
||||
// Set $internal to true so the api return does not go to the browser
|
||||
$internal = true;
|
||||
|
||||
// Check Path
|
||||
if (!is_file(API_PATH . $path)) {
|
||||
$this->error("API Path invalid.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call API
|
||||
require API_PATH . $path;
|
||||
|
||||
// Get return from the API Library
|
||||
$response = $api->getAnswer();
|
||||
|
||||
$this->response = $response;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Executable
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"error":{
|
||||
"name":"error",
|
||||
"dir_name":"error",
|
||||
"html_file":"error.html",
|
||||
"css_files":[
|
||||
"error.css"
|
||||
]
|
||||
},
|
||||
"setup":{
|
||||
"name":"setup",
|
||||
"dir_name":"setup",
|
||||
"html_file":"setup.html",
|
||||
"css_files":[]
|
||||
},
|
||||
"entrys_frontend":{
|
||||
"name":"entrys_frontend",
|
||||
"dir_name":"entrys_frontend",
|
||||
"html_file":"entrys_frontend.html",
|
||||
"css_files":[]
|
||||
},
|
||||
"login":{
|
||||
"name":"login",
|
||||
"dir_name":"login",
|
||||
"html_file":"login.html",
|
||||
"css_files":[]
|
||||
}
|
||||
}
|
||||
Executable → Regular
+3
-25
@@ -1,28 +1,6 @@
|
||||
{
|
||||
"error":{
|
||||
"name":"error",
|
||||
"dir_name":"error",
|
||||
"html_file":"error.html",
|
||||
"css_files":[
|
||||
"error.css"
|
||||
]
|
||||
},
|
||||
"setup":{
|
||||
"name":"setup",
|
||||
"dir_name":"setup",
|
||||
"html_file":"setup.html",
|
||||
"css_files":[]
|
||||
},
|
||||
"entrys_frontend":{
|
||||
"name":"entrys_frontend",
|
||||
"dir_name":"entrys_frontend",
|
||||
"html_file":"entrys_frontend.html",
|
||||
"css_files":[]
|
||||
},
|
||||
"login":{
|
||||
"name":"login",
|
||||
"dir_name":"login",
|
||||
"html_file":"login.html",
|
||||
"css_files":[]
|
||||
"standard":{
|
||||
"name":"Standard Template",
|
||||
"dir_name":"standard"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user