From 88503d06a82643f27d3df1422b07a05a6e1fdeee Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 7 Dec 2020 15:23:49 +0100 Subject: [PATCH] head: load edit script before body Introduce $Page->head for html head output. Allows editor setup before running other javascript. --- head.inc.php | 1 + page.inc.php | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/head.inc.php b/head.inc.php index 4082b92..9ff6495 100644 --- a/head.inc.php +++ b/head.inc.php @@ -15,5 +15,6 @@ +head)) print $Page->head; ?> diff --git a/page.inc.php b/page.inc.php index 8eba91b..17e7c80 100644 --- a/page.inc.php +++ b/page.inc.php @@ -1,4 +1,15 @@ admin("edit {$Page->link}")) { + $ckesrc = '/lib/ckeditor'; # local install + if (!file_exists(DOCROOT . $ckesrc)) { + $ckesrc = '//cdn.ckeditor.com/4.15.1/full-all'; # remote fallback + } + ob_start(); + printf("\n", "$ckesrc/ckeditor.js"); + print ''."\n"; + $Page->head = ob_get_clean(); +} + include_once 'head.inc.php'; print "
\n"; @@ -43,17 +54,6 @@ register_shutdown_function(function () { print '
'; @include 'footer.inc.html'; print "
\n"; - - global $User, $Page; - if ($User and $User->admin("edit {$Page->link}")) { - $ckesrc = '/lib/ckeditor'; # local install - if (!file_exists(DOCROOT . $ckesrc)) { - $ckesrc = '//cdn.ckeditor.com/4.15.1/full-all'; # remote fallback - } - printf("\n", "$ckesrc/ckeditor.js"); - print ''."\n"; - } - print "\n"; }); -- 2.30.0