00001 <?php 00027 function smarty_function_config_load($params, &$smarty) 00028 { 00029 if ($smarty->debugging) { 00030 $_params = array(); 00031 require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); 00032 $_debug_start_time = smarty_core_get_microtime($_params, $smarty); 00033 } 00034 00035 $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null; 00036 $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null; 00037 $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global'; 00038 $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false; 00039 00040 if (!isset($_file) || strlen($_file) == 0) { 00041 $smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__); 00042 } 00043 00044 if (isset($_scope)) { 00045 if ($_scope != 'local' && 00046 $_scope != 'parent' && 00047 $_scope != 'global') { 00048 $smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__); 00049 } 00050 } else { 00051 if ($_global) { 00052 $_scope = 'parent'; 00053 } else { 00054 $_scope = 'local'; 00055 } 00056 } 00057 00058 $_params = array('resource_name' => $_file, 00059 'resource_base_path' => $smarty->config_dir, 00060 'get_source' => false); 00061 $smarty->_parse_resource_name($_params); 00062 $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; 00063 if (isset($_section)) 00064 $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); 00065 else 00066 $_compile_file = $smarty->_get_compile_path($_file_path); 00067 00068 if($smarty->force_compile || !file_exists($_compile_file)) { 00069 $_compile = true; 00070 } elseif ($smarty->compile_check) { 00071 $_params = array('resource_name' => $_file, 00072 'resource_base_path' => $smarty->config_dir, 00073 'get_source' => false); 00074 $_compile = $smarty->_fetch_resource_info($_params) && 00075 $_params['resource_timestamp'] > filemtime($_compile_file); 00076 } else { 00077 $_compile = false; 00078 } 00079 00080 if($_compile) { 00081 // compile config file 00082 if(!is_object($smarty->_conf_obj)) { 00083 require_once SMARTY_DIR . $smarty->config_class . '.class.php'; 00084 $smarty->_conf_obj = new $smarty->config_class(); 00085 $smarty->_conf_obj->overwrite = $smarty->config_overwrite; 00086 $smarty->_conf_obj->booleanize = $smarty->config_booleanize; 00087 $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden; 00088 $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines; 00089 } 00090 00091 $_params = array('resource_name' => $_file, 00092 'resource_base_path' => $smarty->config_dir, 00093 $_params['get_source'] = true); 00094 if (!$smarty->_fetch_resource_info($_params)) { 00095 return; 00096 } 00097 $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']); 00098 $_config_vars = array_merge($smarty->_conf_obj->get($_file), 00099 $smarty->_conf_obj->get($_file, $_section)); 00100 if(function_exists('var_export')) { 00101 $_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>'; 00102 } else { 00103 $_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>'; 00104 } 00105 $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp'])); 00106 require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php'); 00107 smarty_core_write_compiled_resource($_params, $smarty); 00108 } else { 00109 include($_compile_file); 00110 } 00111 00112 if ($smarty->caching) { 00113 $smarty->_cache_info['config'][$_file] = true; 00114 } 00115 00116 $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars); 00117 $smarty->_config[0]['files'][$_file] = true; 00118 00119 if ($_scope == 'parent') { 00120 $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars); 00121 $smarty->_config[1]['files'][$_file] = true; 00122 } else if ($_scope == 'global') { 00123 for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) { 00124 $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars); 00125 $smarty->_config[$i]['files'][$_file] = true; 00126 } 00127 } 00128 00129 if ($smarty->debugging) { 00130 $_params = array(); 00131 require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); 00132 $smarty->_smarty_debug_info[] = array('type' => 'config', 00133 'filename' => $_file.' ['.$_section.'] '.$_scope, 00134 'depth' => $smarty->_inclusion_depth, 00135 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); 00136 } 00137 00138 } 00139 00140 /* vim: set expandtab: */ 00141 00142 ?>
| Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|
