added serendipity_smart_show-function to core, as it was used in multiple places like plugins and templates
This commit is contained in:
@@ -1020,8 +1020,8 @@ function serendipity_smarty_init($vars = array()) {
|
|||||||
|
|
||||||
// For advanced usage, we allow template authors to create a file 'config.inc.php' where they can
|
// For advanced usage, we allow template authors to create a file 'config.inc.php' where they can
|
||||||
// setup custom smarty variables, modifiers etc. to use in their templates.
|
// setup custom smarty variables, modifiers etc. to use in their templates.
|
||||||
@include_once $serendipity['smarty']->getConfigDir(0) . '/config.inc.php';
|
include_once $serendipity['smarty']->getConfigDir(0) . '/config.inc.php';
|
||||||
|
|
||||||
if (is_array($template_loaded_config)) {
|
if (is_array($template_loaded_config)) {
|
||||||
$template_vars =& $template_loaded_config;
|
$template_vars =& $template_loaded_config;
|
||||||
$serendipity['smarty']->assignByRef('template_option', $template_vars);
|
$serendipity['smarty']->assignByRef('template_option', $template_vars);
|
||||||
@@ -1084,3 +1084,29 @@ function serendipity_smarty_shutdown($serendipity_directory = '') {
|
|||||||
}
|
}
|
||||||
$serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
|
$serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Render a smarty-template
|
||||||
|
* $template: path to the template-file
|
||||||
|
* $data: map with the variables to assign
|
||||||
|
* */
|
||||||
|
function serendipity_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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user