From: garvinhicking Date: Thu, 19 May 2005 08:40:00 +0000 (+0000) Subject: Drop our $CONST method and use $smarty.const. in a BC-compatible way instead. X-Git-Tag: 0.9~456 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=881bd8fd5fc4a24db87ab85469c314f10d730bb7;p=s9y.git Drop our $CONST method and use $smarty.const. in a BC-compatible way instead. Feels faster. ;) --- diff --git a/docs/NEWS b/docs/NEWS index d2fda82..1a0e5fb 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,11 @@ Version 0.9 () ------------------------------------------------------------------------ + * Use $smarty.const. to access constants instead of $CONST within + Smarty templates; this is replaced using a Smarty prefilter, so + that within templates you can still use the $CONST shortcut + (garvinhicking) + * Pagination of plugins to install to save memory allocation if many plugins are downloaded (garvinhicking) diff --git a/include/functions_smarty.inc.php b/include/functions_smarty.inc.php index 3ac2fc0..d17f307 100644 --- a/include/functions_smarty.inc.php +++ b/include/functions_smarty.inc.php @@ -126,6 +126,10 @@ function serendipity_smarty_printTrackbacks($params, &$smarty) { return serendipity_printTrackbacks(serendipity_fetchTrackbacks($params['entry'])); } +function &serendipity_replaceSmartyVars(&$tpl_source, $smarty) { + return str_replace('$CONST.', '$smarty.const.', $tpl_source); +} + function serendipity_smarty_init() { global $serendipity; @@ -141,7 +145,8 @@ function serendipity_smarty_init() { $serendipity['smarty']->compile_dir = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE; $serendipity['smarty']->config_dir = &$serendipity['smarty']->template_dir; $serendipity['smarty']->secure_dir = array($serendipity['serendipityPath'] . $serendipity['templatePath']); - $serendipity['smarty']->security_settings['MODIFIER_FUNCS'] = array('sprintf', 'sizeof', 'count', 'rand'); + $serendipity['smarty']->security_settings['MODIFIER_FUNCS'] = array('sprintf', 'sizeof', 'count', 'rand'); + $serendipity['smarty']->security_settings['ALLOW_CONSTANTS'] = true; $serendipity['smarty']->security = true; $serendipity['smarty']->use_sub_dirs = false; $serendipity['smarty']->compile_check = true; @@ -157,6 +162,7 @@ function serendipity_smarty_init() { $serendipity['smarty']->register_function('serendipity_getFile', 'serendipity_smarty_getFile'); $serendipity['smarty']->register_function('serendipity_printComments', 'serendipity_smarty_printComments'); $serendipity['smarty']->register_function('serendipity_printTrackbacks', 'serendipity_smarty_printTrackbacks'); + $serendipity['smarty']->register_prefilter('serendipity_replaceSmartyVars'); } if (!isset($serendipity['smarty_raw_mode'])) { diff --git a/templates/kubrick/config.inc.php b/templates/kubrick/config.inc.php index 9bd5030..091e22c 100644 --- a/templates/kubrick/config.inc.php +++ b/templates/kubrick/config.inc.php @@ -7,5 +7,4 @@ if (file_exists($probelang)) { include dirname(__FILE__) . '/lang_en.inc.php'; } -$serendipity['smarty']->assign('CONST', get_defined_constants()); ?> \ No newline at end of file