diff --git a/include/plugin_api.inc.php b/include/plugin_api.inc.php
index e852dbbf..17fedcb5 100644
--- a/include/plugin_api.inc.php
+++ b/include/plugin_api.inc.php
@@ -52,6 +52,89 @@ function serendipity_plugin_api_backend_header($event_name, &$bag, &$eventData,
}
}
+// Add backend core (pre) hooks
+function serendipity_plugin_api_core_event_hook($event, &$bag, &$eventData, &$addData) {
+ global $serendipity;
+
+ switch($event) {
+ case 'external_plugin':
+ switch ($eventData) {
+ case 'admin/serendipity_editor.js':
+ header('Content-Type: application/javascript');
+ $data = array('token_url' => serendipity_setFormToken("url"));
+ echo serendipity_smarty_show('admin/serendipity_editor.js.tpl', $data);
+ break;
+ }
+ break;
+
+ case 'js':
+ // This is frontend and backend!
+ // Add a global available (index.tpl; admin/index.tpl; preview_iframe.tpl) redirect error string function used by errorToExceptionHandler()
+ // hardened by admin only - better have that here, to be reachable everywhere
+ if( $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN ) {
+ echo "
+function create(htmlStr) {
+ var frag = document.createDocumentFragment(),
+ temp = document.createElement('div');
+ temp.innerHTML = htmlStr;
+ while (temp.firstChild) {
+ frag.appendChild(temp.firstChild);
+ }
+ return frag;
+} \n";
+ }
+ break;
+
+ case 'backend_wysiwyg':
+ if (preg_match('@^nugget@i', $eventData['item'])) {
+ // switch to wysiwyg finisher directly, in case of nuggets
+ serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $bag, $eventData);
+ } else {
+ // this only builds textareas of normal entry forms, the possible button data will be passed to 'backend_footer' via serendipity_emit_htmlarea_code() function
+ if (isset($eventData['item']) && !empty($eventData['item'])) {
+?>
+
+
+
+
+
+
+
+ true);
$template_loaded_config = serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option'], true);
serendipity_loadGlobalThemeOptions($template_config, $template_loaded_config, $template_global_config);
-/**
- * This adds the possibility for templates to register a central function
- * serendipity_plugin_api_event_hook() and
- * serendipity_plugin_api_pre_event_hook() that can be used to
- * use plugin API interaction WITHOUT actual plugins. So special
- * plugins can be bundled within a template, without the need to
- * seperately install them. The "pre" function is called BEFORE
- * all normal plugins are executed, the normal function is called
- * AFTER plugin execution.
- *
- * In here we use it to parse and compile serendipity_editor.js.tpl
- * and to populate serendipity.js via the new 'js' plugin hook for the frontend.
- * The bundled core JS editor - CKEDITOR - will read pre set plugin evenData in some backend hooks
- */
function serendipity_plugin_api_pre_event_hook($event, &$bag, &$eventData, &$addData) {
- global $serendipity;
// Check what Event is coming in, only react to those we want.
switch($event) {
- case 'external_plugin':
- switch ($eventData) {
- case 'admin/serendipity_editor.js':
- header('Content-Type: application/javascript');
- $data = array('token_url' => serendipity_setFormToken("url"));
- echo serendipity_smarty_show('admin/serendipity_editor.js.tpl', $data);
- break;
- }
- break;
-
case 'js':
- // This is frontend and backend!
- // add a global available (index.tpl; admin/index.tpl; preview_iframe.tpl) redirect error string function used by errorToExceptionHandler()
- // hardened by admin only - better have that here, to be reachable everywhere
- if( $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN ) {
- echo "
-function create(htmlStr) {
- var frag = document.createDocumentFragment(),
- temp = document.createElement('div');
- temp.innerHTML = htmlStr;
- while (temp.firstChild) {
- frag.appendChild(temp.firstChild);
- }
- return frag;
-} \n";
- }
- // always add \n\n to the end of last element, in case of plugins using this hook and
+ // always add newlines to the end of last element, in case of other plugins using this hook and
// always start at line Col 1, to populate the (virtual) serendipity.js file
echo "
jQuery(function() {
@@ -161,51 +121,6 @@ jQuery(function() {
})\n\n";
break;
- case 'backend_wysiwyg':
- if (preg_match('@^nugget@i', $eventData['item'])) {
- // switch to wysiwyg finisher directly, in case of nuggets
- serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $bag, $eventData);
- } else {
- // this only builds textareas of normal entry forms, the possible button data will be passed to 'backend_footer' via serendipity_emit_htmlarea_code() function
- if (isset($eventData['item']) && !empty($eventData['item'])) {
-?>
-
-
-
-
-
-
-
-