+++ /dev/null
-<?php\r
-/**\r
- * Smarty plugin\r
- * @package Smarty\r
- * @subpackage plugins\r
- */\r
-\r
-/**\r
- * Smarty {config_load} function plugin\r
- *\r
- * Type: function<br>\r
- * Name: config_load<br>\r
- * Purpose: load config file vars\r
- * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load}\r
- * (Smarty online manual)\r
- * @param array Format:\r
- * <pre>\r
- * array('file' => required config file name,\r
- * 'section' => optional config file section to load\r
- * 'scope' => local/parent/global\r
- * 'global' => overrides scope, setting to parent if true)\r
- * </pre>\r
- * @param Smarty\r
- */\r
-function smarty_function_config_load($params, &$smarty)\r
-{\r
- if ($smarty->debugging) {\r
- $_params = array();\r
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');\r
- $_debug_start_time = smarty_core_get_microtime($_params, $smarty);\r
- }\r
-\r
- $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;\r
- $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;\r
- $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';\r
- $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;\r
-\r
- if (!isset($_file) || strlen($_file) == 0) {\r
- $smarty->_syntax_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);\r
- }\r
-\r
- if (isset($_scope)) {\r
- if ($_scope != 'local' &&\r
- $_scope != 'parent' &&\r
- $_scope != 'global') {\r
- $smarty->_syntax_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);\r
- }\r
- } else {\r
- if ($_global) {\r
- $_scope = 'parent';\r
- } else {\r
- $_scope = 'local';\r
- }\r
- } \r
- \r
- if(@is_dir($smarty->config_dir)) {\r
- $_config_dir = $smarty->config_dir; \r
- } else {\r
- // config_dir not found, try include_path\r
- $_params = array('file_path' => $smarty->config_dir);\r
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');\r
- smarty_core_get_include_path($_params, $smarty);\r
- $_config_dir = $_params['new_file_path'];\r
- }\r
-\r
- $_file_path = $_config_dir . DIRECTORY_SEPARATOR . $_file;\r
- if (isset($_section)) \r
- $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);\r
- else\r
- $_compile_file = $smarty->_get_compile_path($_file_path);\r
- \r
- if($smarty->force_compile\r
- || !file_exists($_compile_file)\r
- || ($smarty->compile_check\r
- && !$smarty->_is_compiled($_file_path, $_compile_file))) {\r
- // compile config file\r
- if(!is_object($smarty->_conf_obj)) {\r
- require_once SMARTY_DIR . $smarty->config_class . '.class.php';\r
- $smarty->_conf_obj = new $smarty->config_class($_config_dir);\r
- $smarty->_conf_obj->overwrite = $smarty->config_overwrite;\r
- $smarty->_conf_obj->booleanize = $smarty->config_booleanize;\r
- $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;\r
- $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;\r
- $smarty->_conf_obj->set_path = $_config_dir;\r
- }\r
- $_config_vars = array_merge($smarty->_conf_obj->get($_file),\r
- $smarty->_conf_obj->get($_file, $_section));\r
- if(function_exists('var_export')) {\r
- $_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';\r
- } else {\r
- $_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';\r
- }\r
- $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => filemtime($_file_path)));\r
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');\r
- smarty_core_write_compiled_resource($_params, $smarty);\r
- } else {\r
- include($_compile_file);\r
- }\r
-\r
- if ($smarty->caching) {\r
- $smarty->_cache_info['config'][$_file] = true;\r
- }\r
-\r
- $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);\r
- $smarty->_config[0]['files'][$_file] = true;\r
- \r
- if ($_scope == 'parent') {\r
- $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);\r
- $smarty->_config[1]['files'][$_file] = true;\r
- } else if ($_scope == 'global') {\r
- for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {\r
- $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);\r
- $smarty->_config[$i]['files'][$_file] = true;\r
- }\r
- }\r
- \r
- if ($smarty->debugging) {\r
- $_params = array();\r
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');\r
- $smarty->_smarty_debug_info[] = array('type' => 'config',\r
- 'filename' => $_file.' ['.$_section.'] '.$_scope,\r
- 'depth' => $smarty->_inclusion_depth,\r
- 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);\r
- }\r
- \r
-}\r
-\r
-/* vim: set expandtab: */\r
-\r
-?>\r