1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace app\admin\controller\general;
- use app\common\controller\Backend;
- /**
- * 附件管理
- *
- * @icon fa fa-circle-o
- * @remark 主要用于管理上传到又拍云的数据或上传至本服务的上传数据
- */
- class Attachment extends Backend
- {
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = model('Attachment');
- }
- /**
- * 查看
- */
- public function index()
- {
- if ($this->request->isAjax())
- {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model
- ->where($where)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->where($where)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
- foreach ($list as $k => &$v)
- {
- $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
- }
- unset($v);
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 选择附件
- */
- public function select()
- {
- if ($this->request->isAjax())
- {
- return $this->index();
- }
- return $this->view->fetch();
- }
- /**
- * 添加
- */
- public function add()
- {
- if ($this->request->isAjax())
- {
- $this->code = -1;
- }
- return $this->view->fetch();
- }
- }
|