page: replace links to current page in menu include
[minimedit.git] / head.inc.php
1 <?php
2 include_once 'head.inc.html';
3
4 print "<header>\n";
5
6 ob_start();
7 include 'menu.html';
8 $nav = ob_get_clean();
9 $nav = preg_replace_callback('{<a href="([^"]+)">(.*?)</a>}', function ($m) {
10         $request = $_SERVER['REQUEST_URI'];
11         $html = $request == $m[1] ? $m[2] : $m[0]; # text or full link
12         return $m[1] == substr($request, 0, strlen($m[1])) ? "<b>$html</b>" : $html;
13 }, $nav);
14 print $nav;
15 print "</header>\n\n";
16
17 print '<div class="article">'."\n\n";
18
19 include_once 'auth.inc.php';
20
21 register_shutdown_function(function () {
22         print "</div>\n\n";
23         include 'foot.inc.php';
24         print "</body></html>\n";
25 });
26
27 include "$Page.html";
28 if (file_exists("$Page.php")) include_once("$Page.php");
29