Cwmap.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace addons\cwmap;
  3. use app\common\library\Menu;
  4. use think\Addons;
  5. /**
  6. * lksms
  7. */
  8. class Cwmap extends Addons {
  9. /**
  10. * 插件安装方法
  11. * @return bool
  12. */
  13. public function install() {
  14. $menu = [
  15. [
  16. 'name' => 'cwmap',
  17. 'title' => '地图',
  18. 'icon' => 'fa fa-location-arrow',
  19. 'remark' => '地图管理',
  20. 'sublist' => [
  21. [
  22. 'name' => 'cwmap/maplocation',
  23. 'title' => '位置信息',
  24. 'icon' => 'fa fa-map-o',
  25. 'remark' => '位置信息管理',
  26. 'ismenu' => 1,
  27. 'sublist' => [
  28. ['name' => 'cwmap/maplocation/index', 'title' => '查看'],
  29. ['name' => 'cwmap/maplocation/add', 'title' => '添加'],
  30. ['name' => 'cwmap/maplocation/edit', 'title' => '修改'],
  31. ['name' => 'cwmap/maplocation/del', 'title' => '删除'],
  32. ]
  33. ]
  34. ]
  35. ]
  36. ];
  37. Menu::create($menu, 'cwmap');
  38. return true;
  39. }
  40. /**
  41. * 插件卸载方法
  42. * @return bool
  43. */
  44. public function uninstall() {
  45. Menu::delete('cwmap');
  46. return true;
  47. }
  48. /**
  49. * 插件启用方法
  50. * @return bool
  51. */
  52. public function enable() {
  53. Menu::enable('cwmap');
  54. return true;
  55. }
  56. /**
  57. * 插件禁用方法
  58. * @return bool
  59. */
  60. public function disable() {
  61. Menu::disable('cwmap');
  62. return true;
  63. }
  64. protected function writeToFile($pathname, $data) {
  65. $search = $replace = [];
  66. foreach ($data as $k => $v) {
  67. $search[] = $k;
  68. $replace[] = $v;
  69. }
  70. $stub = file_get_contents($pathname);
  71. $content = str_replace($search, $replace, $stub);
  72. return file_put_contents($pathname, $content);
  73. }
  74. }