- 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:
Uwe.Tews
2010-03-29 15:41:01 +00:00
parent 76f1bd5428
commit 24d5ad78f3
9 changed files with 1068 additions and 953 deletions

View File

@@ -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
- change of utility->compileAllTemplates() log messages
- 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
- bugfix on register->modifier() error messages

View File

@@ -329,7 +329,7 @@ class Smarty extends Smarty_Internal_Data {
}
// return redered template
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 {
$_output = $_template->getRenderedTemplate();
}

View File

@@ -49,7 +49,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
// display value
$this->compiler->has_output = true;
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 {
$output = '<?php echo ' . $_attr['value'] . ';?>';
}

View File

@@ -1,14 +1,14 @@
<?php
/**
* Smarty Internal Plugin Config
*
* Main class for config variables
*
* @ignore
* @package Smarty
* @subpackage Config
* @author Uwe Tews
*/
* Smarty Internal Plugin Config
*
* Main class for config variables
*
* @ignore
* @package Smarty
* @subpackage Config
* @author Uwe Tews
*/
class Smarty_Internal_Config {
static $config_objects = array();
@@ -172,7 +172,7 @@ class Smarty_Internal_Config {
public function mustCompile ()
{
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;
}
/**
@@ -255,6 +255,6 @@ class Smarty_Internal_Config {
}
}
}
}
}
?>
?>

View File

@@ -1,20 +1,20 @@
<?php
/**
* Smarty Internal Plugin Config File Compiler
*
* This is the config file compiler class. It calls the lexer and parser to
* perform the compiling.
*
* @package Smarty
* @subpackage Config
* @author Uwe Tews
*/
* Smarty Internal Plugin Config File Compiler
*
* This is the config file compiler class. It calls the lexer and parser to
* perform the compiling.
*
* @package Smarty
* @subpackage Config
* @author Uwe Tews
*/
/**
* Main config file compiler class
*/
* Main config file compiler class
*/
class Smarty_Internal_Config_File_Compiler {
public $compile_error= false;
public $compile_error = false;
/**
* Initialize compiler
*/
@@ -41,7 +41,7 @@ class Smarty_Internal_Config_File_Compiler {
then written to compiled files. */
$this->config = $config;
// get config file source
$_content = $config->getConfigSource()."\n";
$_content = $config->getConfigSource() . "\n";
// on empty template just return
if ($_content == '') {
return true;
@@ -49,10 +49,10 @@ class Smarty_Internal_Config_File_Compiler {
// init the lexer/parser to compile the config file
$lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty);
$parser = new Smarty_Internal_Configfileparser($lex, $this);
// $parser->PrintTrace();
if (isset($this->smarty->_parserdebug)) $parser->PrintTrace();
// get tokens from lexer and parse them
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);
}
// finish parsing process
@@ -84,7 +84,7 @@ class Smarty_Internal_Config_File_Compiler {
// get template source line which has error
$line = $this->lex->line;
if (isset($args)) {
// $line--;
// $line--;
}
$match = preg_split("/\n/", $this->lex->data);
$error_text = "Syntax error in config file '{$this->config->getConfigFilepath()}' on line {$line} '{$match[$line-1]}' ";
@@ -110,7 +110,6 @@ class Smarty_Internal_Config_File_Compiler {
// set error flag
$this->compile_error = true;
}
}
?>

View File

@@ -26,7 +26,7 @@ class Smarty_Internal_Filter_Handler {
* @param string $content the content which shall be processed by the filters
* @return string the filtered content
*/
static function runFilter($type, $content, $smarty, $flag = null)
static function runFilter($type, $content, $smarty, $template, $flag = null)
{
$output = $content;
if ($type != 'variable' || ($smarty->variable_filter && $flag !== false) || $flag === true) {
@@ -40,7 +40,7 @@ class Smarty_Internal_Filter_Handler {
$output = $plugin_name($output, $smarty);
} elseif (class_exists($plugin_name, false)) {
// 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 {
// nothing found, throw exception
@@ -52,9 +52,9 @@ class Smarty_Internal_Filter_Handler {
if (!empty($smarty->registered_filters[$type])) {
foreach ($smarty->registered_filters[$type] as $key => $name) {
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 {
$output = $smarty->registered_filters[$type][$key]($output, $smarty);
$output = $smarty->registered_filters[$type][$key]($output, $smarty, $template);
}
}
}

View File

@@ -69,7 +69,7 @@ class Smarty_Internal_TemplateCompilerBase {
$_content = $template->getTemplateSource();
// run prefilter if required
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
if ($_content == '') {
@@ -92,7 +92,7 @@ class Smarty_Internal_TemplateCompilerBase {
}
// run postfilter if required
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;
} else {

File diff suppressed because it is too large Load Diff

View File

@@ -51,12 +51,6 @@ class Smarty_Internal_Utility {
*/
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
if (function_exists('set_time_limit')) {
@set_time_limit($time_limit);
@@ -79,12 +73,12 @@ class Smarty_Internal_Utility {
}
echo '<br>', $_dir, '---', $_template_file;
flush();
$_start_time = _get_time();
$_start_time = $this->_get_time();
try {
$_tpl = $this->smarty->createTemplate($_template_file);
if ($_tpl->mustCompile()) {
$_tpl->compileTemplateSource();
echo ' compiled in ', _get_time() - $_start_time, ' seconds';
echo ' compiled in ', $this->_get_time() - $_start_time, ' seconds';
flush();
} else {
echo ' is up to date';
@@ -137,12 +131,12 @@ class Smarty_Internal_Utility {
}
echo '<br>', $_dir, '---', $_config_file;
flush();
$_start_time = _get_time();
$_start_time = $this->_get_time();
try {
$_config = new Smarty_Internal_Config($_config_file, $this->smarty);
if ($_config->mustCompile()) {
$_config->compileConfigSource();
echo ' compiled in ', _get_time() - $_start_time, ' seconds';
echo ' compiled in ', $this->_get_time() - $_start_time, ' seconds';
flush();
} else {
echo ' is up to date';
@@ -279,4 +273,15 @@ class Smarty_Internal_Utility {
return true;
}
/**
* Get Micro Time
*
* @return double micro time
*/
function _get_time()
{
$_mtime = microtime();
$_mtime = explode(" ", $_mtime);
return (double)($_mtime[1]) + (double)($_mtime[0]);
}
}