mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 11:24:27 +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'] . ';?>';
|
||||||
}
|
}
|
||||||
@@ -58,4 +58,4 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Config
|
* Smarty Internal Plugin Config
|
||||||
*
|
*
|
||||||
* Main class for config variables
|
* Main class for config variables
|
||||||
*
|
*
|
||||||
* @ignore
|
* @ignore
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Config
|
* @subpackage Config
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Config {
|
class Smarty_Internal_Config {
|
||||||
static $config_objects = array();
|
static $config_objects = array();
|
||||||
|
|
||||||
@@ -85,23 +85,23 @@ class Smarty_Internal_Config {
|
|||||||
}
|
}
|
||||||
// check for absolute path
|
// check for absolute path
|
||||||
if (file_exists($this->config_resource_name))
|
if (file_exists($this->config_resource_name))
|
||||||
return $this->config_resource_name;
|
return $this->config_resource_name;
|
||||||
// no tpl file found
|
// no tpl file found
|
||||||
throw new Exception("Unable to load config file \"{$this->config_resource_name}\"");
|
throw new Exception("Unable to load config file \"{$this->config_resource_name}\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Read config file source
|
* Read config file source
|
||||||
*
|
*
|
||||||
* @return string content of source file
|
* @return string content of source file
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns the template source code
|
* Returns the template source code
|
||||||
*
|
*
|
||||||
* The template source is being read by the actual resource handler
|
* The template source is being read by the actual resource handler
|
||||||
*
|
*
|
||||||
* @return string the template source
|
* @return string the template source
|
||||||
*/
|
*/
|
||||||
public function getConfigSource ()
|
public function getConfigSource ()
|
||||||
{
|
{
|
||||||
if ($this->config_source === null) {
|
if ($this->config_source === null) {
|
||||||
@@ -123,10 +123,10 @@ class Smarty_Internal_Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the compiled filepath
|
* Returns the compiled filepath
|
||||||
*
|
*
|
||||||
* @return string the compiled filepath
|
* @return string the compiled filepath
|
||||||
*/
|
*/
|
||||||
public function getCompiledFilepath ()
|
public function getCompiledFilepath ()
|
||||||
{
|
{
|
||||||
return $this->compiled_filepath === null ?
|
return $this->compiled_filepath === null ?
|
||||||
@@ -152,10 +152,10 @@ class Smarty_Internal_Config {
|
|||||||
return $_compile_dir . $_filepath . '.' . basename($this->config_resource_name) . '.config' . '.php';
|
return $_compile_dir . $_filepath . '.' . basename($this->config_resource_name) . '.config' . '.php';
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the timpestamp of the compiled file
|
* Returns the timpestamp of the compiled file
|
||||||
*
|
*
|
||||||
* @return integer the file timestamp
|
* @return integer the file timestamp
|
||||||
*/
|
*/
|
||||||
public function getCompiledTimestamp ()
|
public function getCompiledTimestamp ()
|
||||||
{
|
{
|
||||||
return $this->compiled_timestamp === null ?
|
return $this->compiled_timestamp === null ?
|
||||||
@@ -163,98 +163,98 @@ class Smarty_Internal_Config {
|
|||||||
$this->compiled_timestamp;
|
$this->compiled_timestamp;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns if the current config file must be compiled
|
* Returns if the current config file must be compiled
|
||||||
*
|
*
|
||||||
* It does compare the timestamps of config source and the compiled config and checks the force compile configuration
|
* It does compare the timestamps of config source and the compiled config and checks the force compile configuration
|
||||||
*
|
*
|
||||||
* @return boolean true if the file must be compiled
|
* @return boolean true if the file must be compiled
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the compiled config file
|
* Returns the compiled config file
|
||||||
*
|
*
|
||||||
* It checks if the config file must be compiled or just read the compiled version
|
* It checks if the config file must be compiled or just read the compiled version
|
||||||
*
|
*
|
||||||
* @return string the compiled config file
|
* @return string the compiled config file
|
||||||
*/
|
*/
|
||||||
public function getCompiledConfig ()
|
public function getCompiledConfig ()
|
||||||
{
|
{
|
||||||
if ($this->compiled_config === null) {
|
if ($this->compiled_config === null) {
|
||||||
// see if template needs compiling.
|
// see if template needs compiling.
|
||||||
if ($this->mustCompile()) {
|
if ($this->mustCompile()) {
|
||||||
$this->compileConfigSource();
|
$this->compileConfigSource();
|
||||||
|
} else {
|
||||||
|
$this->compiled_config = file_get_contents($this->getCompiledFilepath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->compiled_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles the config files
|
||||||
|
*/
|
||||||
|
public function compileConfigSource ()
|
||||||
|
{
|
||||||
|
// compile template
|
||||||
|
if (!is_object($this->compiler_object)) {
|
||||||
|
// load compiler
|
||||||
|
$this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty);
|
||||||
|
}
|
||||||
|
// call compiler
|
||||||
|
if ($this->compiler_object->compileSource($this)) {
|
||||||
|
// compiling succeded
|
||||||
|
// write compiled template
|
||||||
|
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->getCompiledConfig(), $this->smarty);
|
||||||
|
// make template and compiled file timestamp match
|
||||||
|
touch($this->getCompiledFilepath(), $this->getTimestamp());
|
||||||
} else {
|
} else {
|
||||||
$this->compiled_config = file_get_contents($this->getCompiledFilepath());
|
// error compiling template
|
||||||
|
throw new Exception("Error compiling template {$this->getConfigFilepath ()}");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->compiled_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Compiles the config files
|
|
||||||
*/
|
|
||||||
public function compileConfigSource ()
|
|
||||||
{
|
|
||||||
// compile template
|
|
||||||
if (!is_object($this->compiler_object)) {
|
|
||||||
// load compiler
|
|
||||||
$this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty);
|
|
||||||
}
|
|
||||||
// call compiler
|
|
||||||
if ($this->compiler_object->compileSource($this)) {
|
|
||||||
// compiling succeded
|
|
||||||
// write compiled template
|
|
||||||
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->getCompiledConfig(), $this->smarty);
|
|
||||||
// make template and compiled file timestamp match
|
|
||||||
touch($this->getCompiledFilepath(), $this->getTimestamp());
|
|
||||||
} else {
|
|
||||||
// error compiling template
|
|
||||||
throw new Exception("Error compiling template {$this->getConfigFilepath ()}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* load config variables
|
* load config variables
|
||||||
*
|
*
|
||||||
* @param mixed $sections array of section names, single section or null
|
* @param mixed $sections array of section names, single section or null
|
||||||
* @param object $scope global,parent or local
|
* @param object $scope global,parent or local
|
||||||
*/
|
*/
|
||||||
public function loadConfigVars ($sections = null, $scope)
|
public function loadConfigVars ($sections = null, $scope)
|
||||||
{
|
{
|
||||||
if (isset($this->template)) {
|
if (isset($this->template)) {
|
||||||
$this->template->properties['file_dependency'][sha1($this->getConfigFilepath())] = array($this->getConfigFilepath(), $this->getTimestamp());
|
$this->template->properties['file_dependency'][sha1($this->getConfigFilepath())] = array($this->getConfigFilepath(), $this->getTimestamp());
|
||||||
} else {
|
|
||||||
$this->smarty->properties['file_dependency'][sha1($this->getConfigFilepath())] = array($this->getConfigFilepath(), $this->getTimestamp());
|
|
||||||
}
|
|
||||||
$config_data = unserialize($this->getCompiledConfig());
|
|
||||||
// var_dump($config_data);
|
|
||||||
// copy global config vars
|
|
||||||
foreach ($config_data['vars'] as $variable => $value) {
|
|
||||||
if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {
|
|
||||||
$scope->config_vars[$variable] = $value;
|
|
||||||
} else {
|
} else {
|
||||||
$scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value);
|
$this->smarty->properties['file_dependency'][sha1($this->getConfigFilepath())] = array($this->getConfigFilepath(), $this->getTimestamp());
|
||||||
}
|
}
|
||||||
}
|
$config_data = unserialize($this->getCompiledConfig());
|
||||||
// scan sections
|
// var_dump($config_data);
|
||||||
foreach ($config_data['sections'] as $this_section => $dummy) {
|
// copy global config vars
|
||||||
if ($sections == null || in_array($this_section, (array)$sections)) {
|
foreach ($config_data['vars'] as $variable => $value) {
|
||||||
foreach ($config_data['sections'][$this_section]['vars'] as $variable => $value) {
|
if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {
|
||||||
if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {
|
$scope->config_vars[$variable] = $value;
|
||||||
$scope->config_vars[$variable] = $value;
|
} else {
|
||||||
} else {
|
$scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value);
|
||||||
$scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value);
|
}
|
||||||
|
}
|
||||||
|
// scan sections
|
||||||
|
foreach ($config_data['sections'] as $this_section => $dummy) {
|
||||||
|
if ($sections == null || in_array($this_section, (array)$sections)) {
|
||||||
|
foreach ($config_data['sections'][$this_section]['vars'] as $variable => $value) {
|
||||||
|
if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {
|
||||||
|
$scope->config_vars[$variable] = $value;
|
||||||
|
} else {
|
||||||
|
$scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
@@ -1,23 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Config File Compiler
|
* Smarty Internal Plugin Config File Compiler
|
||||||
*
|
*
|
||||||
* This is the config file compiler class. It calls the lexer and parser to
|
* This is the config file compiler class. It calls the lexer and parser to
|
||||||
* perform the compiling.
|
* perform the compiling.
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Config
|
* @subpackage Config
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Main config file compiler class
|
* Main config file compiler class
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Config_File_Compiler {
|
class Smarty_Internal_Config_File_Compiler {
|
||||||
public $compile_error= false;
|
public $compile_error = false;
|
||||||
/**
|
/**
|
||||||
* Initialize compiler
|
* Initialize compiler
|
||||||
*/
|
*/
|
||||||
public function __construct($smarty)
|
public function __construct($smarty)
|
||||||
{
|
{
|
||||||
$this->smarty = $smarty;
|
$this->smarty = $smarty;
|
||||||
@@ -29,19 +29,19 @@ class Smarty_Internal_Config_File_Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methode to compile a Smarty template
|
* Methode to compile a Smarty template
|
||||||
*
|
*
|
||||||
* @param $template template object to compile
|
* @param $template template object to compile
|
||||||
* @return bool true if compiling succeeded, false if it failed
|
* @return bool true if compiling succeeded, false if it failed
|
||||||
*/
|
*/
|
||||||
public function compileSource($config)
|
public function compileSource($config)
|
||||||
{
|
{
|
||||||
/* here is where the compiling takes place. Smarty
|
/* here is where the compiling takes place. Smarty
|
||||||
tags in the templates are replaces with PHP code,
|
tags in the templates are replaces with PHP code,
|
||||||
then written to compiled files. */
|
then written to compiled files. */
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
// get config file source
|
// get config file source
|
||||||
$_content = $config->getConfigSource()."\n";
|
$_content = $config->getConfigSource() . "\n";
|
||||||
// on empty template just return
|
// on empty template just return
|
||||||
if ($_content == '') {
|
if ($_content == '') {
|
||||||
return true;
|
return true;
|
||||||
@@ -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
|
||||||
@@ -67,16 +67,16 @@ class Smarty_Internal_Config_File_Compiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* display compiler error messages without dying
|
* display compiler error messages without dying
|
||||||
*
|
*
|
||||||
* If parameter $args is empty it is a parser detected syntax error.
|
* If parameter $args is empty it is a parser detected syntax error.
|
||||||
* In this case the parser is called to obtain information about exspected tokens.
|
* In this case the parser is called to obtain information about exspected tokens.
|
||||||
*
|
*
|
||||||
* If parameter $args contains a string this is used as error message
|
* If parameter $args contains a string this is used as error message
|
||||||
*
|
*
|
||||||
* @todo output exact position of parse error in source line
|
* @todo output exact position of parse error in source line
|
||||||
* @param $args string individual error message or null
|
* @param $args string individual error message or null
|
||||||
*/
|
*/
|
||||||
public function trigger_config_file_error($args = null)
|
public function trigger_config_file_error($args = null)
|
||||||
{
|
{
|
||||||
$this->lex = Smarty_Internal_Configfilelexer::instance();
|
$this->lex = Smarty_Internal_Configfilelexer::instance();
|
||||||
@@ -84,7 +84,7 @@ class Smarty_Internal_Config_File_Compiler {
|
|||||||
// get template source line which has error
|
// get template source line which has error
|
||||||
$line = $this->lex->line;
|
$line = $this->lex->line;
|
||||||
if (isset($args)) {
|
if (isset($args)) {
|
||||||
// $line--;
|
// $line--;
|
||||||
}
|
}
|
||||||
$match = preg_split("/\n/", $this->lex->data);
|
$match = preg_split("/\n/", $this->lex->data);
|
||||||
$error_text = "Syntax error in config file '{$this->config->getConfigFilepath()}' on line {$line} '{$match[$line-1]}' ";
|
$error_text = "Syntax error in config file '{$this->config->getConfigFilepath()}' on line {$line} '{$match[$line-1]}' ";
|
||||||
@@ -106,11 +106,10 @@ class Smarty_Internal_Config_File_Compiler {
|
|||||||
// output parser error message
|
// output parser error message
|
||||||
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
||||||
}
|
}
|
||||||
throw new Exception($error_text);
|
throw new Exception($error_text);
|
||||||
// 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
@@ -50,13 +50,7 @@ class Smarty_Internal_Utility {
|
|||||||
* @return integer number of template files recompiled
|
* @return integer number of template files recompiled
|
||||||
*/
|
*/
|
||||||
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';
|
||||||
@@ -114,8 +108,8 @@ class Smarty_Internal_Utility {
|
|||||||
* @return integer number of template files recompiled
|
* @return integer number of template files recompiled
|
||||||
*/
|
*/
|
||||||
function compileAllConfig($extention = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
|
function compileAllConfig($extention = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
@@ -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