mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
clean up code, respect force_compile and compile_check flags
This commit is contained in:
@@ -256,7 +256,7 @@ class Config_File {
|
|||||||
$fp = @fopen($config_file, "r");
|
$fp = @fopen($config_file, "r");
|
||||||
if (!is_resource($fp)) {
|
if (!is_resource($fp)) {
|
||||||
$this->_trigger_error_msg("Could not open config file '$config_file'");
|
$this->_trigger_error_msg("Could not open config file '$config_file'");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contents = fread($fp, filesize($config_file));
|
$contents = fread($fp, filesize($config_file));
|
||||||
@@ -286,6 +286,8 @@ class Config_File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->_config_data[$config_file] = $config_data;
|
$this->_config_data[$config_file] = $config_data;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1234,32 +1234,40 @@ function _generate_debug_output() {
|
|||||||
$this->_get_include_path($this->config_dir,$_config_dir);
|
$this->_get_include_path($this->config_dir,$_config_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_file_path = $_config_dir . '/' . $file;
|
$_file_path = str_replace('//', '/' ,$_config_dir . '/' . $file);
|
||||||
|
|
||||||
if(!is_object($this->_conf_obj)) {
|
// get path to compiled object file
|
||||||
require_once SMARTY_DIR . $this->config_class . '.class.php';
|
$_compile_file = $this->_get_auto_filename($this->compile_dir, $file . $section, 'SMARTY_CONFIG');
|
||||||
$this->_conf_obj = new Config_File($_config_dir);
|
|
||||||
$this->_conf_obj->overwrite = $this->config_overwrite;
|
// need to generate cache?
|
||||||
$this->_conf_obj->booleanize = $this->config_booleanize;
|
if($this->force_compile ||
|
||||||
$this->_conf_obj->read_hidden = $this->config_read_hidden;
|
($this->compile_check && ( @filemtime($_compile_file) != @filemtime($_file_path) ))) {
|
||||||
$this->_conf_obj->fix_newlines = $this->config_fix_newlines;
|
$_generate_cache = true;
|
||||||
|
} else {
|
||||||
|
include($_compile_file);
|
||||||
|
if(empty($_config_vars)) {
|
||||||
|
$_generate_cache = true;
|
||||||
|
} else {
|
||||||
|
$_generate_cache = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->_config[0]['files'][$file])) {
|
if($_generate_cache) {
|
||||||
// get path to compiled object file
|
if(!is_object($this->_conf_obj)) {
|
||||||
$_cache_file = $this->_get_auto_filename($this->cache_dir, $file, 'SMARTY_CONFIG');
|
require_once SMARTY_DIR . $this->config_class . '.class.php';
|
||||||
|
$this->_conf_obj = new Config_File($_config_dir);
|
||||||
// see if cache file is up to date
|
$this->_conf_obj->overwrite = $this->config_overwrite;
|
||||||
if(@filemtime($_cache_file) == @filemtime($_file_path)) {
|
$this->_conf_obj->booleanize = $this->config_booleanize;
|
||||||
// load cache file
|
$this->_conf_obj->read_hidden = $this->config_read_hidden;
|
||||||
$this->_conf_obj = unserialize($this->_read_file($_cache_file));
|
$this->_conf_obj->fix_newlines = $this->config_fix_newlines;
|
||||||
} else {
|
$this->_conf_obj->set_path = $_config_dir;
|
||||||
// load file and save cache
|
}
|
||||||
$this->_conf_obj->load_file($file);
|
if($_config_vars = $this->_conf_obj->get($file, $section)) {
|
||||||
$_conf_obj_file_contents = serialize($this->_conf_obj);
|
$this->_write_file($_compile_file,
|
||||||
$this->_write_file($_cache_file, $_conf_obj_file_contents, true);
|
'<?php $_config_vars = unserialize(\'' . str_replace('\'','\\\'', serialize($_config_vars)) . '\'); ?>',
|
||||||
touch($_cache_file,filemtime($_file_path));
|
true);
|
||||||
}
|
touch($_compile_file,filemtime($_file_path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
@@ -1270,35 +1278,19 @@ function _generate_debug_output() {
|
|||||||
$this->_cache_info['config'][] = $file;
|
$this->_cache_info['config'][] = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->_config[0]['files'][$file])) {
|
$this->_config[0]['vars'] = @array_merge($this->_config[0]['vars'], $_config_vars);
|
||||||
$this->_config[0]['vars'] = @array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file));
|
$this->_config[0]['files'][$file] = true;
|
||||||
$this->_config[0]['files'][$file] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($scope == 'parent') {
|
if ($scope == 'parent') {
|
||||||
if (count($this->_config) > 0 && !isset($this->_config[1]['files'][$file])) {
|
$this->_config[1]['vars'] = @array_merge($this->_config[1]['vars'], $_config_vars);
|
||||||
$this->_config[1]['vars'] = @array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file));
|
|
||||||
$this->_config[1]['files'][$file] = true;
|
$this->_config[1]['files'][$file] = true;
|
||||||
}
|
|
||||||
} else if ($scope == 'global') {
|
} else if ($scope == 'global') {
|
||||||
for ($i = 1, $for_max = count($this->_config); $i < $for_max; $i++) {
|
for ($i = 1, $for_max = count($this->_config); $i < $for_max; $i++) {
|
||||||
if (!isset($this->_config[$i]['files'][$file])) {
|
$this->_config[$i]['vars'] = @array_merge($this->_config[$i]['vars'], $_config_vars);
|
||||||
$this->_config[$i]['vars'] = @array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file));
|
|
||||||
$this->_config[$i]['files'][$file] = true;
|
$this->_config[$i]['files'][$file] = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($section)) {
|
|
||||||
$this->_config[0]['vars'] = @array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file, $section));
|
|
||||||
if ($scope == 'parent') {
|
|
||||||
if (count($this->_config) > 0)
|
|
||||||
$this->_config[1]['vars'] = @array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file, $section));
|
|
||||||
} 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'], $this->_conf_obj->get($file, $section));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'config',
|
$this->_smarty_debug_info[] = array('type' => 'config',
|
||||||
|
@@ -256,7 +256,7 @@ class Config_File {
|
|||||||
$fp = @fopen($config_file, "r");
|
$fp = @fopen($config_file, "r");
|
||||||
if (!is_resource($fp)) {
|
if (!is_resource($fp)) {
|
||||||
$this->_trigger_error_msg("Could not open config file '$config_file'");
|
$this->_trigger_error_msg("Could not open config file '$config_file'");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contents = fread($fp, filesize($config_file));
|
$contents = fread($fp, filesize($config_file));
|
||||||
@@ -286,6 +286,8 @@ class Config_File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->_config_data[$config_file] = $config_data;
|
$this->_config_data[$config_file] = $config_data;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1234,32 +1234,40 @@ function _generate_debug_output() {
|
|||||||
$this->_get_include_path($this->config_dir,$_config_dir);
|
$this->_get_include_path($this->config_dir,$_config_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_file_path = $_config_dir . '/' . $file;
|
$_file_path = str_replace('//', '/' ,$_config_dir . '/' . $file);
|
||||||
|
|
||||||
if(!is_object($this->_conf_obj)) {
|
// get path to compiled object file
|
||||||
require_once SMARTY_DIR . $this->config_class . '.class.php';
|
$_compile_file = $this->_get_auto_filename($this->compile_dir, $file . $section, 'SMARTY_CONFIG');
|
||||||
$this->_conf_obj = new Config_File($_config_dir);
|
|
||||||
$this->_conf_obj->overwrite = $this->config_overwrite;
|
// need to generate cache?
|
||||||
$this->_conf_obj->booleanize = $this->config_booleanize;
|
if($this->force_compile ||
|
||||||
$this->_conf_obj->read_hidden = $this->config_read_hidden;
|
($this->compile_check && ( @filemtime($_compile_file) != @filemtime($_file_path) ))) {
|
||||||
$this->_conf_obj->fix_newlines = $this->config_fix_newlines;
|
$_generate_cache = true;
|
||||||
|
} else {
|
||||||
|
include($_compile_file);
|
||||||
|
if(empty($_config_vars)) {
|
||||||
|
$_generate_cache = true;
|
||||||
|
} else {
|
||||||
|
$_generate_cache = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->_config[0]['files'][$file])) {
|
if($_generate_cache) {
|
||||||
// get path to compiled object file
|
if(!is_object($this->_conf_obj)) {
|
||||||
$_cache_file = $this->_get_auto_filename($this->cache_dir, $file, 'SMARTY_CONFIG');
|
require_once SMARTY_DIR . $this->config_class . '.class.php';
|
||||||
|
$this->_conf_obj = new Config_File($_config_dir);
|
||||||
// see if cache file is up to date
|
$this->_conf_obj->overwrite = $this->config_overwrite;
|
||||||
if(@filemtime($_cache_file) == @filemtime($_file_path)) {
|
$this->_conf_obj->booleanize = $this->config_booleanize;
|
||||||
// load cache file
|
$this->_conf_obj->read_hidden = $this->config_read_hidden;
|
||||||
$this->_conf_obj = unserialize($this->_read_file($_cache_file));
|
$this->_conf_obj->fix_newlines = $this->config_fix_newlines;
|
||||||
} else {
|
$this->_conf_obj->set_path = $_config_dir;
|
||||||
// load file and save cache
|
}
|
||||||
$this->_conf_obj->load_file($file);
|
if($_config_vars = $this->_conf_obj->get($file, $section)) {
|
||||||
$_conf_obj_file_contents = serialize($this->_conf_obj);
|
$this->_write_file($_compile_file,
|
||||||
$this->_write_file($_cache_file, $_conf_obj_file_contents, true);
|
'<?php $_config_vars = unserialize(\'' . str_replace('\'','\\\'', serialize($_config_vars)) . '\'); ?>',
|
||||||
touch($_cache_file,filemtime($_file_path));
|
true);
|
||||||
}
|
touch($_compile_file,filemtime($_file_path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
@@ -1270,35 +1278,19 @@ function _generate_debug_output() {
|
|||||||
$this->_cache_info['config'][] = $file;
|
$this->_cache_info['config'][] = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->_config[0]['files'][$file])) {
|
$this->_config[0]['vars'] = @array_merge($this->_config[0]['vars'], $_config_vars);
|
||||||
$this->_config[0]['vars'] = @array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file));
|
$this->_config[0]['files'][$file] = true;
|
||||||
$this->_config[0]['files'][$file] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($scope == 'parent') {
|
if ($scope == 'parent') {
|
||||||
if (count($this->_config) > 0 && !isset($this->_config[1]['files'][$file])) {
|
$this->_config[1]['vars'] = @array_merge($this->_config[1]['vars'], $_config_vars);
|
||||||
$this->_config[1]['vars'] = @array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file));
|
|
||||||
$this->_config[1]['files'][$file] = true;
|
$this->_config[1]['files'][$file] = true;
|
||||||
}
|
|
||||||
} else if ($scope == 'global') {
|
} else if ($scope == 'global') {
|
||||||
for ($i = 1, $for_max = count($this->_config); $i < $for_max; $i++) {
|
for ($i = 1, $for_max = count($this->_config); $i < $for_max; $i++) {
|
||||||
if (!isset($this->_config[$i]['files'][$file])) {
|
$this->_config[$i]['vars'] = @array_merge($this->_config[$i]['vars'], $_config_vars);
|
||||||
$this->_config[$i]['vars'] = @array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file));
|
|
||||||
$this->_config[$i]['files'][$file] = true;
|
$this->_config[$i]['files'][$file] = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($section)) {
|
|
||||||
$this->_config[0]['vars'] = @array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file, $section));
|
|
||||||
if ($scope == 'parent') {
|
|
||||||
if (count($this->_config) > 0)
|
|
||||||
$this->_config[1]['vars'] = @array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file, $section));
|
|
||||||
} 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'], $this->_conf_obj->get($file, $section));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'config',
|
$this->_smarty_debug_info[] = array('type' => 'config',
|
||||||
|
Reference in New Issue
Block a user