nieuws/feed: atom content type and link attributes
[minimedit.git] / page.inc.php
index 9d49fad2df8050b4ac7daa86bf903080a9b34bb9..1253338db4707fe6f56e4f6ff424c628242ad678 100644 (file)
@@ -1,17 +1,28 @@
 <?php
-$body = ob_get_clean();
+$body = getoutput(@$Place);
 
-include_once DOCROOT.'head.inc.php';
+include_once 'head.inc.php';
 
 print "<header>\n";
 ob_start();
-include DOCROOT.'menu.html';
+include 'menu.html';
 ob_start();
-if (isset($User)) {
+if (!empty($User)) {
        print '<div class="login"><p>';
-       printf('<span>Ingelogd: <b>%s</b></span>', $User['name']);
-       if ($User['admin']) {
-               print ' <a href="#edit">Wijzig</a>';
+       printf('<span>Ingelogd: <b><a href="%s">%s</a></b></span>', '/login', $User['name']);
+       if (!empty($User['admin'])) {
+               $editpage = $Page.$Args;
+               if (is_dir($editpage)) {
+                       if (file_exists("$editpage/index.html")) {
+                               $editpage .= '/index.html';
+                       }
+               }
+               else {
+                       $editpage .= '.html';
+               }
+               if (!file_exists($editpage) or is_writable($editpage)) {
+                       print ' <a href="#edit">Wijzig</a>';
+               }
        }
        print "</p></div>\n";
 }
@@ -22,7 +33,7 @@ $nav = preg_replace_callback('{<a href="([^"]+)">(.*?)</a>}', function ($m) {
        $html = $request == $m[1] ? $m[2] : $m[0]; # text or full link
        return $m[1] == substr($request, 0, strlen($m[1])) ? "<b>$html</b>" : $html;
 }, $nav);
-if (isset($User)) {
+if (!empty($User)) {
        $nav = preg_replace('{\s*<li class="logout">.*?</li>}', '', $nav);
 }
 else {
@@ -35,13 +46,17 @@ print $body;
 
 register_shutdown_function(function () {
        print '<footer>';
-       @include DOCROOT.'footer.html';
+       @include 'footer.html';
        print "</footer>\n";
 
        global $User;
-       if (isset($User) and $User['admin']) {
-               print '<script src="//cdn.ckeditor.com/4.7.3/full-all/ckeditor.js"></script>'."\n";
-               print '<script src="/edit.js"></script>'."\n";
+       if (!empty($User['admin'])) {
+               $ckesrc = '/lib/ckeditor'; # local install
+               if (!file_exists(DOCROOT . $ckesrc)) {
+                       $ckesrc = '//cdn.ckeditor.com/4.7.3/full-all'; # remote fallback
+               }
+               printf('<script src="%s"></script>'."\n", "$ckesrc/ckeditor.js");
+               print '<script src="/edit/page.js"></script>'."\n";
        }
 
        print "</body></html>\n";