控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Formguide.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 表单插件
  13. // +----------------------------------------------------------------------
  14. namespace addons\formguide;
  15. use app\common\library\Menu;
  16. use think\Addons;
  17. use think\Db;
  18. use think\facade\Config;
  19. class Formguide extends Addons
  20. {
  21. //后台菜单
  22. public $menu = [
  23. [
  24. "name" => "formguide",
  25. "title" => "表单管理",
  26. "icon" => "iconfont icon-file-list-3-line",
  27. "sublist" => [
  28. [
  29. "name" => "formguide.formguide",
  30. "title" => "表单管理",
  31. "icon" => "iconfont icon-file-list-3-line",
  32. "sublist" => [
  33. ["name" => "formguide.formguide/index", "title" => "查看"],
  34. ["name" => "formguide.formguide/add", "title" => "新增"],
  35. ["name" => "formguide.formguide/edit", "title" => "编辑"],
  36. ["name" => "formguide.formguide/del", "title" => "删除"],
  37. ],
  38. ],
  39. [
  40. "name" => "formguide.field",
  41. "title" => "字段管理",
  42. "ismenu" => 0,
  43. "sublist" => [
  44. ["name" => "formguide.field/index", "title" => "查看"],
  45. ["name" => "formguide.field/add", "title" => "新增"],
  46. ["name" => "formguide.field/edit", "title" => "编辑"],
  47. ["name" => "formguide.field/del", "title" => "删除"],
  48. ["name" => "formguide.info/index", "title" => "信息列表"],
  49. ["name" => "formguide.info/public_view", "title" => "信息查看"],
  50. ["name" => "formguide.info/del", "title" => "信息删除"],
  51. ],
  52. ],
  53. ],
  54. ],
  55. ];
  56. //安装
  57. public function install()
  58. {
  59. $info = get_addon_info('cms');
  60. if (!$info || $info['status'] != 1) {
  61. throw new \think\Exception("请在后台插件管理中安装《内容管理系统》并启用后再尝试");
  62. }
  63. Menu::create($this->menu);
  64. return true;
  65. }
  66. /**
  67. * 插件卸载方法
  68. * @return bool
  69. */
  70. public function uninstall()
  71. {
  72. $droptables = request()->param("droptables");
  73. $auth = \app\admin\service\User::instance();
  74. //只有开启调试且为超级管理员才允许删除相关数据库
  75. if ($droptables && Config::get("app_debug") && $auth->isAdministrator()) {
  76. //删除模型中建的表
  77. $table_list = Db::name('model')->where('module', 'formguide')->field('tablename,id')->select();
  78. if ($table_list) {
  79. foreach ($table_list as $val) {
  80. $tablename = Config::get('database.prefix') . $val['tablename'];
  81. Db::execute("DROP TABLE IF EXISTS `{$tablename}`;");
  82. Db::name('model_field')->where('modelid', $val['id'])->delete();
  83. }
  84. }
  85. }
  86. //删除模型中的表
  87. Db::name('model')->where('module', 'formguide')->delete();
  88. Menu::delete("formguide");
  89. return true;
  90. }
  91. /**
  92. * 插件启用方法
  93. * @return bool
  94. */
  95. public function enable()
  96. {
  97. Menu::enable("formguide");
  98. return true;
  99. }
  100. /**
  101. * 插件禁用方法
  102. * @return bool
  103. */
  104. public function disable()
  105. {
  106. Menu::disable("formguide");
  107. return true;
  108. }
  109. }