diff --git a/NEWS b/NEWS index d92094c3..53312692 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - moved config_load from smarty core to plugin (Monte) - added &$repeat-paramter to block-functions (messju) - enabled hex-constants in function.math.php (messju) - enabled hex-constants (0x...) as function-attributes, inside if-statements diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 14ebe7c8..37e47940 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1282,84 +1282,8 @@ class Smarty */ function config_load($file, $section = null, $scope = 'global') { - if(@is_dir($this->config_dir)) { - $_config_dir = $this->config_dir; - } else { - // config_dir not found, try include_path - $this->_get_include_path($this->config_dir,$_config_dir); - } - - $_file_path = str_replace('//', '/' ,$_config_dir . '/' . $file); - - // get path to compiled object file - if(isset($section)) { - $_compile_file = $this->_get_auto_filename($this->compile_dir, $section . ' ' . $file); - } else { - $_compile_file = $this->_get_auto_filename($this->compile_dir, $file); - } - - // need to compile config file? - if($this->force_compile || !file_exists($_compile_file) || - ($this->compile_check && - file_exists($_file_path) && - ( filemtime($_compile_file) != filemtime($_file_path) ))) { - $_compile_config = true; - } else { - include($_compile_file); - $_compile_config = empty($_config_vars); - } - - if($_compile_config) { - if(!is_object($this->_conf_obj)) { - require_once SMARTY_DIR . $this->config_class . '.class.php'; - $this->_conf_obj = new $this->config_class($_config_dir); - $this->_conf_obj->overwrite = $this->config_overwrite; - $this->_conf_obj->booleanize = $this->config_booleanize; - $this->_conf_obj->read_hidden = $this->config_read_hidden; - $this->_conf_obj->fix_newlines = $this->config_fix_newlines; - $this->_conf_obj->set_path = $_config_dir; - } - if($_config_vars = array_merge($this->_conf_obj->get($file), - $this->_conf_obj->get($file, $section))) { - if(function_exists('var_export')) { - $_compile_data = ''; - } else { - $_compile_data = ''; - } - $this->_write_file($_compile_file, $_compile_data, true); - touch($_compile_file,filemtime($_file_path)); - } - } - - if ($this->debugging) { - $debug_start_time = $this->_get_microtime(); - } - - if ($this->caching) { - $this->_cache_info['config'][] = $file; - } - - $this->_config[0]['vars'] = @array_merge($this->_config[0]['vars'], $_config_vars); - $this->_config[0]['files'][$file] = true; - - if ($scope == 'parent') { - $this->_config[1]['vars'] = @array_merge($this->_config[1]['vars'], $_config_vars); - $this->_config[1]['files'][$file] = true; - } else if ($scope == 'global') { - for ($i = 1, $for_max = count($this->_config); $i < $for_max; $i++) { - $this->_config[$i]['vars'] = @array_merge($this->_config[$i]['vars'], $_config_vars); - $this->_config[$i]['files'][$file] = true; - } - } - - if ($this->debugging) { - $debug_start_time = $this->_get_microtime(); - $this->_smarty_debug_info[] = array('type' => 'config', - 'filename' => $file.' ['.$section.'] '.$scope, - 'depth' => $this->_inclusion_depth, - 'exec_time' => $this->_get_microtime() - $debug_start_time); - } - + require_once($this->_get_plugin_filepath('function', 'config_load')); + smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this); } /** diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index d7efef67..ae530619 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -474,9 +474,6 @@ class Smarty_Compiler extends Smarty { else return ""; - case 'config_load': - return $this->_compile_config_load_tag($tag_args); - case 'strip': case '/strip': return $this->left_delimiter.$tag_command.$this->right_delimiter; @@ -782,42 +779,6 @@ class Smarty_Compiler extends Smarty { return "_run_insert_handler(array(".implode(', ', (array)$arg_list).")); ?>\n"; } - - /** - * Compile {config_load ...} tag - * - * @param string $tag_args - */ - function _compile_config_load_tag($tag_args) - { - $attrs = $this->_parse_attrs($tag_args); - - if (empty($attrs['file'])) { - $this->_syntax_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__); - } - - if (empty($attrs['section'])) { - $attrs['section'] = 'null'; - } - - if (isset($attrs['scope'])) { - $scope = @$this->_dequote($attrs['scope']); - if ($scope != 'local' && - $scope != 'parent' && - $scope != 'global') { - $this->_syntax_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__); - } - } else { - if (isset($attrs['global']) && $attrs['global']) - $scope = 'parent'; - else - $scope = 'local'; - } - - return 'config_load(' . $attrs['file'] . ', ' . $attrs['section'] . ", '$scope'); ?>"; - } - - /** * Compile {include ...} tag *