Add PHPDocs generated by ChatGPT,
add additional clarification to some functions, add addNewsComment function and API, currently untested and not implemented in the client, fix a bunch of stuff that PHPStorm pointed out
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
function getDynamicMetadata($file): array{
|
||||
/**
|
||||
* Includes a PHP file that returns metadata associated with a dynamic page.
|
||||
* It simply scopes an external file into a function to prevent variable conflicts.
|
||||
*
|
||||
* @param string $file The file path to the PHP file that contains metadata.
|
||||
* @return array Returns an associative array of metadata from the included PHP file.
|
||||
*/
|
||||
function getDynamicMetadata(string $file): array{
|
||||
return include($file);
|
||||
}
|
||||
|
||||
function getDynamicPermission($metadata): int {
|
||||
/**
|
||||
* Extracts and validates the minimal permission level required to access certain content,
|
||||
* defaulting to system configuration if not properly set or in case of an error.
|
||||
*
|
||||
* @param array $metadata Metadata array that should include a 'parameters' key with 'minimal_permission_level'.
|
||||
* @return int Returns the minimal permission level required to access a page.
|
||||
*@global array $routerConfig Global router configuration settings.
|
||||
*/
|
||||
function getDynamicPermission(array $metadata): int {
|
||||
global $routerConfig;
|
||||
$params = $metadata["parameters"];
|
||||
try {
|
||||
@@ -21,7 +34,14 @@ function getDynamicPermission($metadata): int {
|
||||
return $permission_level;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates HTML navigation links for all sites and pages configured in the router,
|
||||
* adjusting active states based on current request and filtering links by user permissions.
|
||||
*
|
||||
* @global array $routerConfig Global configuration that includes directory paths and default settings.
|
||||
* @global array $routerRequest Current request details including site and page name.
|
||||
* @return string Returns the HTML string of the navigation menu.
|
||||
*/
|
||||
function generateNavigation(): string
|
||||
{
|
||||
global $routerConfig;
|
||||
@@ -107,7 +127,12 @@ function generateNavigation(): string
|
||||
|
||||
return str_replace("__NAV_PAGES__", $nav_out, $nav);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a simple API endpoint-like response for fetching generated navigation HTML.
|
||||
* Wraps generateNavigation for an API.
|
||||
*
|
||||
* @return array Returns an associative array with the navigation HTML and a status indicating success.
|
||||
*/
|
||||
function getNavigationEndpoint() :array{
|
||||
return [
|
||||
"Status" => "Success",
|
||||
|
Reference in New Issue
Block a user