diff --git a/api/entrys/add.php b/api/entry/add.php similarity index 100% rename from api/entrys/add.php rename to api/entry/add.php diff --git a/api/entrys/get.php b/api/entry/get.php similarity index 100% rename from api/entrys/get.php rename to api/entry/get.php diff --git a/api/entry/getcustom.php b/api/entry/getcustom.php new file mode 100644 index 0000000..36f46ec --- /dev/null +++ b/api/entry/getcustom.php @@ -0,0 +1,37 @@ +getInput(); + + +// Check given Status +if (!isset($input["status"])) { + $api->answer(400, [ + "error" => "missing_fields", + "error_text" => "Some fields are missing" + ], true); + return; +} + +if ($status !== 0 && $status !== 1 && $status !== 2) { + $api->answer(400, [ + "error" => "status_invalid", + "error_text" => "The given status is invalid." + ], true); +} + +$command = "SELECT * FROM entrys WHERE status = :status"; + +$response = $api->dbCommand($command, true, true, [ + ":status" => $status +]); + diff --git a/public/html_loader.php b/public/html_loader.php index 8e1911c..0209979 100755 --- a/public/html_loader.php +++ b/public/html_loader.php @@ -48,7 +48,7 @@ class HTMLLoader { function setPage($page) { if (!array_key_exists($page, $this->template_conf)) { - $this->showError("Page " . $page . " for template " . $this->template . " not found."); + $this->showError('Page ' . $page . ' for template ' . $this->template . ' not found.'); }else{ $this->page = $page; } @@ -93,6 +93,10 @@ class HTMLLoader { $page = $tempalte_conf[$this->page]; + if (!is_file(TEMPLATE_PATH . $template_dir . "/" . $page["dir_name"] . "/" . $page["html_file"])) { + $this->showError('HTML File ' . $page["html_file"] . ' for page ' . $page["name"] . ' in template ' . $template . ' does not exists.'); + } + $html = file_get_contents(TEMPLATE_PATH . $template_dir . "/" . $page["dir_name"] . "/" . $page["html_file"]); if ($showAppName) { diff --git a/public/index.php b/public/index.php index cda4d16..90feab5 100755 --- a/public/index.php +++ b/public/index.php @@ -13,12 +13,16 @@ require FRONTEND_PATH . "html_loader.php"; $htmlLoader = new HTMLLoader(); // Build Entry Page -$htmlLoader->setPage("entrys_frontend"); +$htmlLoader->setPage("entries_frontend"); // Get entrys -$call = new APICall("entrys/get.php"); +$call = new APICall("entry/get.php"); $response = $call->response; +if ($call->getError() !== false) { + $htmlLoader->showError("Entry API Returned an error: " . $call->getError()); +} + if ($response["data"]["empty"]) { $html_block = "

There aren'n any entrys yet. Be the first one!

"; }else{ diff --git a/public/main.php b/public/main.php index 0352dc9..7845594 100755 --- a/public/main.php +++ b/public/main.php @@ -46,7 +46,7 @@ class APICall { // Check Path if (!is_file(API_DIR . $path)) { - $this->error("API Path invalid."); + $this->error = "API Path invalid."; return false; } @@ -58,4 +58,12 @@ class APICall { $this->response = $response; } + + function getError() { + if (isset($this->error)) { + return $this->error; + }else{ + return false; + } + } } \ No newline at end of file diff --git a/public/templates/standard/admin_home/home.html b/public/templates/standard/admin_home/home.html index 1040dd0..ca27aa6 100644 --- a/public/templates/standard/admin_home/home.html +++ b/public/templates/standard/admin_home/home.html @@ -101,7 +101,7 @@ menu - Dashboard + %appname% @@ -117,7 +117,14 @@
-

Dashboard

+

%appname%

+

Entrys

+ + +
Cucumber
+
Cucumbers are long green fruits that are just as long as this multi-line description
+
+
diff --git a/public/templates/standard/entrys_frontend/entrys_frontend.html b/public/templates/standard/entries_frontend/entries_frontend.html similarity index 98% rename from public/templates/standard/entrys_frontend/entrys_frontend.html rename to public/templates/standard/entries_frontend/entries_frontend.html index 8d95aad..50dbcc9 100755 --- a/public/templates/standard/entrys_frontend/entrys_frontend.html +++ b/public/templates/standard/entries_frontend/entries_frontend.html @@ -16,7 +16,7 @@ document.adoptedStyleSheets.push(typescaleStyles.styleSheet); - %appname% // Entrys + %appname% // Entries