login/pass: error messages below page title
[minimedit.git] / page.inc.php
index 80f773d30f0395fc40d4411c78d9e85d9e5dc10a..23a7106c1d470e1705d6d830a263b8802c84c5d0 100644 (file)
@@ -1,60 +1,32 @@
 <?php
-$body = getoutput(@$Place);
-
 include_once 'head.inc.php';
 
 print "<header>\n";
+$menu = new ArchiveArticle('menu.inc.html');
 ob_start();
-include 'menu.html';
-ob_start();
-if (!empty($User)) {
+if ($User and property_exists($User, 'login') and $User->login) {
        print '<div class="login"><p>';
-       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>';
-               }
-       }
+       printf('<span title="ingelogd">%s <a href="%s">%s</a></span>',
+               '<span class="icon icon-user">&#x1F464;</span>',
+               '/login', $User->login
+       );
        print "</p></div>\n";
 }
-$nav = getoutput(['login' => ob_get_clean()]);
+$menu->place['login'] = ob_get_clean();
+$nav = $menu->render();
 
 $nav = preg_replace_callback('{<a href="([^"]+)">(.*?)</a>}', function ($m) {
        $request = $_SERVER['REQUEST_URI'];
        $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 (!empty($User)) {
-       $nav = preg_replace('{\s*<li class="logout">.*?</li>}', '', $nav);
-}
-else {
-       $nav = preg_replace('{\s*<li class="login">.*?</li>}', '', $nav);
-}
 print $nav;
 print "</header>\n\n";
 
-print $body;
-
 register_shutdown_function(function () {
        print '<footer>';
-       @include 'footer.html';
+       @include 'footer.inc.html';
        print "</footer>\n";
-
-       global $User;
-       if (!empty($User['admin'])) {
-               print '<script src="//cdn.ckeditor.com/4.7.3/full-all/ckeditor.js"></script>'."\n";
-               print '<script src="/edit.js"></script>'."\n";
-       }
-
        print "</body></html>\n";
 });