123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php namespace Upload\Api;
- use Dever;
- use Manage\Lib\Auth;
- class Manage extends Auth
- {
- # 获取图片组件信息
- public function getImage($value = false)
- {
- Dever::project('image');
- $result = array();
- $option = array();
- if ($value == 1) {
- $option = Dever::db('thumb', 'image')->select([]);
- } elseif ($value == 2) {
- $option = Dever::db('crop', 'image')->select([]);
- } elseif ($value == 3) {
- $option = Dever::db('water_pic', 'image')->select([]);
- } elseif ($value == 4) {
- $option = Dever::db('water_txt', 'image')->select([]);
- }
- $result['type_id']['type'] = 'select';
- $result['type_id']['option'] = $option;
- $result['type_id']['value'] = $option[0]['id'] ?? '';
- return $result;
- }
- # 删除文件
- public function upFileStatus()
- {
- $rule_id = Dever::input('id');
- $id = Dever::input('file_id');
- $status = Dever::input('status', 'is_numeric', '状态', 2);
- $user_id = Dever::load('util', 'upload')->getUser();
- return Dever::db('file', 'upload')->update(array('id' => $id, 'user_id' => $user_id), array('status' => $status));
- }
- # 彻底删除文件
- public function delFile()
- {
- $rule_id = Dever::input('id');
- $id = Dever::input('file_id');
- $user_id = Dever::load('util', 'upload')->getUser();
- $state = Dever::db('file', 'upload')->delete(array('id' => $id, 'status' => 2, 'user_id' => $user_id));
- if ($state) {
- # 同时删除文件
- }
- return 'ok';
- }
- # 添加文件
- public function addFile($id, $url, $file, $source, $name, $size)
- {
- $data = Dever::load('save', 'upload')->init($id)->addFile($url, $source, $name, $file, $size);
- return $data;
- }
- # 获取文件库文件列表
- public function getFileList()
- {
- $type = Dever::input('type', 'is_numeric', '类型', 0);
- $id = Dever::input('id', 'is_numeric', '上传规则错误', 1);
- $cate_id = Dever::input('cate_id', 'is_numeric', '上传分类', 1);
- $group_id = Dever::load('util', 'upload')->getGroup();
- $user_id = Dever::load('util', 'upload')->getUser();
- $file = Dever::input('file');
- $data = Dever::input();
- $set = array();
- $set['num'] = 10;
- $where['rule_id'] = $id;
- $where['status'] = 1;
- #$where['cate_id'] = $cate_id;
- if ($type == 1) {
- $where['group_id'] = $group_id;
- } elseif ($type == 2) {
- $where['user_id'] = $user_id;
- } elseif ($type == 4) {
- $where['status'] = 2;
- }
-
- $result['file'] = Dever::db('file', 'upload')->select($where, $set);
- if ($result['file']) {
- foreach ($result['file'] as &$v) {
- if ($v['source_name']) {
- $v['name'] = $v['source_name'];
- }
- $v['url'] = Dever::load('view', 'upload')->getUrl($v);
- $v['class'] = '';
- $v['del'] = 2;
- if ($user_id == $v['user_id']) {
- $v['del'] = 1;
- }
- if ($file) {
- foreach ($file as $v1) {
- if ($v1 && $v1['url'] == $v['url']) {
- $v['class'] = 'show-image-active';
- }
- }
- }
- }
- }
- $result['total'] = Dever::page('total');
- return $result;
- }
- }
|