login/pass: error messages below page title
[minimedit.git] / page.inc.php
index 654f37fa7ebeee2a412b2348fc3bab61d1ac4d88..23a7106c1d470e1705d6d830a263b8802c84c5d0 100644 (file)
@@ -1,41 +1,32 @@
 <?php
-$body = ob_get_clean();
-
-include_once './head.inc.php';
+include_once 'head.inc.php';
 
 print "<header>\n";
+$menu = new ArchiveArticle('menu.inc.html');
 ob_start();
-include './menu.html';
-$nav = ob_get_clean();
+if ($User and property_exists($User, 'login') and $User->login) {
+       print '<div class="login"><p>';
+       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";
+}
+$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 (isset($User)) {
-       $nav = preg_replace('{\s*<li class="logout">.*?</li>}', '', $nav);
-       $nav = str_replace('[[login]]', $User['name'], $nav);
-}
-else {
-       $nav = preg_replace('{\s*<li class="login">.*?</li>}', '', $nav);
-}
 print $nav;
 print "</header>\n\n";
 
-print $body;
-
-$footinc = realpath('footer.html'); # cwd lost during shutdown
 register_shutdown_function(function () {
        print '<footer>';
-       @include $GLOBALS['footinc'];
+       @include 'footer.inc.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";
-       }
-
        print "</body></html>\n";
 });