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:
parent
e1526d87b8
commit
0cd974fa6d
@ -10,7 +10,7 @@
|
|||||||
var view_full = '{$CONST.VIEW_FULL}';
|
var view_full = '{$CONST.VIEW_FULL}';
|
||||||
var view_hide = '{$CONST.HIDE}';
|
var view_hide = '{$CONST.HIDE}';
|
||||||
</script>
|
</script>
|
||||||
<script src="{$serendipityBaseURL}index.php?/plugin/serendipity_editor.js"></script>
|
<script src="{serendipity_getFile file='admin/serendipity_editor.js'}"></script>
|
||||||
|
|
||||||
<h2>{$CONST.COMMENTS}</h2>
|
<h2>{$CONST.COMMENTS}</h2>
|
||||||
|
|
||||||
|
@ -282,6 +282,11 @@ function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath') {
|
|||||||
if (file_exists($serendipity['serendipityPath'] . $templateFile)) {
|
if (file_exists($serendipity['serendipityPath'] . $templateFile)) {
|
||||||
return $serendipity[$key] . $templateFile;
|
return $serendipity[$key] . $templateFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_exists($serendipity['serendipityPath'] . $templateFile . ".tpl")) {
|
||||||
|
# catch .js.tpl files served via the template-plugin-api
|
||||||
|
return $serendipity['baseURL'] . 'index.php?/plugin/' . $file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('@\.(tpl|css|php)@i', $file) && !stristr($file, 'plugin')) {
|
if (preg_match('@\.(tpl|css|php)@i', $file) && !stristr($file, 'plugin')) {
|
||||||
@ -2246,4 +2251,14 @@ function serendipity_passwordhash($cleartext_password) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//function serendipity_registerHandler($handler, $link) {
|
||||||
|
//global $serendipity;
|
||||||
|
//
|
||||||
|
//if ( ! is_array($serendipity["handler"])) {
|
||||||
|
//$serendipity["handler"] = array();
|
||||||
|
//}
|
||||||
|
//$serendipity["handler"][$link] = $handler;
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
/* vim: set sts=4 ts=4 expandtab : */
|
/* vim: set sts=4 ts=4 expandtab : */
|
||||||
|
18
index.php
18
index.php
@ -363,6 +363,15 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
|
|||||||
|
|
||||||
print $data;
|
print $data;
|
||||||
exit;
|
exit;
|
||||||
|
} else if (preg_match(PAT_PLUGIN, $uri, $matches)) {
|
||||||
|
$serendipity['view'] = 'plugin';
|
||||||
|
include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
|
||||||
|
|
||||||
|
#echo $serendipity["handler"]["test.js"];
|
||||||
|
serendipity_plugin_api::hook_event('external_plugin', $matches[2]);
|
||||||
|
if (!defined('NO_EXIT')) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
} else if (preg_match(PAT_ADMIN, $uri)) {
|
} else if (preg_match(PAT_ADMIN, $uri)) {
|
||||||
$serendipity['view'] = 'admin';
|
$serendipity['view'] = 'admin';
|
||||||
$base = $serendipity['baseURL'];
|
$base = $serendipity['baseURL'];
|
||||||
@ -398,15 +407,6 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
|
|||||||
}
|
}
|
||||||
|
|
||||||
include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
|
include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
|
||||||
} else if (preg_match(PAT_PLUGIN, $uri, $matches)) {
|
|
||||||
$serendipity['view'] = 'plugin';
|
|
||||||
include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
|
|
||||||
|
|
||||||
#echo $serendipity["handler"]["test.js"];
|
|
||||||
serendipity_plugin_api::hook_event('external_plugin', $matches[2]);
|
|
||||||
if (!defined('NO_EXIT')) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
} else if ($is_multicat || preg_match(PAT_PERMALINK_CATEGORIES, $uri, $matches)) {
|
} else if ($is_multicat || preg_match(PAT_PERMALINK_CATEGORIES, $uri, $matches)) {
|
||||||
$serendipity['view'] = 'categories';
|
$serendipity['view'] = 'categories';
|
||||||
|
|
||||||
|
@ -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.
|
// Check what Event is coming in, only react to those we want.
|
||||||
switch($event) {
|
switch($event) {
|
||||||
case 'external_plugin':
|
case 'external_plugin':
|
||||||
|
echo $eventData;
|
||||||
switch ($eventData) {
|
switch ($eventData) {
|
||||||
case 'serendipity_editor.js':
|
case 'admin/serendipity_editor.js':
|
||||||
smarty_show('serendipity_editor.js.tpl');
|
serendipity_smarty_show('admin/serendipity_editor.js.tpl');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
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";
|
//echo "registering link to js-handler";
|
||||||
//serendipity_registerHandler(dirname(__FILE__). '/test.php', 'test.js');
|
//serendipity_registerHandler(dirname(__FILE__). '/test.php', 'test.js');
|
Loading…
x
Reference in New Issue
Block a user