diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index 8df72f5f..9fa3529e 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -80,6 +80,7 @@ CREATE TABLE `fa_area` ( DROP TABLE IF EXISTS `fa_attachment`; CREATE TABLE `fa_attachment` ( `id` int(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `category` varchar(50) DEFAULT '' COMMENT '类别', `admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID', `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', `url` varchar(255) DEFAULT '' COMMENT '物理路径', @@ -103,7 +104,7 @@ CREATE TABLE `fa_attachment` ( -- Records of fa_attachment -- ---------------------------- BEGIN; -INSERT INTO `fa_attachment` VALUES (1, 1, 0, '/assets/img/qrcode.png', '150', '150', 'png', 0, 'qrcode.png', 21859, 'image/png', '', 1491635035, 1491635035, 1491635035, 'local', '17163603d0263e4838b9387ff2cd4877e8b018f6'); +INSERT INTO `fa_attachment` VALUES (1, '', 1, 0, '/assets/img/qrcode.png', '150', '150', 'png', 0, 'qrcode.png', 21859, 'image/png', '', 1491635035, 1491635035, 1491635035, 'local', '17163603d0263e4838b9387ff2cd4877e8b018f6'); COMMIT; -- ---------------------------- @@ -350,6 +351,7 @@ INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码或授权码)', 'string', 'password', '', '', '', ''); INSERT INTO `fa_config` VALUES (16, 'mail_verify_type', 'email', 'Mail vertify type', '(SMTP验证方式[推荐SSL])', 'select', '2', '[\"无\",\"TLS\",\"SSL\"]', '', '', ''); INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '10000@qq.com', '', '', '', ''); +INSERT INTO `fa_config` VALUES (18, 'attachmentcategory', 'dictionary', 'Attachment category', '', 'array', '{\"category1\":\"Category1\",\"category2\":\"Category2\",\"custom\":\"Custom\"}', '', '', '', ''); COMMIT; -- ---------------------------- diff --git a/application/admin/controller/general/Attachment.php b/application/admin/controller/general/Attachment.php index d73c25ce..57296f2f 100644 --- a/application/admin/controller/general/Attachment.php +++ b/application/admin/controller/general/Attachment.php @@ -8,7 +8,7 @@ use app\common\controller\Backend; * 附件管理 * * @icon fa fa-circle-o - * @remark 主要用于管理上传到又拍云的数据或上传至本服务的上传数据 + * @remark 主要用于管理上传到服务器或第三方存储的数据 */ class Attachment extends Backend { @@ -18,11 +18,15 @@ class Attachment extends Backend */ protected $model = null; + protected $searchFields = 'id,filename,url'; + public function _initialize() { parent::_initialize(); $this->model = model('Attachment'); $this->view->assign("mimetypeList", \app\common\model\Attachment::getMimetypeList()); + $this->view->assign("categoryList", \app\common\model\Attachment::getCategoryList()); + $this->assignconfig("categoryList", \app\common\model\Attachment::getCategoryList()); } /** @@ -36,10 +40,15 @@ class Attachment extends Backend $mimetypeQuery = []; $filter = $this->request->request('filter'); $filterArr = (array)json_decode($filter, true); + if (isset($filterArr['category']) && $filterArr['category'] == 'unclassed') { + $filterArr['category'] = ''; + $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['category' => '']))]); + } if (isset($filterArr['mimetype']) && preg_match("/[]\,|\*]/", $filterArr['mimetype'])) { - $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]); - $mimetypeQuery = function ($query) use ($filterArr) { - $mimetypeArr = explode(',', $filterArr['mimetype']); + $mimetype = $filterArr['mimetype']; + $filterArr = array_diff_key($filterArr, ['mimetype' => '']); + $mimetypeQuery = function ($query) use ($mimetype) { + $mimetypeArr = explode(',', $mimetype); foreach ($mimetypeArr as $index => $item) { if (stripos($item, "/*") !== false) { $query->whereOr('mimetype', 'like', str_replace("/*", "/", $item) . '%'); @@ -49,6 +58,7 @@ class Attachment extends Backend } }; } + $this->request->get(['filter' => json_encode($filterArr)]); list($where, $sort, $order, $offset, $limit) = $this->buildparams(); @@ -121,4 +131,25 @@ class Attachment extends Backend $this->error(__('Parameter %s can not be empty', 'ids')); } + /** + * 移动 + */ + public function move($ids = "") + { + if (!$this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + $category = $this->request->post('category', ''); + $ids = $this->request->post('ids'); + if (!$ids) { + $this->error(__('Parameter %s can not be empty', 'ids')); + } + $categoryList = \app\common\model\Attachment::getCategoryList(); + if ($category && !isset($categoryList[$category])) { + $this->error(__('Category not found')); + } + \app\common\model\Attachment::where('id', 'in', $ids)->update(['category' => $category]); + $this->success(); + } + } diff --git a/application/admin/controller/general/Config.php b/application/admin/controller/general/Config.php index f4b93e2a..bab69e84 100644 --- a/application/admin/controller/general/Config.php +++ b/application/admin/controller/general/Config.php @@ -60,6 +60,14 @@ class Config extends Backend $value['value'] = explode(',', $value['value']); } $value['content'] = json_decode($value['content'], true); + if (in_array($value['name'], ['categorytype', 'configgroup', 'attachmentcategory'])) { + $dictValue = (array)json_decode($value['value'], true); + foreach ($dictValue as $index => &$item) { + $item = __($item); + } + unset($item); + $value['value'] = json_encode($dictValue, JSON_UNESCAPED_UNICODE); + } $value['tip'] = htmlspecialchars($value['tip']); $siteList[$v['group']]['list'][] = $value; } diff --git a/application/admin/lang/zh-cn/general/attachment.php b/application/admin/lang/zh-cn/general/attachment.php index 90fe66d7..86690e2a 100644 --- a/application/admin/lang/zh-cn/general/attachment.php +++ b/application/admin/lang/zh-cn/general/attachment.php @@ -23,9 +23,17 @@ return [ 'Createtime' => '创建日期', 'Uploadtime' => '上传时间', 'Storage' => '存储引擎', + 'Category1' => '分类一', + 'Category2' => '分类二', + 'Custom' => '自定义', + 'Unclassed' => '未归类', + 'Category' => '类别', 'Upload to third' => '上传到第三方', 'Upload to local' => '上传到本地', 'Upload to third by chunk' => '上传到第三方(分片模式)', 'Upload to local by chunk' => '上传到本地(分片模式)', + 'Please enter a new name' => '请输入新的类别名称', + 'Please select category' => '请选择一个类别', + 'Category not found' => '指定的类别未找到', 'Upload from editor' => '从编辑器上传' ]; diff --git a/application/admin/lang/zh-cn/general/config.php b/application/admin/lang/zh-cn/general/config.php index 021384f3..6a2b95d6 100644 --- a/application/admin/lang/zh-cn/general/config.php +++ b/application/admin/lang/zh-cn/general/config.php @@ -57,6 +57,9 @@ return [ 'Fixed page' => '后台固定页', 'Category type' => '分类类型', 'Config group' => '配置分组', + 'Attachment category' => '附件类别', + 'Category1' => '分类一', + 'Category2' => '分类二', 'Rule tips' => '校验规则使用请参考Nice-validator文档', 'Extend tips' => '扩展属性支持{id}、{name}、{group}、{title}、{value}、{content}、{rule}替换', 'Mail type' => '邮件发送方式', diff --git a/application/admin/view/general/attachment/edit.html b/application/admin/view/general/attachment/edit.html index 8caa393e..85898b57 100644 --- a/application/admin/view/general/attachment/edit.html +++ b/application/admin/view/general/attachment/edit.html @@ -1,5 +1,18 @@ + +