mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 11:24:27 +02:00
fix cache fuctions with separated compiled class
This commit is contained in:
@@ -406,6 +406,30 @@ class Smarty
|
||||
return false;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _process_cached_inserts
|
||||
Purpose: Replace cached inserts with the actual results
|
||||
\*======================================================================*/
|
||||
function _process_cached_inserts($results)
|
||||
{
|
||||
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||
$results, $match);
|
||||
list($cached_inserts, $insert_args) = $match;
|
||||
|
||||
for ($i = 0; $i < count($cached_inserts); $i++) {
|
||||
$args = unserialize($insert_args[$i]);
|
||||
$name = $args['name'];
|
||||
unset($args['name']);
|
||||
|
||||
$function_name = 'insert_' . $name;
|
||||
$replace = $function_name($args);
|
||||
|
||||
$results = str_replace($cached_inserts[$i], $replace, $results);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _dequote
|
||||
Purpose: Remove starting and ending quotes from the string
|
||||
@@ -498,6 +522,26 @@ class Smarty
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _create_dir_structure
|
||||
Purpose: create full directory structure
|
||||
\*======================================================================*/
|
||||
function _create_dir_structure($dir)
|
||||
{
|
||||
if (!file_exists($dir)) {
|
||||
$dir_parts = preg_split('!/+!', $dir, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$new_dir = ($dir{0} == '/') ? '/' : '';
|
||||
foreach ($dir_parts as $dir_part) {
|
||||
$new_dir .= $dir_part;
|
||||
if (!file_exists($new_dir) && !mkdir($new_dir, 0755)) {
|
||||
$this->_set_error_msg("problem creating directory \"$dir\"");
|
||||
return false;
|
||||
}
|
||||
$new_dir .= '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: quote_replace
|
||||
Purpose: Quote subpattern references
|
||||
|
@@ -13,8 +13,8 @@ class Smarty_Compiler extends Smarty {
|
||||
Function: _traverse_files()
|
||||
Purpose: traverse the template files & process each one
|
||||
\*======================================================================*/
|
||||
function _traverse_files($tpl_dir, $depth)
|
||||
{
|
||||
function _traverse_files($tpl_dir, $depth)
|
||||
{
|
||||
$retval = true;
|
||||
|
||||
if (is_dir($tpl_dir)) {
|
||||
@@ -49,7 +49,7 @@ function _traverse_files($tpl_dir, $depth)
|
||||
$this->_set_error_msg("Directory \"$tpl_dir\" does not exist or is not a directory.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _process_file()
|
||||
@@ -57,8 +57,8 @@ function _traverse_files($tpl_dir, $depth)
|
||||
and execute the compilation for each
|
||||
one requiring it.
|
||||
\*======================================================================*/
|
||||
function _process_file($filepath)
|
||||
{
|
||||
function _process_file($filepath)
|
||||
{
|
||||
if(preg_match("/^(.+)\/([^\/]+)$/", $filepath, $match)) {
|
||||
$tpl_file_dir = $match[1];
|
||||
$tpl_file_name = $match[2] . '.php';
|
||||
@@ -84,45 +84,25 @@ function _process_file($filepath)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _create_dir_structure
|
||||
Purpose: create full directory structure
|
||||
\*======================================================================*/
|
||||
function _create_dir_structure($dir)
|
||||
{
|
||||
if (!file_exists($dir)) {
|
||||
$dir_parts = preg_split('!/+!', $dir, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$new_dir = ($dir{0} == '/') ? '/' : '';
|
||||
foreach ($dir_parts as $dir_part) {
|
||||
$new_dir .= $dir_part;
|
||||
if (!file_exists($new_dir) && !mkdir($new_dir, 0755)) {
|
||||
$this->_set_error_msg("problem creating directory \"$dir\"");
|
||||
return false;
|
||||
}
|
||||
$new_dir .= '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _modified_file()
|
||||
Input: return comparison of modification times of files
|
||||
\*======================================================================*/
|
||||
function _modified_file($filepath, $compilepath)
|
||||
{
|
||||
function _modified_file($filepath, $compilepath)
|
||||
{
|
||||
if (filemtime($filepath) >= filemtime($compilepath))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_file()
|
||||
Input: compile a template file
|
||||
\*======================================================================*/
|
||||
function _compile_file($filepath, $compilepath)
|
||||
{
|
||||
function _compile_file($filepath, $compilepath)
|
||||
{
|
||||
if (!($template_contents = $this->_read_file($filepath)))
|
||||
return false;
|
||||
|
||||
@@ -204,14 +184,14 @@ function _compile_file($filepath, $compilepath)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _process_cached_inserts
|
||||
Purpose: Replace cached inserts with the actual results
|
||||
\*======================================================================*/
|
||||
function _process_cached_inserts($results)
|
||||
{
|
||||
function _process_cached_inserts($results)
|
||||
{
|
||||
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||
$results, $match);
|
||||
list($cached_inserts, $insert_args) = $match;
|
||||
@@ -228,15 +208,15 @@ function _process_cached_inserts($results)
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_tag
|
||||
Purpose: Compile a template tag
|
||||
\*======================================================================*/
|
||||
function _compile_tag($template_tag)
|
||||
{
|
||||
function _compile_tag($template_tag)
|
||||
{
|
||||
/* Matched comment. */
|
||||
if ($template_tag{0} == '*' && $template_tag{strlen($template_tag)-1} == '*')
|
||||
return '';
|
||||
@@ -320,14 +300,14 @@ function _compile_tag($template_tag)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_custom_tag
|
||||
Purpose: compile custom tag
|
||||
\*======================================================================*/
|
||||
function _compile_custom_tag($tag_command, $tag_args)
|
||||
{
|
||||
function _compile_custom_tag($tag_command, $tag_args)
|
||||
{
|
||||
$function = $this->custom_funcs[$tag_command];
|
||||
|
||||
if (!function_exists($function)) {
|
||||
@@ -343,14 +323,14 @@ function _compile_custom_tag($tag_command, $tag_args)
|
||||
}
|
||||
|
||||
return "<?php $function(array(".implode(',', (array)$arg_list).")); ?>";
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_insert_tag
|
||||
Purpose: Compile {insert ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_insert_tag($tag_args)
|
||||
{
|
||||
function _compile_insert_tag($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
$name = substr($attrs['name'], 1, -1);
|
||||
|
||||
@@ -365,15 +345,15 @@ function _compile_insert_tag($tag_args)
|
||||
}
|
||||
|
||||
return "<?php echo _smarty_insert_handler(array(".implode(', ', (array)$arg_list)."), \$this->caching, \$this->_smarty_md5); ?>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_config_load_tag
|
||||
Purpose: Compile {config_load ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_config_load_tag($tag_args)
|
||||
{
|
||||
function _compile_config_load_tag($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
|
||||
if (empty($attrs['file'])) {
|
||||
@@ -393,15 +373,14 @@ function _compile_config_load_tag($tag_args)
|
||||
$output .= '?>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_include_tag
|
||||
Purpose: Compile {include ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_include_tag($tag_args)
|
||||
{
|
||||
function _compile_include_tag($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
|
||||
if (empty($attrs['file'])) {
|
||||
@@ -432,15 +411,14 @@ function _compile_include_tag($tag_args)
|
||||
"$include_func_name(\"$include_file_name\", get_defined_vars(), array(".implode(',', (array)$arg_list)."));\n?>";
|
||||
} else
|
||||
return '<?php include "'.$this->compile_dir.'/'.$attrs['file'].'.php"; ?>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_section_start
|
||||
Purpose: Compile {section ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_section_start($tag_args)
|
||||
{
|
||||
function _compile_section_start($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
|
||||
$output = "<?php ";
|
||||
@@ -497,15 +475,14 @@ function _compile_section_start($tag_args)
|
||||
$output .= "?>";
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_if_tag
|
||||
Purpose: Compile {if ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_if_tag($tag_args, $elseif = false)
|
||||
{
|
||||
function _compile_if_tag($tag_args, $elseif = false)
|
||||
{
|
||||
/* Tokenize args for 'if' tag. */
|
||||
preg_match_all('/(?:
|
||||
"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | # match all double quoted strings allowed escaped double quotes
|
||||
@@ -602,14 +579,14 @@ function _compile_if_tag($tag_args, $elseif = false)
|
||||
return '<?php elseif ('.implode(' ', $tokens).'): ?>';
|
||||
else
|
||||
return '<?php if ('.implode(' ', $tokens).'): ?>';
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_is_expr
|
||||
Purpose: Parse is expression
|
||||
\*======================================================================*/
|
||||
function _parse_is_expr($is_arg, $tokens)
|
||||
{
|
||||
function _parse_is_expr($is_arg, $tokens)
|
||||
{
|
||||
$expr_end = 0;
|
||||
|
||||
if (($first_token = array_shift($tokens)) == 'not') {
|
||||
@@ -661,14 +638,14 @@ function _parse_is_expr($is_arg, $tokens)
|
||||
array_splice($tokens, 0, $expr_end, $expr);
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_attrs
|
||||
Purpose: Parse attribute string
|
||||
\*======================================================================*/
|
||||
function _parse_attrs($tag_args, $quote = true)
|
||||
{
|
||||
function _parse_attrs($tag_args, $quote = true)
|
||||
{
|
||||
/* Tokenize tag attributes. */
|
||||
preg_match_all('/(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
|
||||
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\'=\s]+)
|
||||
@@ -734,14 +711,14 @@ function _parse_attrs($tag_args, $quote = true)
|
||||
$this->_parse_vars_props($attrs);
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _preg_grep
|
||||
Purpose: Emulate PHP's preg_grep()
|
||||
\*======================================================================*/
|
||||
function _preg_grep($pattern, $array)
|
||||
{
|
||||
function _preg_grep($pattern, $array)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($array as $key => $entry) {
|
||||
@@ -750,14 +727,14 @@ function _preg_grep($pattern, $array)
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_vars_props
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_vars_props(&$tokens)
|
||||
{
|
||||
function _parse_vars_props(&$tokens)
|
||||
{
|
||||
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
|
||||
|
||||
/* preg_grep() was fixed to return keys properly in 4.0.4 and later. To
|
||||
@@ -790,14 +767,14 @@ function _parse_vars_props(&$tokens)
|
||||
$tokens[$expr_index] = $this->_parse_section_prop($section_prop_expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_var
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_var($var_expr)
|
||||
{
|
||||
function _parse_var($var_expr)
|
||||
{
|
||||
list($var_ref, $modifiers) = explode('|', substr($var_expr, 1), 2);
|
||||
|
||||
$sections = explode('/', $var_ref);
|
||||
@@ -819,14 +796,14 @@ function _parse_var($var_expr)
|
||||
$this->_parse_modifiers($output, $modifiers);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_conf_var
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_conf_var($conf_var_expr)
|
||||
{
|
||||
function _parse_conf_var($conf_var_expr)
|
||||
{
|
||||
list($var_ref, $modifiers) = explode('|', $conf_var_expr, 2);
|
||||
|
||||
$var_name = substr($var_ref, 1, -1);
|
||||
@@ -836,14 +813,14 @@ function _parse_conf_var($conf_var_expr)
|
||||
$this->_parse_modifiers($output, $modifiers);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_section_prop
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_section_prop($section_prop_expr)
|
||||
{
|
||||
function _parse_section_prop($section_prop_expr)
|
||||
{
|
||||
list($var_ref, $modifiers) = explode('|', $section_prop_expr, 2);
|
||||
|
||||
preg_match('!%(\w+)\.(\w+)%!', $var_ref, $match);
|
||||
@@ -855,14 +832,14 @@ function _parse_section_prop($section_prop_expr)
|
||||
$this->_parse_modifiers($output, $modifiers);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_modifiers
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_modifiers(&$output, $modifier_string)
|
||||
{
|
||||
function _parse_modifiers(&$output, $modifier_string)
|
||||
{
|
||||
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
|
||||
preg_match_all('!\|(@?\w+)((?>:(?:'. $qstr_regexp . '|[^|]+))*)!', '|' . $modifier_string, $match);
|
||||
list(, $modifiers, $modifier_arg_strings) = $match;
|
||||
@@ -905,7 +882,7 @@ function _parse_modifiers(&$output, $modifier_string)
|
||||
|
||||
$output = "_smarty_mod_handler('$mod_func_name', $map_array, $output$modifier_args)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -406,6 +406,30 @@ class Smarty
|
||||
return false;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _process_cached_inserts
|
||||
Purpose: Replace cached inserts with the actual results
|
||||
\*======================================================================*/
|
||||
function _process_cached_inserts($results)
|
||||
{
|
||||
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||
$results, $match);
|
||||
list($cached_inserts, $insert_args) = $match;
|
||||
|
||||
for ($i = 0; $i < count($cached_inserts); $i++) {
|
||||
$args = unserialize($insert_args[$i]);
|
||||
$name = $args['name'];
|
||||
unset($args['name']);
|
||||
|
||||
$function_name = 'insert_' . $name;
|
||||
$replace = $function_name($args);
|
||||
|
||||
$results = str_replace($cached_inserts[$i], $replace, $results);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _dequote
|
||||
Purpose: Remove starting and ending quotes from the string
|
||||
@@ -498,6 +522,26 @@ class Smarty
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _create_dir_structure
|
||||
Purpose: create full directory structure
|
||||
\*======================================================================*/
|
||||
function _create_dir_structure($dir)
|
||||
{
|
||||
if (!file_exists($dir)) {
|
||||
$dir_parts = preg_split('!/+!', $dir, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$new_dir = ($dir{0} == '/') ? '/' : '';
|
||||
foreach ($dir_parts as $dir_part) {
|
||||
$new_dir .= $dir_part;
|
||||
if (!file_exists($new_dir) && !mkdir($new_dir, 0755)) {
|
||||
$this->_set_error_msg("problem creating directory \"$dir\"");
|
||||
return false;
|
||||
}
|
||||
$new_dir .= '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: quote_replace
|
||||
Purpose: Quote subpattern references
|
||||
|
@@ -13,8 +13,8 @@ class Smarty_Compiler extends Smarty {
|
||||
Function: _traverse_files()
|
||||
Purpose: traverse the template files & process each one
|
||||
\*======================================================================*/
|
||||
function _traverse_files($tpl_dir, $depth)
|
||||
{
|
||||
function _traverse_files($tpl_dir, $depth)
|
||||
{
|
||||
$retval = true;
|
||||
|
||||
if (is_dir($tpl_dir)) {
|
||||
@@ -49,7 +49,7 @@ function _traverse_files($tpl_dir, $depth)
|
||||
$this->_set_error_msg("Directory \"$tpl_dir\" does not exist or is not a directory.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _process_file()
|
||||
@@ -57,8 +57,8 @@ function _traverse_files($tpl_dir, $depth)
|
||||
and execute the compilation for each
|
||||
one requiring it.
|
||||
\*======================================================================*/
|
||||
function _process_file($filepath)
|
||||
{
|
||||
function _process_file($filepath)
|
||||
{
|
||||
if(preg_match("/^(.+)\/([^\/]+)$/", $filepath, $match)) {
|
||||
$tpl_file_dir = $match[1];
|
||||
$tpl_file_name = $match[2] . '.php';
|
||||
@@ -84,45 +84,25 @@ function _process_file($filepath)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _create_dir_structure
|
||||
Purpose: create full directory structure
|
||||
\*======================================================================*/
|
||||
function _create_dir_structure($dir)
|
||||
{
|
||||
if (!file_exists($dir)) {
|
||||
$dir_parts = preg_split('!/+!', $dir, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$new_dir = ($dir{0} == '/') ? '/' : '';
|
||||
foreach ($dir_parts as $dir_part) {
|
||||
$new_dir .= $dir_part;
|
||||
if (!file_exists($new_dir) && !mkdir($new_dir, 0755)) {
|
||||
$this->_set_error_msg("problem creating directory \"$dir\"");
|
||||
return false;
|
||||
}
|
||||
$new_dir .= '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _modified_file()
|
||||
Input: return comparison of modification times of files
|
||||
\*======================================================================*/
|
||||
function _modified_file($filepath, $compilepath)
|
||||
{
|
||||
function _modified_file($filepath, $compilepath)
|
||||
{
|
||||
if (filemtime($filepath) >= filemtime($compilepath))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_file()
|
||||
Input: compile a template file
|
||||
\*======================================================================*/
|
||||
function _compile_file($filepath, $compilepath)
|
||||
{
|
||||
function _compile_file($filepath, $compilepath)
|
||||
{
|
||||
if (!($template_contents = $this->_read_file($filepath)))
|
||||
return false;
|
||||
|
||||
@@ -204,14 +184,14 @@ function _compile_file($filepath, $compilepath)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _process_cached_inserts
|
||||
Purpose: Replace cached inserts with the actual results
|
||||
\*======================================================================*/
|
||||
function _process_cached_inserts($results)
|
||||
{
|
||||
function _process_cached_inserts($results)
|
||||
{
|
||||
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||
$results, $match);
|
||||
list($cached_inserts, $insert_args) = $match;
|
||||
@@ -228,15 +208,15 @@ function _process_cached_inserts($results)
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_tag
|
||||
Purpose: Compile a template tag
|
||||
\*======================================================================*/
|
||||
function _compile_tag($template_tag)
|
||||
{
|
||||
function _compile_tag($template_tag)
|
||||
{
|
||||
/* Matched comment. */
|
||||
if ($template_tag{0} == '*' && $template_tag{strlen($template_tag)-1} == '*')
|
||||
return '';
|
||||
@@ -320,14 +300,14 @@ function _compile_tag($template_tag)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_custom_tag
|
||||
Purpose: compile custom tag
|
||||
\*======================================================================*/
|
||||
function _compile_custom_tag($tag_command, $tag_args)
|
||||
{
|
||||
function _compile_custom_tag($tag_command, $tag_args)
|
||||
{
|
||||
$function = $this->custom_funcs[$tag_command];
|
||||
|
||||
if (!function_exists($function)) {
|
||||
@@ -343,14 +323,14 @@ function _compile_custom_tag($tag_command, $tag_args)
|
||||
}
|
||||
|
||||
return "<?php $function(array(".implode(',', (array)$arg_list).")); ?>";
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_insert_tag
|
||||
Purpose: Compile {insert ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_insert_tag($tag_args)
|
||||
{
|
||||
function _compile_insert_tag($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
$name = substr($attrs['name'], 1, -1);
|
||||
|
||||
@@ -365,15 +345,15 @@ function _compile_insert_tag($tag_args)
|
||||
}
|
||||
|
||||
return "<?php echo _smarty_insert_handler(array(".implode(', ', (array)$arg_list)."), \$this->caching, \$this->_smarty_md5); ?>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_config_load_tag
|
||||
Purpose: Compile {config_load ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_config_load_tag($tag_args)
|
||||
{
|
||||
function _compile_config_load_tag($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
|
||||
if (empty($attrs['file'])) {
|
||||
@@ -393,15 +373,14 @@ function _compile_config_load_tag($tag_args)
|
||||
$output .= '?>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_include_tag
|
||||
Purpose: Compile {include ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_include_tag($tag_args)
|
||||
{
|
||||
function _compile_include_tag($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
|
||||
if (empty($attrs['file'])) {
|
||||
@@ -432,15 +411,14 @@ function _compile_include_tag($tag_args)
|
||||
"$include_func_name(\"$include_file_name\", get_defined_vars(), array(".implode(',', (array)$arg_list)."));\n?>";
|
||||
} else
|
||||
return '<?php include "'.$this->compile_dir.'/'.$attrs['file'].'.php"; ?>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_section_start
|
||||
Purpose: Compile {section ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_section_start($tag_args)
|
||||
{
|
||||
function _compile_section_start($tag_args)
|
||||
{
|
||||
$attrs = $this->_parse_attrs($tag_args);
|
||||
|
||||
$output = "<?php ";
|
||||
@@ -497,15 +475,14 @@ function _compile_section_start($tag_args)
|
||||
$output .= "?>";
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _compile_if_tag
|
||||
Purpose: Compile {if ...} tag
|
||||
\*======================================================================*/
|
||||
function _compile_if_tag($tag_args, $elseif = false)
|
||||
{
|
||||
function _compile_if_tag($tag_args, $elseif = false)
|
||||
{
|
||||
/* Tokenize args for 'if' tag. */
|
||||
preg_match_all('/(?:
|
||||
"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | # match all double quoted strings allowed escaped double quotes
|
||||
@@ -602,14 +579,14 @@ function _compile_if_tag($tag_args, $elseif = false)
|
||||
return '<?php elseif ('.implode(' ', $tokens).'): ?>';
|
||||
else
|
||||
return '<?php if ('.implode(' ', $tokens).'): ?>';
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_is_expr
|
||||
Purpose: Parse is expression
|
||||
\*======================================================================*/
|
||||
function _parse_is_expr($is_arg, $tokens)
|
||||
{
|
||||
function _parse_is_expr($is_arg, $tokens)
|
||||
{
|
||||
$expr_end = 0;
|
||||
|
||||
if (($first_token = array_shift($tokens)) == 'not') {
|
||||
@@ -661,14 +638,14 @@ function _parse_is_expr($is_arg, $tokens)
|
||||
array_splice($tokens, 0, $expr_end, $expr);
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_attrs
|
||||
Purpose: Parse attribute string
|
||||
\*======================================================================*/
|
||||
function _parse_attrs($tag_args, $quote = true)
|
||||
{
|
||||
function _parse_attrs($tag_args, $quote = true)
|
||||
{
|
||||
/* Tokenize tag attributes. */
|
||||
preg_match_all('/(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
|
||||
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\'=\s]+)
|
||||
@@ -734,14 +711,14 @@ function _parse_attrs($tag_args, $quote = true)
|
||||
$this->_parse_vars_props($attrs);
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _preg_grep
|
||||
Purpose: Emulate PHP's preg_grep()
|
||||
\*======================================================================*/
|
||||
function _preg_grep($pattern, $array)
|
||||
{
|
||||
function _preg_grep($pattern, $array)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($array as $key => $entry) {
|
||||
@@ -750,14 +727,14 @@ function _preg_grep($pattern, $array)
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_vars_props
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_vars_props(&$tokens)
|
||||
{
|
||||
function _parse_vars_props(&$tokens)
|
||||
{
|
||||
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
|
||||
|
||||
/* preg_grep() was fixed to return keys properly in 4.0.4 and later. To
|
||||
@@ -790,14 +767,14 @@ function _parse_vars_props(&$tokens)
|
||||
$tokens[$expr_index] = $this->_parse_section_prop($section_prop_expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_var
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_var($var_expr)
|
||||
{
|
||||
function _parse_var($var_expr)
|
||||
{
|
||||
list($var_ref, $modifiers) = explode('|', substr($var_expr, 1), 2);
|
||||
|
||||
$sections = explode('/', $var_ref);
|
||||
@@ -819,14 +796,14 @@ function _parse_var($var_expr)
|
||||
$this->_parse_modifiers($output, $modifiers);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_conf_var
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_conf_var($conf_var_expr)
|
||||
{
|
||||
function _parse_conf_var($conf_var_expr)
|
||||
{
|
||||
list($var_ref, $modifiers) = explode('|', $conf_var_expr, 2);
|
||||
|
||||
$var_name = substr($var_ref, 1, -1);
|
||||
@@ -836,14 +813,14 @@ function _parse_conf_var($conf_var_expr)
|
||||
$this->_parse_modifiers($output, $modifiers);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_section_prop
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_section_prop($section_prop_expr)
|
||||
{
|
||||
function _parse_section_prop($section_prop_expr)
|
||||
{
|
||||
list($var_ref, $modifiers) = explode('|', $section_prop_expr, 2);
|
||||
|
||||
preg_match('!%(\w+)\.(\w+)%!', $var_ref, $match);
|
||||
@@ -855,14 +832,14 @@ function _parse_section_prop($section_prop_expr)
|
||||
$this->_parse_modifiers($output, $modifiers);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: _parse_modifiers
|
||||
Purpose:
|
||||
\*======================================================================*/
|
||||
function _parse_modifiers(&$output, $modifier_string)
|
||||
{
|
||||
function _parse_modifiers(&$output, $modifier_string)
|
||||
{
|
||||
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
|
||||
preg_match_all('!\|(@?\w+)((?>:(?:'. $qstr_regexp . '|[^|]+))*)!', '|' . $modifier_string, $match);
|
||||
list(, $modifiers, $modifier_arg_strings) = $match;
|
||||
@@ -905,7 +882,7 @@ function _parse_modifiers(&$output, $modifier_string)
|
||||
|
||||
$output = "_smarty_mod_handler('$mod_func_name', $map_array, $output$modifier_args)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user