mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 03:44:26 +02:00
- bugfix allow array definitions as modifier parameter
- bugfix observe compile_check property when loading config files - added the template object as third filter parameter
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
|
29/03/2010
|
||||||
|
- bugfix allow array definitions as modifier parameter
|
||||||
|
- bugfix observe compile_check property when loading config files
|
||||||
|
- added the template object as third filter parameter
|
||||||
|
|
||||||
25/03/2010
|
25/03/2010
|
||||||
- change of utility->compileAllTemplates() log messages
|
- change of utility->compileAllTemplates() log messages
|
||||||
- bugfix on nocache code in {function} tags
|
- bugfix on nocache code in {function} tags
|
||||||
- new methode utility->compileAllConfig() to compile all config files
|
- new method utility->compileAllConfig() to compile all config files
|
||||||
|
|
||||||
24/03/2010
|
24/03/2010
|
||||||
- bugfix on register->modifier() error messages
|
- bugfix on register->modifier() error messages
|
||||||
|
@@ -329,7 +329,7 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
}
|
}
|
||||||
// return redered template
|
// return redered template
|
||||||
if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) {
|
if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) {
|
||||||
$_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this);
|
$_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this, $_template);
|
||||||
} else {
|
} else {
|
||||||
$_output = $_template->getRenderedTemplate();
|
$_output = $_template->getRenderedTemplate();
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
// display value
|
// display value
|
||||||
$this->compiler->has_output = true;
|
$this->compiler->has_output = true;
|
||||||
if (isset($this->compiler->smarty->registered_filters['variable'])) {
|
if (isset($this->compiler->smarty->registered_filters['variable'])) {
|
||||||
$output = '<?php echo Smarty_Internal_Filter_Handler::runFilter(\'variable\', ' . $_attr['value'] . ',$this->smarty, ' . $_attr['filter'] . ');?>';
|
$output = '<?php echo Smarty_Internal_Filter_Handler::runFilter(\'variable\', ' . $_attr['value'] . ',$_smarty_tpl->smarty, $_smarty_tpl, ' . $_attr['filter'] . ');?>';
|
||||||
} else {
|
} else {
|
||||||
$output = '<?php echo ' . $_attr['value'] . ';?>';
|
$output = '<?php echo ' . $_attr['value'] . ';?>';
|
||||||
}
|
}
|
||||||
|
@@ -172,7 +172,7 @@ class Smarty_Internal_Config {
|
|||||||
public function mustCompile ()
|
public function mustCompile ()
|
||||||
{
|
{
|
||||||
return $this->mustCompile === null ?
|
return $this->mustCompile === null ?
|
||||||
$this->mustCompile = ($this->smarty->force_compile || $this->getCompiledTimestamp () !== $this->getTimestamp ()):
|
$this->mustCompile = ($this->smarty->force_compile || $this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTimestamp ()):
|
||||||
$this->mustCompile;
|
$this->mustCompile;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@@ -49,10 +49,10 @@ class Smarty_Internal_Config_File_Compiler {
|
|||||||
// init the lexer/parser to compile the config file
|
// init the lexer/parser to compile the config file
|
||||||
$lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty);
|
$lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty);
|
||||||
$parser = new Smarty_Internal_Configfileparser($lex, $this);
|
$parser = new Smarty_Internal_Configfileparser($lex, $this);
|
||||||
// $parser->PrintTrace();
|
if (isset($this->smarty->_parserdebug)) $parser->PrintTrace();
|
||||||
// get tokens from lexer and parse them
|
// get tokens from lexer and parse them
|
||||||
while ($lex->yylex()) {
|
while ($lex->yylex()) {
|
||||||
// echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
|
if (isset($this->smarty->_parserdebug)) echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
|
||||||
$parser->doParse($lex->token, $lex->value);
|
$parser->doParse($lex->token, $lex->value);
|
||||||
}
|
}
|
||||||
// finish parsing process
|
// finish parsing process
|
||||||
@@ -110,7 +110,6 @@ class Smarty_Internal_Config_File_Compiler {
|
|||||||
// set error flag
|
// set error flag
|
||||||
$this->compile_error = true;
|
$this->compile_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -26,7 +26,7 @@ class Smarty_Internal_Filter_Handler {
|
|||||||
* @param string $content the content which shall be processed by the filters
|
* @param string $content the content which shall be processed by the filters
|
||||||
* @return string the filtered content
|
* @return string the filtered content
|
||||||
*/
|
*/
|
||||||
static function runFilter($type, $content, $smarty, $flag = null)
|
static function runFilter($type, $content, $smarty, $template, $flag = null)
|
||||||
{
|
{
|
||||||
$output = $content;
|
$output = $content;
|
||||||
if ($type != 'variable' || ($smarty->variable_filter && $flag !== false) || $flag === true) {
|
if ($type != 'variable' || ($smarty->variable_filter && $flag !== false) || $flag === true) {
|
||||||
@@ -40,7 +40,7 @@ class Smarty_Internal_Filter_Handler {
|
|||||||
$output = $plugin_name($output, $smarty);
|
$output = $plugin_name($output, $smarty);
|
||||||
} elseif (class_exists($plugin_name, false)) {
|
} elseif (class_exists($plugin_name, false)) {
|
||||||
// loaded class of filter plugin
|
// loaded class of filter plugin
|
||||||
$output = call_user_func(array($plugin_name, 'execute'), $output, $smarty);
|
$output = call_user_func(array($plugin_name, 'execute'), $output, $smarty, $template);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// nothing found, throw exception
|
// nothing found, throw exception
|
||||||
@@ -52,9 +52,9 @@ class Smarty_Internal_Filter_Handler {
|
|||||||
if (!empty($smarty->registered_filters[$type])) {
|
if (!empty($smarty->registered_filters[$type])) {
|
||||||
foreach ($smarty->registered_filters[$type] as $key => $name) {
|
foreach ($smarty->registered_filters[$type] as $key => $name) {
|
||||||
if (is_array($smarty->registered_filters[$type][$key])) {
|
if (is_array($smarty->registered_filters[$type][$key])) {
|
||||||
$output = call_user_func($smarty->registered_filters[$type][$key], $output, $smarty);
|
$output = call_user_func($smarty->registered_filters[$type][$key], $output, $smarty, $template);
|
||||||
} else {
|
} else {
|
||||||
$output = $smarty->registered_filters[$type][$key]($output, $smarty);
|
$output = $smarty->registered_filters[$type][$key]($output, $smarty, $template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
$_content = $template->getTemplateSource();
|
$_content = $template->getTemplateSource();
|
||||||
// run prefilter if required
|
// run prefilter if required
|
||||||
if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
|
if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
|
||||||
$_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $this->smarty);
|
$_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $this->smarty, $template);
|
||||||
}
|
}
|
||||||
// on empty template just return header
|
// on empty template just return header
|
||||||
if ($_content == '') {
|
if ($_content == '') {
|
||||||
@@ -92,7 +92,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
}
|
}
|
||||||
// run postfilter if required
|
// run postfilter if required
|
||||||
if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
|
if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
|
||||||
$template->compiled_template = Smarty_Internal_Filter_Handler::runFilter('post', $template->compiled_template, $this->smarty);
|
$template->compiled_template = Smarty_Internal_Filter_Handler::runFilter('post', $template->compiled_template, $this->smarty, $template);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -51,12 +51,6 @@ class Smarty_Internal_Utility {
|
|||||||
*/
|
*/
|
||||||
function compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
function compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||||
{
|
{
|
||||||
function _get_time()
|
|
||||||
{
|
|
||||||
$_mtime = microtime();
|
|
||||||
$_mtime = explode(" ", $_mtime);
|
|
||||||
return (double)($_mtime[1]) + (double)($_mtime[0]);
|
|
||||||
}
|
|
||||||
// switch off time limit
|
// switch off time limit
|
||||||
if (function_exists('set_time_limit')) {
|
if (function_exists('set_time_limit')) {
|
||||||
@set_time_limit($time_limit);
|
@set_time_limit($time_limit);
|
||||||
@@ -79,12 +73,12 @@ class Smarty_Internal_Utility {
|
|||||||
}
|
}
|
||||||
echo '<br>', $_dir, '---', $_template_file;
|
echo '<br>', $_dir, '---', $_template_file;
|
||||||
flush();
|
flush();
|
||||||
$_start_time = _get_time();
|
$_start_time = $this->_get_time();
|
||||||
try {
|
try {
|
||||||
$_tpl = $this->smarty->createTemplate($_template_file);
|
$_tpl = $this->smarty->createTemplate($_template_file);
|
||||||
if ($_tpl->mustCompile()) {
|
if ($_tpl->mustCompile()) {
|
||||||
$_tpl->compileTemplateSource();
|
$_tpl->compileTemplateSource();
|
||||||
echo ' compiled in ', _get_time() - $_start_time, ' seconds';
|
echo ' compiled in ', $this->_get_time() - $_start_time, ' seconds';
|
||||||
flush();
|
flush();
|
||||||
} else {
|
} else {
|
||||||
echo ' is up to date';
|
echo ' is up to date';
|
||||||
@@ -137,12 +131,12 @@ class Smarty_Internal_Utility {
|
|||||||
}
|
}
|
||||||
echo '<br>', $_dir, '---', $_config_file;
|
echo '<br>', $_dir, '---', $_config_file;
|
||||||
flush();
|
flush();
|
||||||
$_start_time = _get_time();
|
$_start_time = $this->_get_time();
|
||||||
try {
|
try {
|
||||||
$_config = new Smarty_Internal_Config($_config_file, $this->smarty);
|
$_config = new Smarty_Internal_Config($_config_file, $this->smarty);
|
||||||
if ($_config->mustCompile()) {
|
if ($_config->mustCompile()) {
|
||||||
$_config->compileConfigSource();
|
$_config->compileConfigSource();
|
||||||
echo ' compiled in ', _get_time() - $_start_time, ' seconds';
|
echo ' compiled in ', $this->_get_time() - $_start_time, ' seconds';
|
||||||
flush();
|
flush();
|
||||||
} else {
|
} else {
|
||||||
echo ' is up to date';
|
echo ' is up to date';
|
||||||
@@ -279,4 +273,15 @@ class Smarty_Internal_Utility {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Get Micro Time
|
||||||
|
*
|
||||||
|
* @return double micro time
|
||||||
|
*/
|
||||||
|
function _get_time()
|
||||||
|
{
|
||||||
|
$_mtime = microtime();
|
||||||
|
$_mtime = explode(" ", $_mtime);
|
||||||
|
return (double)($_mtime[1]) + (double)($_mtime[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user