StorageController.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
class StorageController extends AdminBaseController
{
/**
* 文件存储
* @adminMenu(
* 'name' => '文件存储',
* 'parent' => 'admin/Setting/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '文件存储',
* 'param' => ''
* )
*/
public function index()
{
$storage = cmf_get_option('storage');
if (empty($storage)) {
$storage['type'] = 'Local';
$storage['storages'] = ['Local' => ['name' => '本地']];
} else {
if (empty($storage['type'])) {
$storage['type'] = 'Local';
}
if (empty($storage['storages']['Local'])) {
$storage['storages']['Local'] = ['name' => '本地'];
}
}
$this->assign($storage);
return $this->fetch();
}
/**
* 文件存储
* @adminMenu(
* 'name' => '文件存储设置提交',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '文件存储设置提交',
* 'param' => ''
* )
*/
public function settingPost()
{
$post = $this->request->post();
$storage = cmf_get_option('storage');
$storage['type'] = $post['type'];
cmf_set_option('storage', $storage);
$this->success("设置成功!", '');
}
}