nieuws: blockquote containers around replies
[minimedit.git] / page.inc.php
1 <?php
2 $body = getoutput(@$Place);
3
4 include_once 'head.inc.php';
5
6 print "<header>\n";
7 ob_start();
8 include 'menu.html';
9 ob_start();
10 if (!empty($User)) {
11         print '<div class="login"><p>';
12         printf('<span>Ingelogd: <b><a href="%s">%s</a></b></span>', '/login', $User['name']);
13         if (!empty($User['admin'])) {
14                 $editpage = $Page.$Args;
15                 if (is_dir($editpage)) {
16                         if (file_exists("$editpage/index.html")) {
17                                 $editpage .= '/index.html';
18                         }
19                 }
20                 else {
21                         $editpage .= '.html';
22                 }
23                 if (!file_exists($editpage) or is_writable($editpage)) {
24                         print ' <a href="#edit">Wijzig</a>';
25                 }
26         }
27         print "</p></div>\n";
28 }
29 $nav = getoutput(['login' => ob_get_clean()]);
30
31 $nav = preg_replace_callback('{<a href="([^"]+)">(.*?)</a>}', function ($m) {
32         $request = $_SERVER['REQUEST_URI'];
33         $html = $request == $m[1] ? $m[2] : $m[0]; # text or full link
34         return $m[1] == substr($request, 0, strlen($m[1])) ? "<b>$html</b>" : $html;
35 }, $nav);
36 if (!empty($User)) {
37         $nav = preg_replace('{\s*<li class="logout">.*?</li>}', '', $nav);
38 }
39 else {
40         $nav = preg_replace('{\s*<li class="login">.*?</li>}', '', $nav);
41 }
42 print $nav;
43 print "</header>\n\n";
44
45 print $body;
46
47 register_shutdown_function(function () {
48         print '<footer>';
49         @include 'footer.html';
50         print "</footer>\n";
51
52         global $User;
53         if (!empty($User['admin'])) {
54                 $ckesrc = '/lib/ckeditor'; # local install
55                 if (!file_exists(DOCROOT . $ckesrc)) {
56                         $ckesrc = '//cdn.ckeditor.com/4.7.3/full-all'; # remote fallback
57                 }
58                 printf('<script src="%s"></script>'."\n", "$ckesrc/ckeditor.js");
59                 print '<script src="/edit/page.js"></script>'."\n";
60         }
61
62         print "</body></html>\n";
63 });
64