12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace app\admin\controller\cms;
- use app\common\controller\Backend;
- /**
- * 自定义表单表
- *
- * @icon fa fa-list
- */
- class Diyform extends Backend
- {
- /**
- * Model模型对象
- */
- protected $model = null;
- protected $searchFields = 'id,name,title,table';
- protected $noNeedRight = ['check_element_available'];
- public function _initialize()
- {
- parent::_initialize();
- $config = get_addon_config('cms');
- if ($config['diyformdatalimit'] != 'all') {
- $this->dataLimit = $config['diyformdatalimit'];
- }
- $this->assignconfig('spiderRecord', intval($config['spiderrecord']?? 0));
- $this->model = new \app\admin\model\cms\Diyform;
- $this->view->assign("statusList", $this->model->getStatusList());
- }
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- \app\admin\model\cms\SpiderLog::render($list, 'diyform');
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 检测元素是否可用
- * @internal
- */
- public function check_element_available()
- {
- $id = $this->request->request('id');
- $name = $this->request->request('name');
- $value = $this->request->request('value');
- $name = substr($name, 4, -1);
- if (!$name) {
- $this->error(__('Parameter %s can not be empty', 'name'));
- }
- if ($id) {
- $this->model->where('id', '<>', $id);
- }
- $exist = $this->model->where($name, $value)->find();
- if ($exist) {
- $this->error(__('The data already exist'));
- } else {
- $this->success();
- }
- }
- }
|