cvs: smarty / NEWS /libs Smarty.class.php Smarty_Compiler.class.php

From: Date: Sun, 20 Apr 2003 18:08:04 +0000
Subject: cvs: smarty / NEWS /libs Smarty.class.php Smarty_Compiler.class.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-539@lists.php.net to get a copy of this message
mohrt Sun Apr 20 14:08:04 2003 EDT Modified files: /smarty NEWS /smarty/libs Smarty.class.php Smarty_Compiler.class.php Log: moved config_load from smarty core to plugin Index: smarty/NEWS diff -u smarty/NEWS:1.345 smarty/NEWS:1.346 --- smarty/NEWS:1.345 Sun Apr 20 09:04:42 2003 +++ smarty/NEWS Sun Apr 20 14:08:04 2003 @@ -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 Index: smarty/libs/Smarty.class.php diff -u smarty/libs/Smarty.class.php:1.378 smarty/libs/Smarty.class.php:1.379 --- smarty/libs/Smarty.class.php:1.378 Fri Apr 18 06:03:09 2003 +++ smarty/libs/Smarty.class.php Sun Apr 20 14:08:04 2003 @@ -42,7 +42,7 @@ * @version 2.5.0 */ -/* $Id: Smarty.class.php,v 1.378 2003/04/18 10:03:09 messju Exp $ */ +/* $Id: Smarty.class.php,v 1.379 2003/04/20 18:08:04 mohrt Exp $ */ /** * set SMARTY_DIR to absolute path to Smarty library files. @@ -1282,84 +1282,8 @@ */ 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 = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; return true; ?>'; - } else { - $_compile_data = '<?php $_config_vars = unserialize(\'' . str_replace('\'','\\\'', serialize($_config_vars)) . '\'); return true; ?>'; - } - $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); } /** Index: smarty/libs/Smarty_Compiler.class.php diff -u smarty/libs/Smarty_Compiler.class.php:1.213 smarty/libs/Smarty_Compiler.class.php:1.214 --- smarty/libs/Smarty_Compiler.class.php:1.213 Sun Apr 20 09:04:42 2003 +++ smarty/libs/Smarty_Compiler.class.php Sun Apr 20 14:08:04 2003 @@ -39,7 +39,7 @@ * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.213 2003/04/20 13:04:42 messju Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.214 2003/04/20 18:08:04 mohrt Exp $ */ class Smarty_Compiler extends Smarty { @@ -474,9 +474,6 @@ else return "<?php endforeach; endif; ?>"; - case 'config_load': - return $this->_compile_config_load_tag($tag_args); - case 'strip': case '/strip': return $this->left_delimiter.$tag_command.$this->right_delimiter; @@ -781,42 +778,6 @@ return "<?php echo \$this->_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 '<?php $this->config_load(' . $attrs['file'] . ', ' . $attrs['section'] . ", '$scope'); ?>"; - } - /** * Compile {include ...} tag

« previous php.smarty.cvs (#539) next »