Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #51 from DiliCMS/develop
Browse files Browse the repository at this point in the history
[PR] 完成#50, setting 支持.穿越操作
  • Loading branch information
Che Kun committed Nov 14, 2014
2 parents 16bee07 + 4492c17 commit 3e8d9c7
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions shared/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -83,8 +103,8 @@ function update_cache($array, $fix = '')
{
function array_to_cache($name, $array)
{
return '<?php if ( ! defined(\'IN_DILICMS\')) exit(\'No direct script access allowed\');' . PHP_EOL .
'$' . $name . '=' . var_export($array, TRUE) . ';';
return '<?php if ( ! defined(\'IN_DILICMS\')) exit(\'No direct script access allowed\');' . PHP_EOL .
'$' . $name . '=' . var_export($array, TRUE) . ';';
}
}

Expand Down Expand Up @@ -119,7 +139,7 @@ function backend_url($uri = '', $qs = '')
function plugin_url($plugin, $controller, $method = 'index', $qs = array())
{
$ci = &get_instance();
if (false and $ci->config->item('index_page') === '')
if (false and $ci->config->item('index_page') === '')
{
return backend_url("plugin/$name/$controller/$method", http_build_query($qs));
}
Expand All @@ -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 */
/* Location: ./shared/heleprs/common_helper.php */

0 comments on commit 3e8d9c7

Please sign in to comment.