From 4492c1788fa5afe2fdbfb56495bccaa1a7f4a59d Mon Sep 17 00:00:00 2001 From: chekun <234267695@qq.com> Date: Fri, 14 Nov 2014 18:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90#50?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/helpers/common_helper.php | 34 +++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/shared/helpers/common_helper.php b/shared/helpers/common_helper.php index fb58047..4a8b646 100755 --- a/shared/helpers/common_helper.php +++ b/shared/helpers/common_helper.php @@ -32,15 +32,35 @@ * 读取配置数据 * * @access public - * @param string + * @param string * @return mixed */ if ( ! function_exists('setting')) { - function setting($key) + function setting($key, $default = null) { $ci = &get_instance(); - return $ci->settings->item($key); + + $sequences = explode('.', $key); + + $key = array_shift($sequences); + + $tmp_result = $ci->settings->item($key); + + for ($i = 0, $total = count($sequences); $i < $total; ) + { + + if (isset($tmp_result[$sequences[$i]])) + { + $tmp_result = $tmp_result[$sequences[$i]]; + $i ++; + } else { + return $default; + } + + } + + return $tmp_result; } } @@ -83,8 +103,8 @@ function update_cache($array, $fix = '') { function array_to_cache($name, $array) { - return 'config->item('index_page') === '') + if (false and $ci->config->item('index_page') === '') { return backend_url("plugin/$name/$controller/$method", http_build_query($qs)); } @@ -133,4 +153,4 @@ function plugin_url($plugin, $controller, $method = 'index', $qs = array()) // ------------------------------------------------------------------------ /* End of file common_helper.php */ -/* Location: ./shared/heleprs/common_helper.php */ \ No newline at end of file +/* Location: ./shared/heleprs/common_helper.php */