setting类没有看懂
function __construct(){
$this->load('site');
}
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$file = ($file == '') ? 'site' : str_replace(EXT, '', $file);
$loaded = FALSE;
foreach($this->_setting_paths as $path)
{
$file_path = $path.'../settings/'.$file.EXT;
if (in_array($file_path, $this->is_loaded, TRUE))
{
$loaded = TRUE;
continue;
}
if ( ! file_exists($path.'../settings/'.$file.EXT))
{
continue;
}
include($file_path);
if ( ! isset($setting) OR ! is_array($setting))
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
}
if ($use_sections === TRUE)
{
if (isset($this->setting[$file]))
{
$this->setting[$file] = array_merge($this->setting[$file], $setting);
}
else
{
$this->setting[$file] = $setting;
}
}
else
{
$this->setting = array_merge_recursive($this->setting, $setting);
}
$this->is_loaded[] = $file_path;
unset($setting);
$loaded = TRUE;
}
if ($loaded === FALSE)
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('The configuration file '.$file.EXT.' does not exist.');
}
return TRUE;
}
function item($item, $index = '')
{
if ($index == '')
{
if ( ! isset($this->setting[$item]))
{
return FALSE;
}
$pref = $this->setting[$item];
}
else
{
if ( ! isset($this->setting[$index]))
{
return FALSE;
}
if ( ! isset($this->setting[$index][$item]))
{
return FALSE;
}
$pref = $this->setting[$index][$item];
}
return $pref;
}
function set_item($item, $value)
{
$this->setting[$item] = $value;
}
}
//setting helper
function setting($key)
{
$ci = &get_instance();
return $ci->settings->item($key);
}
这段函数一直没看懂,导致后面的代码修改触壁了~~能不能做一个详细点的解释
这个类其实就是ci的config类,你可以对比一下,:-) 我也看到这里,我看到是在dili控制器里加载进来的, 这样和他原先的config类会不会重复了? godsoul 发表于 2011-11-14 21:44 static/image/common/back.gif
我也看到这里,我看到是在dili控制器里加载进来的, 这样和他原先的config类会不会重复了? ...
不重复哈,因为改造过了{:1_1:}
页:
[1]