插件机制完善
This commit is contained in:
@@ -15,6 +15,7 @@ use think\facade\Cache;
|
||||
use think\Validate;
|
||||
use app\model\Config;
|
||||
use think\facade\Route;
|
||||
use app\model\Hooks;
|
||||
|
||||
class Base {
|
||||
|
||||
@@ -71,7 +72,11 @@ class Base {
|
||||
$config = Config::getConfigList($this->request);
|
||||
Cache::set('system_config_data', $config);
|
||||
}
|
||||
config($config, 'config');
|
||||
$hooks = Hooks::where('status', 1)->column('addons', 'name');
|
||||
foreach($hooks as $key => $value){
|
||||
$hooks[$key] = $value ? explode(",", $value) : [];
|
||||
}
|
||||
Cache::set('sentcms_hooks', $hooks);
|
||||
View::assign('config', $config);
|
||||
// 控制器初始化
|
||||
$this->initialize();
|
||||
|
||||
@@ -56,6 +56,20 @@ class Upload extends Base {
|
||||
echo $data->output();
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$id = $this->request->param('id', 0);
|
||||
if(!$id){
|
||||
$data = [
|
||||
'status' => false
|
||||
];
|
||||
}else{
|
||||
$data = [
|
||||
'status' => true
|
||||
];
|
||||
}
|
||||
return json($data);
|
||||
}
|
||||
|
||||
protected function save($file, $upload_type){
|
||||
$data = [];
|
||||
$savename = Filesystem::disk('public')->putFile($upload_type, $file, 'md5');
|
||||
|
||||
@@ -23,7 +23,7 @@ class Addons extends Base {
|
||||
public function index($refresh = 0) {
|
||||
$map = [];
|
||||
if ($refresh) {
|
||||
AddonsM::refreshAddons();
|
||||
AddonsM::refreshAddons($this->app->getRootPath() . 'addons' . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$list = AddonsM::where($map)->order('id desc')->paginate($this->request->pageConfig);
|
||||
@@ -36,33 +36,9 @@ class Addons extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加插件
|
||||
* @title 删除插件
|
||||
*/
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->addons->create();
|
||||
if ($data) {
|
||||
if ($result) {
|
||||
return $this->success("创建成功!", url('admin/addons/index'));
|
||||
} else {
|
||||
return $this->error("创建失败!");
|
||||
}
|
||||
} else {
|
||||
return $this->error($this->addons->getError());
|
||||
}
|
||||
} else {
|
||||
// $hooks = db('Hooks')->field('name,description')->select();
|
||||
// $this->assign('Hooks', $hooks);
|
||||
// $hook = db('Hooks')->field(true)->select();
|
||||
// foreach ($hook as $key => $value) {
|
||||
// $addons_opt[$value['name']] = $value['name'];
|
||||
// }
|
||||
// $addons_opt = array(array('type' => 'select', 'opt' => $addons_opt));
|
||||
// if (!is_writable(SENT_ADDON_PATH)) {
|
||||
// return $this->error('您没有创建目录写入权限,无法使用此功能');
|
||||
// }
|
||||
return $this->fetch();
|
||||
}
|
||||
public function del() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user