diff options
author | Jonas Kohl | 2024-07-21 13:23:33 +0200 |
---|---|---|
committer | Jonas Kohl | 2024-07-21 13:23:33 +0200 |
commit | d79fb0f0ce4744974d45d7d4e80c3af8c2cca717 (patch) | |
tree | bf7a46b251b3047ef5704613fa93c3912427497f /common.php | |
parent | d3db01ccb363db3f48695abd7dd9eef404ebc670 (diff) |
Switch to more flexible params system and add active navlink state
Diffstat (limited to 'common.php')
-rw-r--r-- | common.php | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -2,19 +2,19 @@ define("SRCDIR", realpath(__DIR__ . "/src/")); -function hzcom_expand(string $__page): string { - $title = ""; - $__page = preg_replace_callback( - ';<title>(.*?)</title>;i', - function(array $matches) use(&$title): string { - $title = $matches[1]; +function hzcom_expand(string $pageContents): string { + $params = []; + $page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp"; + file_put_contents($page, preg_replace_callback( + "/<param:(?'paramName'[a-z][a-z0-9_-]*?)\s*>" . + "(?'paramValue'.*?)<\/param:\\1\s*>/s", + function(array $matches) use (&$params) { + $params[$matches['paramName']] = $matches['paramValue']; return ""; }, - $__page - ); - $page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp"; - file_put_contents($page, $__page); - unset($__page); + $pageContents + )); + unset($pageContents); ob_start(); include SRCDIR . "/template.php"; |