page: include scripts from placeholders
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 2 May 2018 12:52:16 +0000 (14:52 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 8 Jun 2018 22:37:09 +0000 (00:37 +0200)
page.php

index 2c3a68ae4e172c86524bbe91004c551bec0794b3..c2dfd9f0ed6089d0f9171c16e8eb02c16fa62341 100644 (file)
--- a/page.php
+++ b/page.php
@@ -23,12 +23,19 @@ function getoutput($blocks = [])
        }
 
        return preg_replace_callback(
-               '< \[\[ ([^]]*) \]\] >x',
+               '< \[\[ ([^]/]+) ([^]]*) \]\] >x',
                function ($sub) use ($blocks) {
-                       list ($placeholder, $name) = $sub;
+                       list ($placeholder, $name, $params) = $sub;
                        if (isset($blocks[$name])) {
                                $html = $blocks[$name];
                        }
+                       elseif (file_exists("$name.php")) {
+                               ob_start();
+                               $Page = $GLOBALS['Page'];
+                               $Args = $GLOBALS['Args'] . $params;
+                               include "$name.php";
+                               $html = ob_get_clean();
+                       }
                        else {
                                $html = '<strong class="warn"><em>'.$name.'</em> ontbreekt</strong>';
                        }