* Includes are now always done via generated function call to protect

namespace.
* config_load now always uses global config object to improve
  performance.
This commit is contained in:
andrey
2001-03-15 21:28:24 +00:00
parent 6de2acf24d
commit 2ca77e08d8
2 changed files with 54 additions and 60 deletions

View File

@@ -398,13 +398,13 @@ class Smarty_Compiler extends Smarty {
$output = "<?php if (!class_exists('Config_File'))\n" .
" include_once 'Config_File.class.php';\n" .
"if (!is_object(\$_conf_obj) || get_class(\$_conf_obj) != 'config_file') {\n" .
" \$_conf_obj = new Config_File('".$this->config_dir."');\n" .
"if (!is_object(\$GLOBALS['_smarty_conf_obj']) || get_class(\$GLOBALS['_smarty_conf_obj']) != 'config_file') {\n" .
" \$GLOBALS['_smarty_conf_obj'] = new Config_File('".$this->config_dir."');\n" .
"}\n" .
"\$_config = array_merge((array)\$_config, \$_conf_obj->get(".$attrs['file']."));\n";
"\$_smarty_config = array_merge((array)\$_smarty_config, \$GLOBALS['_smarty_conf_obj']->get(".$attrs['file']."));\n";
if (!empty($attrs['section']))
$output .= '$_config = array_merge((array)$_config, $_conf_obj->get('.$attrs['file'].', '.$attrs['section'].')); ';
$output .= '$_smarty_config = array_merge((array)$_smarty_config, $GLOBALS[\'_smarty_conf_obj\']->get('.$attrs['file'].', '.$attrs['section'].')); ';
$output .= '?>';
@@ -424,7 +424,6 @@ class Smarty_Compiler extends Smarty {
} else
$attrs['file'] = $this->_dequote($attrs['file']);
if (count($attrs) > 1) {
$include_func_name = uniqid("_include_");
$include_file_name = $this->compile_dir.'/'.$attrs['file'];
@@ -445,8 +444,6 @@ class Smarty_Compiler extends Smarty {
" }\n" .
"}\n" .
"$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"; ?>';
}
/*======================================================================*\
@@ -463,8 +460,8 @@ class Smarty_Compiler extends Smarty {
$this->_syntax_error("missing section name");
}
$output .= "if(isset(\$_sections[$section_name])) { unset(\$_sections[$section_name]); }\n";
$section_props = "\$_sections[$section_name]['properties']";
$output .= "if (isset(\$_smarty_sections[$section_name])) unset(\$_smarty_sections[$section_name]);\n";
$section_props = "\$_smarty_sections[$section_name]['properties']";
foreach ($attrs as $attr_name => $attr_value) {
switch ($attr_name) {
@@ -823,7 +820,7 @@ class Smarty_Compiler extends Smarty {
list($section, $section_prop) = explode('.', $section_ref);
if (!isset($section_prop))
$section_prop = 'index';
$output .= "[\$_sections['$section']['properties']['$section_prop']]";
$output .= "[\$_smarty_sections['$section']['properties']['$section_prop']]";
}
foreach ($props as $prop) {
$output .= "['$prop']";
@@ -844,7 +841,7 @@ class Smarty_Compiler extends Smarty {
$var_name = substr($var_ref, 1, -1);
$output = "\$_config['$var_name']";
$output = "\$_smarty_config['$var_name']";
$this->_parse_modifiers($output, $modifiers);
@@ -863,7 +860,7 @@ class Smarty_Compiler extends Smarty {
$section_name = $match[1];
$prop_name = $match[2];
$output = "\$_sections['$section_name']['properties']['$prop_name']";
$output = "\$_smarty_sections['$section_name']['properties']['$prop_name']";
$this->_parse_modifiers($output, $modifiers);

View File

@@ -398,13 +398,13 @@ class Smarty_Compiler extends Smarty {
$output = "<?php if (!class_exists('Config_File'))\n" .
" include_once 'Config_File.class.php';\n" .
"if (!is_object(\$_conf_obj) || get_class(\$_conf_obj) != 'config_file') {\n" .
" \$_conf_obj = new Config_File('".$this->config_dir."');\n" .
"if (!is_object(\$GLOBALS['_smarty_conf_obj']) || get_class(\$GLOBALS['_smarty_conf_obj']) != 'config_file') {\n" .
" \$GLOBALS['_smarty_conf_obj'] = new Config_File('".$this->config_dir."');\n" .
"}\n" .
"\$_config = array_merge((array)\$_config, \$_conf_obj->get(".$attrs['file']."));\n";
"\$_smarty_config = array_merge((array)\$_smarty_config, \$GLOBALS['_smarty_conf_obj']->get(".$attrs['file']."));\n";
if (!empty($attrs['section']))
$output .= '$_config = array_merge((array)$_config, $_conf_obj->get('.$attrs['file'].', '.$attrs['section'].')); ';
$output .= '$_smarty_config = array_merge((array)$_smarty_config, $GLOBALS[\'_smarty_conf_obj\']->get('.$attrs['file'].', '.$attrs['section'].')); ';
$output .= '?>';
@@ -424,7 +424,6 @@ class Smarty_Compiler extends Smarty {
} else
$attrs['file'] = $this->_dequote($attrs['file']);
if (count($attrs) > 1) {
$include_func_name = uniqid("_include_");
$include_file_name = $this->compile_dir.'/'.$attrs['file'];
@@ -445,8 +444,6 @@ class Smarty_Compiler extends Smarty {
" }\n" .
"}\n" .
"$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"; ?>';
}
/*======================================================================*\
@@ -463,8 +460,8 @@ class Smarty_Compiler extends Smarty {
$this->_syntax_error("missing section name");
}
$output .= "if(isset(\$_sections[$section_name])) { unset(\$_sections[$section_name]); }\n";
$section_props = "\$_sections[$section_name]['properties']";
$output .= "if (isset(\$_smarty_sections[$section_name])) unset(\$_smarty_sections[$section_name]);\n";
$section_props = "\$_smarty_sections[$section_name]['properties']";
foreach ($attrs as $attr_name => $attr_value) {
switch ($attr_name) {
@@ -823,7 +820,7 @@ class Smarty_Compiler extends Smarty {
list($section, $section_prop) = explode('.', $section_ref);
if (!isset($section_prop))
$section_prop = 'index';
$output .= "[\$_sections['$section']['properties']['$section_prop']]";
$output .= "[\$_smarty_sections['$section']['properties']['$section_prop']]";
}
foreach ($props as $prop) {
$output .= "['$prop']";
@@ -844,7 +841,7 @@ class Smarty_Compiler extends Smarty {
$var_name = substr($var_ref, 1, -1);
$output = "\$_config['$var_name']";
$output = "\$_smarty_config['$var_name']";
$this->_parse_modifiers($output, $modifiers);
@@ -863,7 +860,7 @@ class Smarty_Compiler extends Smarty {
$section_name = $match[1];
$prop_name = $match[2];
$output = "\$_sections['$section_name']['properties']['$prop_name']";
$output = "\$_smarty_sections['$section_name']['properties']['$prop_name']";
$this->_parse_modifiers($output, $modifiers);