StorageController.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-present http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 老猫 <zxxjjforever@163.com>
  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. if ($this->request->isPost()) {
  61. $post = $this->request->post();
  62. $storage = cmf_get_option('storage');
  63. $storage['type'] = $post['type'];
  64. cmf_set_option('storage', $storage);
  65. $this->success("设置成功!", '');
  66. }
  67. }
  68. }