/** * 去除插件所有钩子里对应的插件数据 * @param $plug_name * @return bool */ public function removeHooks($plug_name) { $plug_class = getPlugClass($plug_name); if (!class_exists($plug_class)) { return false; } $methods = get_class_methods($plug_class); $_hooks = db()->table("hook")->getAll()->fields('name')->done(); $hooks = array(); foreach ($_hooks as $v) { $hooks[] = $v['name']; } $common = array_intersect($hooks, $methods); if ($common) { foreach ($common as $hook) { $flag = $this->removePlugs($hook, array($plug_name)); if (false === $flag) { return false; } } } return true; }
/** * 插件设置 */ public function settingAction() { $id = get("id", "int"); if (!$id) { return $this->link()->error("参数错误"); } $plug = db()->table("plugs")->getRow(array('id' => $id))->done(); if (!$plug) { return $this->link()->error("插件未安装"); } $plugClass = getPlugClass($plug['name']); if (!class_exists($plugClass)) { trace("插件{$plug['name']}无法实例化,", 'ADDONS', 'ERR'); } $data = new $plugClass(); $dbConfig = $plug['config']; $plug['config'] = (include $data->config_file); if ($dbConfig) { $dbConfig = json_decode($dbConfig, true); foreach ($plug['config'] as $key => $value) { if ($value['type'] != 'group') { $plug['config'][$key]['value'] = $dbConfig[$key]; } else { foreach ($value['options'] as $gourp => $options) { foreach ($options['options'] as $gkey => $value) { $plug['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $dbConfig[$gkey]; } } } } } $this->getView()->assign(array('data' => $plug, 'id' => $id)); $this->getView()->display(); }
/** * 获取插件信息 * @param $pluginClassName * @return mixed */ function getPluginData($name) { $pluginClassName = getPlugClass($name); $plug = new $pluginClassName(); return $plug->info; }