page: omit numeric placeholders during edit
[minimedit.git] / page.php
index 6d98863165e670b5d55cc8793fb89b89777ad62a..c34b11c765c51425bb7f634b9921d7e003279c1a 100644 (file)
--- a/page.php
+++ b/page.php
@@ -52,6 +52,9 @@ if (file_exists("$Page$Args/index.html")) {
 elseif (file_exists("$Page$Args.html")) {
        $found = include "./$Page$Args.html";
 }
+elseif (isset($User) and $User['admin']) {
+       $found = require './template.html';
+}
 
 print "</div>\n\n";
 
@@ -62,7 +65,9 @@ if ($Page) {
        {
                $rep = [];
                foreach ($blocks as $name => $html) {
-                       $rep["[[$name]]"] = $html;
+                       $rep["[[$name]]"] = sprintf('<!--BLOCK:%s-->%s<!--/-->',
+                               is_numeric($name) ? '' : "[[$name]]", $html
+                       );
                }
                return str_replace(array_keys($rep), array_values($rep), ob_get_clean());
        }
@@ -76,14 +81,9 @@ include_once 'page.inc.php';
 
 if (!$found) {
        # no resulting output
-       if (isset($User) and $User['admin']) {
-               require './template.html';
-       }
-       else {
-               http_response_code(404);
-               ob_start();
-               require "./404.html";
-               print getoutput([ 'url' => htmlspecialchars($_SERVER['REQUEST_URI']) ]);
-       }
+       http_response_code(404);
+       ob_start();
+       require "./404.html";
+       print getoutput([ 'url' => htmlspecialchars($_SERVER['REQUEST_URI']) ]);
 }