mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
- fixed array access on super globals
- changed internal access to smarty object
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
06/14/2009
|
||||||
|
- fixed array access on super globals
|
||||||
|
|
||||||
06/13/2009
|
06/13/2009
|
||||||
- bugfix at extend resource: create unique files for compiled template and cache for each combination of template files
|
- bugfix at extend resource: create unique files for compiled template and cache for each combination of template files
|
||||||
- update extend resource to handle appen and prepend block attributes
|
- update extend resource to handle appen and prepend block attributes
|
||||||
|
@@ -35,7 +35,7 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase {
|
|||||||
$compiler->template->properties['file_dependency'][] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp());
|
$compiler->template->properties['file_dependency'][] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp());
|
||||||
// $_old_source = preg_replace ('/' . $this->smarty->left_delimiter . 'extend\s+(?:file=)?\s*(\S+?|(["\']).+?\2)' . $this->smarty->right_delimiter . '/i', '' , $compiler->template->template_source, 1);
|
// $_old_source = preg_replace ('/' . $this->smarty->left_delimiter . 'extend\s+(?:file=)?\s*(\S+?|(["\']).+?\2)' . $this->smarty->right_delimiter . '/i', '' , $compiler->template->template_source, 1);
|
||||||
$_old_source = $compiler->template->template_source;
|
$_old_source = $compiler->template->template_source;
|
||||||
$_old_source = preg_replace_callback('/(' . $this->smarty->left_delimiter . 'block(.+?)' . $this->smarty->right_delimiter . ')((?:\r?\n?)(.*?)(?:\r?\n?))(' . $this->smarty->left_delimiter . '\/block(.*?)' . $this->smarty->right_delimiter . ')/is', array($this, 'saveBlockData'), $_old_source);
|
$_old_source = preg_replace_callback('/(' . $this->compiler->smarty->left_delimiter . 'block(.+?)' . $this->compiler->smarty->right_delimiter . ')((?:\r?\n?)(.*?)(?:\r?\n?))(' . $this->compiler->smarty->left_delimiter . '\/block(.*?)' . $this->compiler->smarty->right_delimiter . ')/is', array($this, 'saveBlockData'), $_old_source);
|
||||||
$compiler->template->template_source = $_template->getTemplateSource();
|
$compiler->template->template_source = $_template->getTemplateSource();
|
||||||
$compiler->abort_and_recompile = true;
|
$compiler->abort_and_recompile = true;
|
||||||
return ' ';
|
return ' ';
|
||||||
@@ -47,7 +47,7 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase {
|
|||||||
$this->compiler->trigger_template_error("\"" . $matches[0] . "\" missing name attribute");
|
$this->compiler->trigger_template_error("\"" . $matches[0] . "\" missing name attribute");
|
||||||
} else {
|
} else {
|
||||||
// compile block content
|
// compile block content
|
||||||
$_tpl = $this->smarty->createTemplate('string:' . $matches[3]);
|
$_tpl = $this->compiler->smarty->createTemplate('string:' . $matches[3]);
|
||||||
$_tpl->suppressHeader = true;
|
$_tpl->suppressHeader = true;
|
||||||
$_compiled_content = $_tpl->getCompiledTemplate();
|
$_compiled_content = $_tpl->getCompiledTemplate();
|
||||||
unset($_tpl);
|
unset($_tpl);
|
||||||
|
@@ -33,7 +33,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
|
|||||||
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
|
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
|
||||||
}
|
}
|
||||||
// make function known for recursive calls
|
// make function known for recursive calls
|
||||||
$this->smarty->template_functions[$_name]['compiled'] = '';
|
$this->compiler->smarty->template_functions[$_name]['compiled'] = '';
|
||||||
$compiler->template->extract_code = true;
|
$compiler->template->extract_code = true;
|
||||||
$compiler->template->extracted_compiled_code = '';
|
$compiler->template->extracted_compiled_code = '';
|
||||||
$compiler->template->has_code = false;
|
$compiler->template->has_code = false;
|
||||||
|
@@ -35,8 +35,8 @@ class Smarty_Internal_Compile_FunctionClose extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
$_name = trim($saved_data[0]['name'], "'");
|
$_name = trim($saved_data[0]['name'], "'");
|
||||||
$compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code);
|
$compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code);
|
||||||
$this->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code;
|
$this->compiler->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code;
|
||||||
$this->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter'];
|
$this->compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter'];
|
||||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||||
$compiler->template->extract_code = $saved_data[2];
|
$compiler->template->extract_code = $saved_data[2];
|
||||||
return true;
|
return true;
|
||||||
|
@@ -34,31 +34,31 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil
|
|||||||
return 'time()';
|
return 'time()';
|
||||||
|
|
||||||
case 'get':
|
case 'get':
|
||||||
$compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_GET" : "\$GLOBALS['HTTP_GET_VARS']";
|
$compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_GET" : "\$GLOBALS['HTTP_GET_VARS']";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'post':
|
case 'post':
|
||||||
$compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_POST" : "\$GLOBALS['HTTP_POST_VARS']";
|
$compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_POST" : "\$GLOBALS['HTTP_POST_VARS']";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cookies':
|
case 'cookies':
|
||||||
$compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_COOKIE" : "\$GLOBALS['HTTP_COOKIE_VARS']";
|
$compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_COOKIE" : "\$GLOBALS['HTTP_COOKIE_VARS']";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'env':
|
case 'env':
|
||||||
$compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_ENV" : "\$GLOBALS['HTTP_ENV_VARS']";
|
$compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_ENV" : "\$GLOBALS['HTTP_ENV_VARS']";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'server':
|
case 'server':
|
||||||
$compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_SERVER" : "\$GLOBALS['HTTP_SERVER_VARS']";
|
$compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_SERVER" : "\$GLOBALS['HTTP_SERVER_VARS']";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'session':
|
case 'session':
|
||||||
$compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_SESSION" : "\$GLOBALS['HTTP_SESSION_VARS']";
|
$compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_SESSION" : "\$GLOBALS['HTTP_SESSION_VARS']";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'request':
|
case 'request':
|
||||||
if ($this->smarty->request_use_auto_globals) {
|
if ($compiler->smarty->request_use_auto_globals) {
|
||||||
$compiled_ref = "\$_REQUEST";
|
$compiled_ref = "\$_REQUEST";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil
|
|||||||
return "'$_version'";
|
return "'$_version'";
|
||||||
|
|
||||||
case 'const':
|
case 'const':
|
||||||
if ($this->smarty->security && !$this->smarty->security_policy->allow_constants) {
|
if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) {
|
||||||
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -87,11 +87,11 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil
|
|||||||
return "''";
|
return "''";
|
||||||
}
|
}
|
||||||
case 'ldelim':
|
case 'ldelim':
|
||||||
$_ldelim = $this->smarty->left_delimiter;
|
$_ldelim = $compiler->smarty->left_delimiter;
|
||||||
return "'$_ldelim'";
|
return "'$_ldelim'";
|
||||||
|
|
||||||
case 'rdelim':
|
case 'rdelim':
|
||||||
$_rdelim = $this->smarty->right_delimiter;
|
$_rdelim = $compiler->smarty->right_delimiter;
|
||||||
return "'$_rdelim'";
|
return "'$_rdelim'";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -99,7 +99,10 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isset($_index[1])) {
|
if (isset($_index[1])) {
|
||||||
$compiled_ref = $compiled_ref . "[$_index[1]]";
|
array_shift($_index);
|
||||||
|
foreach ($_index as $_ind) {
|
||||||
|
$compiled_ref = $compiled_ref . "[$_ind]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $compiled_ref;
|
return $compiled_ref;
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,6 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->smarty = Smarty::instance();
|
|
||||||
// initialize valid attributes
|
// initialize valid attributes
|
||||||
$this->required_attributes = array();
|
$this->required_attributes = array();
|
||||||
$this->optional_attributes = array();
|
$this->optional_attributes = array();
|
||||||
|
Reference in New Issue
Block a user