Administrator(6); $ca = db('action')->where('c', 'config_setting')->where('a', '<>', 'index')->select(); $this->category_text = ['system' => '全局配置']; foreach ($ca as $v) { $this->category_text[$v['a']] = $v['name']; } $this->type_text = json_decode(IN_CONFIG_TYPE, true); $this->header(); } public function __destruct() { // TODO: Implement __destruct() method. ?> footer(); } function index($map = []) { $page = SafeRequest('page', 'get'); $this->search = SafeRequest('search', 'get'); $this->search && $map[] = ['title|name|group|note', 'like', "%$this->search%"]; $this->category = SafeRequest('category', 'get'); $this->category && $map[] = ['category', '=', $this->category]; $this->type = SafeRequest('type', 'get'); $this->type && $map[] = ['type', '=', $this->type]; $list = db('config')->where($map)->order('category,group,status,sort,name')->paginate([ 'page' => $page ]); $result = $list->items(); $render = getRender($list, $page); $count = $list->total(); echo '
'; $this->searchForm('可以输入名称等关键词进行搜索', '', function () { ?> 配置列表 '; if ($count == 0) { echo ' '; } if ($result) { foreach ($result as $item) { echo ''; } } echo '
ID 名称 变量名称 分组 类别 类型 排序 状态
没有配置管理
' . $item['id'] . ' ' . lightnum($item['title'], $this->search) . ' ' . lightnum($item['name'], $this->search) . ' ' . $this->category_text[$item['category']] . ' ' . lightnum($item['group'], $this->search) . ' ' . $this->type_text[$item['type']] . ' '; echo '
' . $render; } function edit() { $id = SafeRequest("id", "get"); $arrname = $id ? '编辑' : '新增'; $data = db('config')->where('id', $id)->find(); echo '
'; $this->nav3(); echo ''; echo ''; echo '
' . $arrname . '配置
配置名称:
变量名称:' . ($id ? '(禁止修改,如要变更,请修改数据库)' : '') . '
分类:
分组:
类型:
描述:
内容:(此处为JSON格式,不懂勿动,默认:[0,100])
'; } function save() { if (!submitcheck('hash', 1)) { $this->ShowMessage("表单来路不明,无法提交!", '?c=config', "infotitle3", 3000, 1); } $id = intval(SafeRequest("id", "post")); $title = SafeRequest("title", "post"); if (!$title) { $this->ShowMessage("配置名称不能为空", '?c=config', "infotitle3", 3000, 1); } $name = SafeRequest("name", "post"); if (!$name) { $this->ShowMessage("变量名称不能为空", '?c=config', "infotitle3", 3000, 1); } $note = SafeRequest("note", "post"); $type = SafeRequest("type", "post"); $category = SafeRequest("category", "post"); $group = SafeRequest("group", "post"); $content = SafeRequest("content", "post",1); !$content && $content = '[0, 100]'; if (isJson($content) == false) { $this->ShowMessage("内容不是合法的JSON格式", '?c=config', "infotitle3", 3000, 1); } $data = [ 'name' => $name, 'title' => $title, 'type' => $type, 'note' => $note, 'category' => $category, 'group' => $group, 'content' => $content, ]; if ($id) { $res = db('config')->where('id', $id)->update($data); } else { $config = db('config')->where('name', $name)->find(); if ($config) { $this->ShowMessage("已存在相同的配置", '?c=config', "infotitle3", 3000, 1); } $data['value']=''; $res = db('config')->insert($data); } $res && $this->ShowMessage("恭喜您,配置保存成功!", '?c=config', "infotitle2", 1000, 1); $this->ShowMessage("配置保存失败!请稍后重试!", '?c=config', "infotitle3", 3000, 1); } function change_status() { if (!submitcheck('hash', -1)) { $this->ShowMessage("链接来路不明,无法提交!", $_SERVER['HTTP_REFERER'], "infotitle3", 3000, 1); } $id = intval(SafeRequest("id", "get")); $status = intval(SafeRequest("status", "get")); $res = db('config')->where('id', $id)->update(['status' => $status]); $this->ShowMessage("恭喜您,状态切换成功!", "?c=config", "infotitle2", 1000, 1); } }