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 () {
?>
配置列表 |
' . $render;
}
function edit()
{
$id = SafeRequest("id", "get");
$arrname = $id ? '编辑' : '新增';
$data = db('config')->where('id', $id)->find();
echo '
';
}
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);
}
}