diff --git a/application/admin/view/config.index.html b/application/admin/view/config.index.html index 42bfe07b0..0141514b0 100644 --- a/application/admin/view/config.index.html +++ b/application/admin/view/config.index.html @@ -44,14 +44,6 @@ -
- -
- -

友盟统计应用ID,可以在友盟网站统计申请并获取

-
-
-
diff --git a/extend/controller/BasicAdmin.php b/extend/controller/BasicAdmin.php index 83606a9b8..d2d1395b5 100644 --- a/extend/controller/BasicAdmin.php +++ b/extend/controller/BasicAdmin.php @@ -56,34 +56,30 @@ class BasicAdmin extends Controller { * @param string $tplFile 显示模板名字 * @param string $pkField 更新主键规则 * @param array $where 查询规则 - * @param array $data 扩展数据 + * @param array $extendData 扩展数据 * @return array|string */ - protected function _form($dbQuery = null, $tplFile = '', $pkField = '', $where = [], $data = []) { + protected function _form($dbQuery = null, $tplFile = '', $pkField = '', $where = [], $extendData = []) { $db = is_null($dbQuery) ? Db::name($this->table) : (is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery); $pk = empty($pkField) ? ($db->getPk() ? $db->getPk() : 'id') : $pkField; - $pkValue = $this->request->request($pk, isset($where[$pk]) ? $where[$pk] : (isset($data[$pk]) ? $data[$pk] : null)); - // POST请求, 数据自动存库 - if ($this->request->isPost()) { - $data = array_merge($this->request->post(), $data); - if (false !== $this->_callback('_form_filter', $data)) { - $result = DataService::save($db, $data, $pk, $where); - if (false === $this->_callback('_form_result', $result)) { - return $result; - } - if ($result !== false) { - $this->success('恭喜, 数据保存成功!', ''); - } - $this->error('数据保存失败, 请稍候再试!'); + $pkValue = $this->request->request($pk, isset($where[$pk]) ? $where[$pk] : (isset($extendData[$pk]) ? $extendData[$pk] : null)); + // 非POST请求, 获取数据并显示表单页面 + if (!$this->request->isPost()) { + $vo = ($pkValue !== null) ? array_merge((array) $db->where($pk, $pkValue)->where($where)->find(), $extendData) : $extendData; + if (false !== $this->_callback('_form_filter', $vo)) { + empty($this->title) || $this->assign('title', $this->title); + return $this->fetch($tplFile, ['vo' => $vo]); } - } - // GET请求, 获取并显示表单页面 - $vo = ($pkValue !== null) ? array_merge((array) $db->where($pk, $pkValue)->where($where)->find(), $data) : $data; - if (false === $this->_callback('_form_filter', $vo)) { return $vo; } - empty($this->title) or $this->assign('title', $this->title); - return $this->fetch($tplFile, ['vo' => $vo]); + // POST请求, 数据自动存库 + $data = array_merge($this->request->post(), $extendData); + if (false !== $this->_callback('_form_filter', $data)) { + $result = DataService::save($db, $data, $pk, $where); + if (false !== $this->_callback('_form_result', $result)) { + $result !== false ? $this->success('恭喜, 数据保存成功!', '') : $this->error('数据保存失败, 请稍候再试!'); + } + } } /** @@ -108,15 +104,15 @@ class BasicAdmin extends Controller { $this->success('列表排序成功, 正在刷新列表', ''); } // 列表数据查询与显示 - $result = array(); if (null === $db->getOptions('order')) { $fields = $db->getTableFields(['table' => $db->getTable()]); in_array('sort', $fields) && $db->order('sort asc'); } + $result = array(); if ($isPage) { - $row_page = $this->request->get('rows', cookie('rows'), 'intval'); - cookie('rows', $row_page >= 10 ? $row_page : 20); - $page = $db->paginate($row_page, $total, ['query' => $this->request->get()]); + $rowPage = intval($this->request->get('rows', cookie('rows'))); + cookie('rows', $rowPage >= 10 ? $rowPage : 20); + $page = $db->paginate($rowPage, $total, ['query' => $this->request->get()]); $result['list'] = $page->all(); $result['page'] = preg_replace(['|href="(.*?)"|', '|pagination|'], ['data-open="$1" href="javascript:void(0);"', 'pagination pull-right'], $page->render()); } else { diff --git a/extend/hook/FilterView.php b/extend/hook/FilterView.php index a24ad3ba9..6134732d3 100644 --- a/extend/hook/FilterView.php +++ b/extend/hook/FilterView.php @@ -37,17 +37,14 @@ class FilterView { */ public function run(&$params) { $this->request = Request::instance(); - $app = $this->request->root(true); + $appRoot = $this->request->root(true); $replace = [ - '__APP__' => $app, + '__APP__' => $appRoot, '__SELF__' => $this->request->url(true), - '__PUBLIC__' => strpos($app, EXT) ? ltrim(dirname($app), DS) : $app, + '__PUBLIC__' => strpos($appRoot, EXT) ? ltrim(dirname($appRoot), DS) : $appRoot, ]; $params = str_replace(array_keys($replace), array_values($replace), $params); - if (!IS_CLI) { - $this->baidu($params); - $this->cnzz($params); - } + !IS_CLI && $this->baidu($params); } /** @@ -71,16 +68,4 @@ SCRIPT; } } - /** - * CNZZ统计实现代码 - * @param $params - */ - public function cnzz(&$params) { - if (($key = sysconf('tongji_cnzz_key'))) { - $query = ['siteid' => $key, 'r' => $this->request->server('HTTP_REFERER'), 'rnd' => mt_rand(100000, 999999)]; - $imgSrc = 'https://c.cnzz.com/wapstat.php?' . http_build_query($query); - $params = preg_replace('||i', "\n ", $params); - } - } - }