forked from Adleraci/adlerka.top
Change the template from replace to string interpolation
This commit is contained in:
parent
02d480d31a
commit
9fb61dd8a9
@ -5,9 +5,6 @@ function generateNavigation()
|
||||
global $routerConfig;
|
||||
global $routerRequest;
|
||||
|
||||
$navsite_template = '<li class="navsite_item"><a href="__LOCATION__" __CLASS__>__NAME__</a><ul class="navpage_list">__NAVPAGES__</ul></li>';
|
||||
$navpage_template = '<li class="navpage_item"><a href="__LOCATION__" __CLASS__>__NAME__</a></li>';
|
||||
|
||||
$site_dirs = array_diff(scandir($routerConfig["static_page_dir"]), array('.', '..'));
|
||||
|
||||
$nav_out = "";
|
||||
@ -15,12 +12,13 @@ function generateNavigation()
|
||||
foreach ($site_dirs as $site_dir) {
|
||||
$pages_dir = array_diff(scandir($routerConfig["static_page_dir"] . $site_dir), array('.', '..'));
|
||||
|
||||
$navsite = $navsite_template;
|
||||
$site_name = str_replace("_", " ", $site_dir);
|
||||
if ($site_name == "global") {
|
||||
$site_name = "misc";
|
||||
$site_dir = $routerConfig["default_page"];
|
||||
}
|
||||
$site_name = ucfirst($site_name);
|
||||
|
||||
$site_location = $routerRequest["protocol"] . $site_dir . "." . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $routerConfig["default_page"];
|
||||
|
||||
if ($routerRequest["subdomain"] == $site_dir) {
|
||||
@ -31,14 +29,9 @@ function generateNavigation()
|
||||
$site_class = "class=\"navsite_link\"";
|
||||
}
|
||||
|
||||
$navsite = str_replace("__CLASS__", $site_class, $navsite);
|
||||
$navsite = str_replace("__LOCATION__", $site_location, $navsite);
|
||||
$navsite = str_replace("__NAME__", ucfirst($site_name), $navsite);
|
||||
|
||||
$navpages = "";
|
||||
foreach ($pages_dir as $page_dir) {
|
||||
$page_dir = explode(".", $page_dir)[0];
|
||||
$navpage = $navpage_template;
|
||||
$page_class = "class=\"navpage_link\"";
|
||||
if ($routerRequest["subdomain"] == $site_dir && $routerRequest["page_name"] == $page_dir) {
|
||||
$page_class = "class=\"navpage_link active\"";
|
||||
@ -48,14 +41,11 @@ function generateNavigation()
|
||||
|
||||
$page_name = str_replace("_", " ", $page_dir);
|
||||
$page_name = explode(".", $page_name)[0];
|
||||
$page_name = ucfirst($page_name);
|
||||
|
||||
$navpage = str_replace("__CLASS__", $page_class, $navpage);
|
||||
$navpage = str_replace("__LOCATION__", $page_location, $navpage);
|
||||
$navpage = str_replace("__NAME__", $page_name, $navpage);
|
||||
$navpages .= $navpage;
|
||||
$navpages .= "<li class='navpage_item'><a href='$page_location' $page_class>$page_name</a></li>";
|
||||
}
|
||||
$navsite = str_replace("__NAVPAGES__", $navpages, $navsite);
|
||||
$nav_out .= $navsite;
|
||||
$nav_out .= "<li class='navsite_item'><a href='$site_location' $site_class>$site_name</a><ul class='navpage_list'>$navpages</ul></li>";
|
||||
}
|
||||
|
||||
return $nav_out;
|
||||
|
Loading…
Reference in New Issue
Block a user