From 241c6fc370190d0d698ada0df0a52ed2bcf7925a Mon Sep 17 00:00:00 2001 From: Karson <karsonzhang@163.com> Date: Fri, 21 Jul 2017 18:22:30 +0800 Subject: [PATCH] 修复普通搜索无法执行搜索的BUG --- application/admin/library/traits/Backend.php | 50 +++++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/application/admin/library/traits/Backend.php b/application/admin/library/traits/Backend.php index b3db442..67bd793 100644 --- a/application/admin/library/traits/Backend.php +++ b/application/admin/library/traits/Backend.php @@ -11,7 +11,7 @@ trait Backend public function index() { //设置过滤方法 - $this->request->filter(['strip_tags', 'htmlspecialchars']); + $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage @@ -45,7 +45,6 @@ trait Backend { if ($this->request->isPost()) { - $this->code = -1; $params = $this->request->post("row/a"); if ($params) { @@ -65,24 +64,19 @@ trait Backend $result = $this->model->save($params); if ($result !== false) { - $this->code = 1; + $this->success(); } else { - $this->msg = $this->model->getError(); + $this->error($this->model->getError()); } } catch (\think\exception\PDOException $e) { - $this->msg = $e->getMessage(); + $this->error($e->getMessage()); } } - else - { - $this->msg = __('Parameter %s can not be empty', ''); - } - - return; + $this->error(__('Parameter %s can not be empty', '')); } return $this->view->fetch(); } @@ -97,7 +91,6 @@ trait Backend $this->error(__('No Results were found')); if ($this->request->isPost()) { - $this->code = -1; $params = $this->request->post("row/a"); if ($params) { @@ -111,30 +104,25 @@ trait Backend if ($this->modelValidate) { $name = basename(str_replace('\\', '/', get_class($this->model))); - $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; $row->validate($validate); } $result = $row->save($params); if ($result !== false) { - $this->code = 1; + $this->success(); } else { - $this->msg = $row->getError(); + $this->error($row->getError()); } } catch (think\exception\PDOException $e) { - $this->msg = $e->getMessage(); + $this->error($e->getMessage()); } } - else - { - $this->msg = __('Parameter %s can not be empty', ''); - } - - return; + $this->error(__('Parameter %s can not be empty', '')); } $this->view->assign("row", $row); return $this->view->fetch(); @@ -145,17 +133,15 @@ trait Backend */ public function del($ids = "") { - $this->code = -1; if ($ids) { $count = $this->model->destroy($ids); if ($count) { - $this->code = 1; + $this->success(); } } - - return; + $this->error(__('Parameter %s can not be empty', 'ids')); } /** @@ -163,7 +149,6 @@ trait Backend */ public function multi($ids = "") { - $this->code = -1; $ids = $ids ? $ids : $this->request->param("ids"); if ($ids) { @@ -176,21 +161,16 @@ trait Backend $count = $this->model->where($this->model->getPk(), 'in', $ids)->update($values); if ($count) { - $this->code = 1; + $this->success(); } } else { - $this->msg = __('You have no permission'); + $this->error(__('You have no permission')); } } - else - { - $this->msg = __('Parameter %s can not be empty', ''); - } } - - return; + $this->error(__('Parameter %s can not be empty', 'ids')); } } -- libgit2 0.24.0