扩展插件完善优化
This commit is contained in:
@@ -205,15 +205,19 @@ class Addons extends Base {
|
||||
*/
|
||||
public function addhook() {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $hooks->change();
|
||||
$data = $this->request->post();
|
||||
$data['addons'] = isset($data['addons'][0]) ? $data['addons'][0] : [];
|
||||
|
||||
$result = Hooks::create($data);
|
||||
if ($result !== false) {
|
||||
return $this->success("修改成功");
|
||||
return $this->success("添加成功");
|
||||
} else {
|
||||
return $this->error($hooks->getError());
|
||||
return $this->error('添加失败!');
|
||||
}
|
||||
} else {
|
||||
$keylist = Hooks::getaddons([]);
|
||||
$this->data = array(
|
||||
'keyList' => Hooks::$keylist,
|
||||
'keyList' => $keylist,
|
||||
);
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
@@ -225,12 +229,13 @@ class Addons extends Base {
|
||||
public function edithook($id) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$data['addons'] = isset($data['addons'][0]) ? $data['addons'][0] : [];
|
||||
|
||||
$result = Hooks::update($data, ['id' => $data['id']]);
|
||||
if ($result !== false) {
|
||||
return $this->success("修改成功");
|
||||
} else {
|
||||
return $this->error($hooks->getError());
|
||||
return $this->error('修改失败!');
|
||||
}
|
||||
} else {
|
||||
$info = Hooks::find($id);
|
||||
|
||||
@@ -29,6 +29,10 @@ class Base extends BaseC {
|
||||
if ($template == '') {
|
||||
$template = str_replace(".", "@", strtolower($this->request->controller())) . "/" . $this->request->action();
|
||||
}
|
||||
if($this->request->param('addon')){
|
||||
$this->tpl_config['view_depr'] = '/';
|
||||
$this->tpl_config['view_dir_name'] = 'addons' . DIRECTORY_SEPARATOR . $this->request->param('addon') . DIRECTORY_SEPARATOR . 'view';
|
||||
}
|
||||
|
||||
View::config($this->tpl_config);
|
||||
View::assign($this->data);
|
||||
|
||||
@@ -20,8 +20,8 @@ class Hooks extends \think\Model {
|
||||
}
|
||||
|
||||
protected function setAddonsAttr($value){
|
||||
if (!empty($value[0])) {
|
||||
return implode(",", $value[0]);
|
||||
if (is_array($value) && !empty($value)) {
|
||||
return implode(",", $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@ class Hooks extends \think\Model {
|
||||
if (isset($row[$value]) && !empty($row[$value])) {
|
||||
$info = $row[$value];
|
||||
$addons = $info['addons'] ? explode(",", $info['addons']) : [];
|
||||
empty($addons) ? [$name] : array_push($addons, $name);
|
||||
$info['addons'] = implode(",", $addons);
|
||||
$info['addons'] = empty($addons) ? [$name] : array_push($addons, $name);
|
||||
$save[] = $info;
|
||||
}else{
|
||||
$save[] = ['name' => $value, 'type' => 1, 'create_time' => time(), 'status' => 1, 'addons'=> $name];
|
||||
|
||||
Reference in New Issue
Block a user