public function start($formName) { $array = array("class" => "form-horizontal", "role" => "form", "enctype" => "multipart/form-data", "id" => "plugAdd"); $this->init($formName, '/index.php?m=admin&c=plug&a=save', '', $array); $array = array("class" => "form-control", "placeholder" => "请输入插件标识"); $this->setText("name", "标识名", $array, array('datatype' => '*2-24')); $array = array("class" => "form-control", "placeholder" => "请输入插件名"); $this->setText("title", "插件名", $array, array('datatype' => '*2-24')); $array = array("class" => "form-control", "placeholder" => "请输入作者"); $this->setText("author", "作者", $array, array('datatype' => '*2-24')); $array = array("class" => "form-control", "placeholder" => "请输入版本"); $this->setText("version", "版本", $array, array('datatype' => '*2-24')); $array = array("class" => "form-control", "style" => "height:100px", "placeholder" => "请输入描述"); $this->setTextArea("description", "描述", $array, array('datatype' => '*0-512')); $array = array("class" => "make-switch", "data-on-color" => "primary", "data-off-color" => "info"); $this->setBsCheckBox("enable", "是否启用", $array); $array = array("class" => "make-switch", "data-on-color" => "primary", "data-off-color" => "info"); $this->setBsCheckBox("isConfig", "是否需要配置", $array); $array = array("class" => "make-switch", "data-on-color" => "primary", "data-off-color" => "info"); $this->setBsCheckBox("isAdminList", "是否需要后台列表", $array); $array = array("class" => "bs-select form-control", "multiple" => "true"); $hookModel = new \Admin\Model\hookModel(); $hookArr = $hookModel->getHookList(); $this->setSelect("hookName[]", "实现的钩子方法", $array, $hookArr, 3); }
/** * 卸载插件 */ public function uninstallAction() { $id = post("val", "int"); $row = db()->table("plugs")->getRow(array("id" => $id))->done(); $hookModel = new \Admin\Model\hookModel(); if (!$row) { JsonObject(array('status' => false, 'msg' => "插件不存在")); } $class = getPlugClass($row['name']); if (!class_exists($class)) { JsonObject(array('status' => false, 'msg' => '插件文件缺失,卸载失败')); } $plugs = new $class(); $uninstall_flag = $plugs->uninstall(); if (!$uninstall_flag) { JsonObject(array('status' => false, 'msg' => '执行插件预卸载操作失败')); } db()->beginTransaction(); $r1 = db()->table("plugs")->delete(array("id" => $id))->done(); $r2 = $hookModel->removeHooks($row['name']); if ($r1 && $r2) { $this->deletePlugDir($row['name']); //db()->commit(); JsonObject(array('status' => true, 'msg' => '卸载成功')); } else { db()->rollBack(); JsonObject(array('status' => false, 'msg' => '卸载失败')); } }