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