1
0

proof-of-concept .js.tpl: Added fallback for serendipity_editor.js.tpl as serendipity_editor.js to default-template, and changed serendipity_get_file to react to .js.tpl-files in template-directories

This commit is contained in:
onli
2013-03-06 14:55:21 +01:00
parent e1526d87b8
commit 0cd974fa6d
6 changed files with 28 additions and 38 deletions

View File

@ -103,9 +103,10 @@ function serendipity_plugin_api_pre_event_hook($event, &$bag, &$eventData, &$add
// Check what Event is coming in, only react to those we want.
switch($event) {
case 'external_plugin':
echo $eventData;
switch ($eventData) {
case 'serendipity_editor.js':
smarty_show('serendipity_editor.js.tpl');
case 'admin/serendipity_editor.js':
serendipity_smarty_show('admin/serendipity_editor.js.tpl');
break;
}
return true;
@ -113,31 +114,5 @@ function serendipity_plugin_api_pre_event_hook($event, &$bag, &$eventData, &$add
}
}
/* Render a smarty-template
* $template: path to the template-file
* $data: map with the variables to assign
* */
function smarty_show($template, $data = null) {
global $serendipity;
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$serendipity['smarty']->assign($data);
$tfile = serendipity_getTemplateFile($template, 'serendipityPath');
if ($tfile == $template) {
$tfile = dirname(__FILE__) . "/$template";
}
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
$content = $serendipity['smarty']->fetch('file:'. $tfile);
$serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
echo $content;
}
//echo "registering link to js-handler";
//serendipity_registerHandler(dirname(__FILE__). '/test.php', 'test.js');