nieuws: ignore missing page description in new articles
[minimedit.git] / page.php
index dd629fd8d4f0f869af47c8bb84515a12e34546d8..bca7a6745e7e9809e5b8c746818c5041933a54b9 100644 (file)
--- a/page.php
+++ b/page.php
@@ -10,7 +10,7 @@ function abort($body, $status = NULL) {
 
 function placeholder_include($name, $params = [])
 {
-       $path = "$name.php";
+       $path = stream_resolve_include_path("$name.php");
        if (!file_exists($path)) {
                return '<strong class="warn"><em>'.$name.'</em> ontbreekt</strong>';
        }
@@ -52,8 +52,13 @@ function getoutput($blocks = [])
                }
        }
 
+       # keep either login or logout parts depending on user level
+       global $User;
+       $hideclass = empty($User) ? 'login' : 'logout';
+       $doc = preg_replace('{\s*<(p|li|span) class="'.$hideclass.'">.*?</\1>}s', '', $doc);
+
        return preg_replace_callback(
-               '< \[\[ ([^] ]+) ([^]]*) \]\] >x',
+               '{ (?<! <!--BLOCK: ) \[\[ ([^] ]+) ([^]]*) \]\] }x',
                function ($sub) use ($blocks) {
                        list ($placeholder, $name, $params) = $sub;
                        if (isset($blocks[$name])) {