From 7f6afabab259f261dbe595a8bf71ca1cd70fc551 Mon Sep 17 00:00:00 2001 From: bruno Date: Fri, 2 Feb 2024 12:38:18 +0100 Subject: [PATCH] dokelu --- lib/endpoint.php | 2 +- lib/navigation.php | 19 ++++--------------- lib/page.php | 18 +----------------- .../{global/account.php => account/domov.php} | 0 4 files changed, 6 insertions(+), 33 deletions(-) rename pages/{global/account.php => account/domov.php} (100%) diff --git a/lib/endpoint.php b/lib/endpoint.php index a617001..de8413f 100644 --- a/lib/endpoint.php +++ b/lib/endpoint.php @@ -23,7 +23,7 @@ function getEndpoint($endpoint_name): string $endpoint_file = $routerConfig["endpoint_dir"] . $routerRequest["subdomain"] . "/" . $endpoint_name . ".php"; - $endpoint_file_global = $routerConfig["endpoint_dir"] . "global/" . $endpoint_name . ".php"; + $endpoint_file_global = $routerConfig["endpoint_dir"] . "account/" . $endpoint_name . ".php"; if (file_exists($endpoint_file_global)){ $output = runEndpoint($endpoint_file_global); diff --git a/lib/navigation.php b/lib/navigation.php index e4b6b4b..16e7ff6 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -18,21 +18,10 @@ function generateNavigation(): string $pages_dir = array_diff(scandir($routerConfig["page_dir"] . $site_dir), array('.', '..')); $site_name = str_replace("_", " ", $site_dir); - if ($site_name == "global") { - $site_name = "misc"; - $site_subdomain = $routerConfig["default_site"]; - } - else{ - $site_subdomain = $site_dir; - } - - if ($site_name == "smp") { - $site_name = "SMP"; - } else{ - $site_name = ucfirst($site_name); - } - $site_location = $routerConfig["protocol"] . $site_subdomain . "." . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $routerConfig["default_page"]; + $site_name = ucfirst($site_name); + + $site_location = $routerConfig["protocol"] . $site_dir . "." . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $routerConfig["default_page"]; if ($routerRequest["subdomain"] == $site_dir) { //this is the current page @@ -52,7 +41,7 @@ function generateNavigation(): string $page_class = "class=\"navpage_link active\""; } - $page_location = $routerConfig["protocol"] . $site_subdomain . "." . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $page_dir; + $page_location = $routerConfig["protocol"] . $site_dir . "." . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $page_dir; $page_name = str_replace("_", " ", $page_dir); $page_name = explode(".", $page_name)[0]; diff --git a/lib/page.php b/lib/page.php index 75d58c6..15107b4 100644 --- a/lib/page.php +++ b/lib/page.php @@ -44,24 +44,10 @@ function getPage($page_name = null): array|false|string $dynamic_page_file = $routerConfig["page_dir"] . $routerRequest["subdomain"] . "/" . $page_name . ".php"; $page_file = $routerConfig["page_dir"] . $routerRequest["subdomain"] . "/" . $page_name . ".html"; - $dynamic_page_file_global = $routerConfig["page_dir"] . "global/" . $page_name . ".php"; - $page_file_global = $routerConfig["page_dir"] . "global/" . $page_name . ".html"; - $skeleton = file_get_contents($routerConfig["template_dir"] . "skeleton.html"); $nav = file_get_contents($routerConfig["template_dir"] . "nav.html"); - if (file_exists($dynamic_page_file_global)){ - $pageMetadata = renderDynamicPage($dynamic_page_file_global); - $page = $pageMetadata["output"]; - - } - elseif (file_exists($page_file_global)){ - $page_tmp = file_get_contents($page_file_global); - - $pageMetadata = parsePageTag($page_tmp); - $page = $pageMetadata["output"]; - } - elseif (file_exists($dynamic_page_file)){ + if (file_exists($dynamic_page_file)){ $pageMetadata = renderDynamicPage($dynamic_page_file); $page = $pageMetadata["output"]; @@ -143,11 +129,9 @@ function getPage($page_name = null): array|false|string if(!empty($pageMetadata["parameters"]["page_script"])){ $script_location = $pageMetadata["parameters"]["page_script"]; - echo $script_location; } else{ $script_location = "assets/scripts/$site_name/$page_name.js"; - echo $script_location; } if(file_exists($style_location)) { diff --git a/pages/global/account.php b/pages/account/domov.php similarity index 100% rename from pages/global/account.php rename to pages/account/domov.php