page: replace output caching by article object
[minimedit.git] / page.php
index f5e9749cbeac10837f6d9bf0fb923c5a4234114d..f02544bd0b06dbd7add643d19a17e02bbdca69c2 100644 (file)
--- a/page.php
+++ b/page.php
@@ -163,42 +163,33 @@ elseif ($User and $User->admin("edit $Page$Args")) {
        $staticpage = (file_exists("$Page/template.inc.html") ? "$Page/template.inc.html" : 'template.inc.html');
 }
 
-# load static contents
+# prepare page contents
 
 require_once('article.inc.php');
 $Article = new ArchiveArticle($staticpage);
 
 ob_start(); # page body
-ob_start(); # inner html
-print '<div class="static">'."\n\n";
-
-$found = FALSE;
-if (isset($Article->raw)) {
-       print $Article->raw;
-       $found = 1;
-}
-
-print "</div>\n\n";
-
-# execute dynamic code
-
-$Place = [];
-
-if ($Page) {
-       $found |= require "./$Page/index.php";
-}
-
-$Place += [
+$Place = [
        'user'  => $User ? $User->login : '',
        'url'   => htmlspecialchars($_SERVER['REQUEST_URI']),
 ];
 
-# global html
+if (isset($Article->raw)) {
+       $Article->raw = '<div class="static">'."\n\n".$Article->raw."</div>\n\n";
+}
 
-if (!$found) {
-       # no resulting output
-       http_response_code(404);
-       @require '404.inc.html';
+# output dynamic and/or static html
+
+if (!$Page or require("./$Page/index.php")) {
+       # static contents
+       if (isset($Article->raw)) {
+               print $Article->raw;
+       }
+       else {
+               # no resulting output
+               http_response_code(404);
+               @require '404.inc.html';
+       }
 }
 
 include_once 'page.inc.php';