From 0826661558e00b7f64011320fe7b039e343521da Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 2 May 2018 17:23:19 +0200 Subject: [PATCH] page: placeholder options Target name can be followed by whitespace for additional configuration. Syntax "name=value" will be applied to global GET (overriding user input). Otherwise a /subpath will be appended to local page Args. --- page.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/page.php b/page.php index c2dfd9f..7c4f8b1 100644 --- a/page.php +++ b/page.php @@ -23,7 +23,7 @@ function getoutput($blocks = []) } return preg_replace_callback( - '< \[\[ ([^]/]+) ([^]]*) \]\] >x', + '< \[\[ ([^] ]+) ([^]]*) \]\] >x', function ($sub) use ($blocks) { list ($placeholder, $name, $params) = $sub; if (isset($blocks[$name])) { @@ -32,7 +32,15 @@ function getoutput($blocks = []) elseif (file_exists("$name.php")) { ob_start(); $Page = $GLOBALS['Page']; - $Args = $GLOBALS['Args'] . $params; + $Args = $GLOBALS['Args']; + foreach (explode(' ', $params) as $param) { + if ($set = strpos($param, '=')) { + $_GET[ substr($param, 0, $set) ] = substr($param, $set + 1); + } + elseif (!empty($param)) { + $Args .= '/'.$param; + } + } include "$name.php"; $html = ob_get_clean(); } -- 2.30.0