获取插件类的配置文件数组:
/**
* 获取插件类的配置文件数组
* @param string $name 插件名
*/
function get_addon_config($name){
$class = get_addon_class($name);
if(class_exists($class)) {
$addon = new $class();
return $addon->getConfig();
}else {
return array();
}
}
获取插件类的类名 get_addon_class()函数:
/**
* 获取插件类的类名
* @param strng $name 插件名
*/
function get_addon_class($name){
$class = "Addons\\{$name}\\{$name}Addon";
return $class;
}
获取插件的配置数组:
/**
* 获取插件的配置数组
*/
final public function getConfig($name=''){
static $_config = array();
if(empty($name)){
$name = $this->getName();
}
if(isset($_config[$name])){
return $_config[$name];
}
$config = array();
$map['name'] = $name;
$map['status'] = 1;
$config = M('Addons')->where($map)->getField('config');
if($config){
$config = json_decode($config, true);
}else{
$temp_arr = include $this->config_file;
foreach ($temp_arr as $key => $value) {
if($value['type'] == 'group'){
foreach ($value['options'] as $gkey => $gvalue) {
foreach ($gvalue['options'] as $ikey => $ivalue) {
$config[$ikey] = $ivalue['value'];
}
}
}else{
$config[$key] = $temp_arr[$key]['value'];
}
}
}
$_config[$name] = $config;
return $config;
}
发表评论 取消回复