123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- // +----------------------------------------------------------------------
- // | Yzncms [ 御宅男工作室 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2018 http://yzncms.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 御宅男 <530765310@qq.com>
- // +----------------------------------------------------------------------
-
- // +----------------------------------------------------------------------
- // | 表单插件
- // +----------------------------------------------------------------------
- namespace addons\formguide;
-
- use app\common\library\Menu;
- use think\Addons;
- use think\Db;
- use think\facade\Config;
-
- class Formguide extends Addons
- {
- //后台菜单
- public $menu = [
- [
- "name" => "formguide",
- "title" => "表单管理",
- "icon" => "iconfont icon-file-list-3-line",
- "sublist" => [
- [
- "name" => "formguide.formguide",
- "title" => "表单管理",
- "icon" => "iconfont icon-file-list-3-line",
- "sublist" => [
- ["name" => "formguide.formguide/index", "title" => "查看"],
- ["name" => "formguide.formguide/add", "title" => "新增"],
- ["name" => "formguide.formguide/edit", "title" => "编辑"],
- ["name" => "formguide.formguide/del", "title" => "删除"],
- ],
- ],
- [
- "name" => "formguide.field",
- "title" => "字段管理",
- "ismenu" => 0,
- "sublist" => [
- ["name" => "formguide.field/index", "title" => "查看"],
- ["name" => "formguide.field/add", "title" => "新增"],
- ["name" => "formguide.field/edit", "title" => "编辑"],
- ["name" => "formguide.field/del", "title" => "删除"],
- ["name" => "formguide.info/index", "title" => "信息列表"],
- ["name" => "formguide.info/public_view", "title" => "信息查看"],
- ["name" => "formguide.info/del", "title" => "信息删除"],
- ],
- ],
-
- ],
- ],
- ];
-
- //安装
- public function install()
- {
- $info = get_addon_info('cms');
- if (!$info || $info['status'] != 1) {
- throw new \think\Exception("请在后台插件管理中安装《内容管理系统》并启用后再尝试");
- }
- Menu::create($this->menu);
- return true;
- }
-
- /**
- * 插件卸载方法
- * @return bool
- */
- public function uninstall()
- {
- $droptables = request()->param("droptables");
- $auth = \app\admin\service\User::instance();
- //只有开启调试且为超级管理员才允许删除相关数据库
- if ($droptables && Config::get("app_debug") && $auth->isAdministrator()) {
- //删除模型中建的表
- $table_list = Db::name('model')->where('module', 'formguide')->field('tablename,id')->select();
- if ($table_list) {
- foreach ($table_list as $val) {
- $tablename = Config::get('database.prefix') . $val['tablename'];
- Db::execute("DROP TABLE IF EXISTS `{$tablename}`;");
- Db::name('model_field')->where('modelid', $val['id'])->delete();
- }
- }
- }
- //删除模型中的表
- Db::name('model')->where('module', 'formguide')->delete();
- Menu::delete("formguide");
- return true;
- }
-
- /**
- * 插件启用方法
- * @return bool
- */
- public function enable()
- {
- Menu::enable("formguide");
- return true;
- }
-
- /**
- * 插件禁用方法
- * @return bool
- */
- public function disable()
- {
- Menu::disable("formguide");
- return true;
- }
-
- }
|