edit/head: move admin preparation to separate include
[minimedit.git] / edit / head.inc.php
1 <?php
2 if (!isset($Page->raw)) {
3         # open bottom template as initial contents
4         $template = 'template.inc.html';
5         if ($Page->handler and file_exists("{$Page->handler}/$template")) {
6                 $template = "{$Page->handler}/$template";
7         }
8         $Page->raw($template);
9         $Page->meta['article:published_time'] = date('Y-m-d h:i:s O');
10         $Page->meta['article:author'] = '/' . $User->dir;
11         $Page->body = NULL;
12 }
13
14 if (isset($Page->raw)) {
15         # restore meta tags in static contents for editing
16         foreach (array_reverse($Page->meta) as $metaprop => $val) {
17                 $Page->raw = sprintf(
18                         '<meta property="%s" content="%s">'."\n",
19                         $metaprop, $val
20                 ) . $Page->raw;
21         }
22 }
23
24 $ckesrc = '/lib/ckeditor'; # local install
25 if (!file_exists(DOCROOT . $ckesrc)) {
26         $ckesrc = '//cdn.ckeditor.com/4.15.1/full-all'; # remote fallback
27 }
28 ob_start();
29 printf("<script>var ckesrc = '%s'</script>\n", "$ckesrc/ckeditor.js");
30 print '<script src="/edit/page.js"></script>'."\n";
31 $Page->head = ob_get_clean();
32