StorageController.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-04-30
  10. // +—————————————————————————————————————————————————————————————————————
  11. namespace app\admin\controller;
  12. use cmf\controller\AdminBaseController;
  13. class StorageController extends AdminBaseController
  14. {
  15. /**
  16. * 文件存储
  17. * @adminMenu(
  18. * 'name' => '文件存储',
  19. * 'parent' => 'admin/Setting/default',
  20. * 'display'=> true,
  21. * 'hasView'=> true,
  22. * 'order' => 10000,
  23. * 'icon' => '',
  24. * 'remark' => '文件存储',
  25. * 'param' => ''
  26. * )
  27. */
  28. public function index()
  29. {
  30. $storage = cmf_get_option('storage');
  31. if (empty($storage)) {
  32. $storage['type'] = 'Local';
  33. $storage['storages'] = ['Local' => ['name' => '本地']];
  34. } else {
  35. if (empty($storage['type'])) {
  36. $storage['type'] = 'Local';
  37. }
  38. if (empty($storage['storages']['Local'])) {
  39. $storage['storages']['Local'] = ['name' => '本地'];
  40. }
  41. }
  42. $this->assign($storage);
  43. return $this->fetch();
  44. }
  45. /**
  46. * 文件存储
  47. * @adminMenu(
  48. * 'name' => '文件存储设置提交',
  49. * 'parent' => 'index',
  50. * 'display'=> false,
  51. * 'hasView'=> false,
  52. * 'order' => 10000,
  53. * 'icon' => '',
  54. * 'remark' => '文件存储设置提交',
  55. * 'param' => ''
  56. * )
  57. */
  58. public function settingPost()
  59. {
  60. $post = $this->request->post();
  61. $storage = cmf_get_option('storage');
  62. $storage['type'] = $post['type'];
  63. cmf_set_option('storage', $storage);
  64. $this->success("设置成功!", '');
  65. }
  66. }