Change the page endpoint
This commit is contained in:
parent
01fd8389ac
commit
914057680d
30
lib/page.php
30
lib/page.php
@ -32,7 +32,7 @@ function parsePageTag($input): array
|
|||||||
return ['parameters' => [], 'output' => $input];
|
return ['parameters' => [], 'output' => $input];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPage($page_name = null, $site_name = null): string
|
function renderPage($page_name = null, $site_name = null): array
|
||||||
{
|
{
|
||||||
global $routerConfig;
|
global $routerConfig;
|
||||||
global $routerRequest;
|
global $routerRequest;
|
||||||
@ -48,9 +48,6 @@ function getPage($page_name = null, $site_name = null): string
|
|||||||
$dynamic_page_file = $routerConfig["page_dir"] . $site_name . "/" . $page_name . ".php";
|
$dynamic_page_file = $routerConfig["page_dir"] . $site_name . "/" . $page_name . ".php";
|
||||||
$page_file = $routerConfig["page_dir"] . $site_name . "/" . $page_name . ".html";
|
$page_file = $routerConfig["page_dir"] . $site_name . "/" . $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)){
|
if (file_exists($dynamic_page_file)){
|
||||||
$pageMetadata = renderDynamicPage($dynamic_page_file);
|
$pageMetadata = renderDynamicPage($dynamic_page_file);
|
||||||
|
|
||||||
@ -112,15 +109,31 @@ function getPage($page_name = null, $site_name = null): string
|
|||||||
$page = "";
|
$page = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
"PageContent" => $page,
|
||||||
|
"PageName" => $page_name,
|
||||||
|
"SiteName" => $site_name,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPage($page_name_in = null, $site_name_in = null): string
|
||||||
|
{
|
||||||
|
$page_tmp = renderPage($page_name_in, $site_name_in);
|
||||||
|
|
||||||
|
$page = $page_tmp["PageContent"];
|
||||||
|
$page_name = $page_tmp["PageName"];
|
||||||
|
$site_name = $page_tmp["SiteName"];
|
||||||
|
global $routerConfig;
|
||||||
|
|
||||||
|
$skeleton = file_get_contents($routerConfig["template_dir"] . "skeleton.html");
|
||||||
|
$nav = file_get_contents($routerConfig["template_dir"] . "nav.html");
|
||||||
if(!empty($pageMetadata["parameters"]["page_title"])){
|
if(!empty($pageMetadata["parameters"]["page_title"])){
|
||||||
$page_title = $pageMetadata["parameters"]["page_title"];
|
$page_title = $pageMetadata["parameters"]["page_title"];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$page_title = $page_name;
|
$page_title = $page_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$dynamic_style = doDynamicStyling();
|
$dynamic_style = doDynamicStyling();
|
||||||
$dynamic_script = generateScriptData([
|
$dynamic_script = generateScriptData([
|
||||||
"currentPage" => $page_name,
|
"currentPage" => $page_name,
|
||||||
@ -146,9 +159,10 @@ function getPageEndpoint($page_name, $site_name) :array
|
|||||||
{
|
{
|
||||||
global $routerRequest, $routerConfig;
|
global $routerRequest, $routerConfig;
|
||||||
$page_location = $routerConfig["protocol"] . $site_name . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $page_name;
|
$page_location = $routerConfig["protocol"] . $site_name . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $page_name;
|
||||||
|
$page_tmp = renderPage($page_name, $site_name);
|
||||||
return [
|
return [
|
||||||
"Status" => "Success",
|
"Status" => "Success",
|
||||||
"Page" => getPage($page_name, $site_name),
|
"Page" => $page_tmp["PageContent"],
|
||||||
"PageLocation" => $page_location,
|
"PageLocation" => $page_location,
|
||||||
];
|
];
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user