Test page title

This commit is contained in:
Bruno Rybársky 2024-02-15 10:49:19 +01:00
parent 3344d7412c
commit 9a2afd7528

@ -1,10 +1,15 @@
<?php
function getDynamicPermission($file): int {
function getDynamicMetadata($file): array{
$page_tmp = include($file);
return $page_tmp;
}
function getDynamicPermission($params): int {
global $routerConfig;
try {
$page_tmp = include($file);
$permission_level = $page_tmp["parameters"]["minimal_permission_level"];
$permission_level = $params["minimal_permission_level"];
if (!is_numeric($permission_level) || $permission_level <= 0) {
$permission_level = $routerConfig["page"]["default_permissions"];
@ -59,6 +64,7 @@ function generateNavigation(): string
$page_name = str_replace("_", " ", $page_basename);
$page_name = explode(".", $page_name)[0];
$page_name = ucfirst($page_name);
$page_file_path = $routerConfig["page_dir"] . $site_dir . "/" . $page_file ;
if($page_file_tmp[1] == "html"){
$page_tmp = file_get_contents($page_file_path);
@ -70,9 +76,17 @@ function generateNavigation(): string
else{
$page_required_permission = $routerConfig["page"]["default_permissions"];
}
if(!empty($pageMetadata["parameters"]["page_title"])){
$page_name = $pageMetadata["parameters"]["page_title"];
}
}
elseif($page_file_tmp[1] == "php"){
$page_required_permission = getDynamicPermission($page_file_path);
$pageMetadata = getDynamicMetadata($page_file_path);
$page_required_permission = getDynamicPermission($pageMetadata);
if(!empty($pageMetadata["parameters"]["page_title"])){
$page_name = $pageMetadata["parameters"]["page_title"];
}
}
else{
$page_required_permission = $routerConfig["page"]["default_permissions"];