|
PHP复制代码 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);
} 复制代码
这段函数一直没看懂,导致后面的代码修改触壁了~~能不能做一个详细点的解释
|
|