更新
This commit is contained in:
@@ -7,8 +7,9 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
use app\model\Config as ConfigM;
|
||||
|
||||
/**
|
||||
* @title 配置管理
|
||||
@@ -17,7 +18,7 @@ class Config extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->model = model('Config');
|
||||
$this->model = new ConfigM();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,9 +27,9 @@ class Config extends Admin {
|
||||
*/
|
||||
public function index() {
|
||||
$group = input('group', 0, 'trim');
|
||||
$name = input('name', '', 'trim');
|
||||
$name = input('name', '', 'trim');
|
||||
/* 查询条件初始化 */
|
||||
$map = array('status' => 1);
|
||||
$map = array('status' => 1);
|
||||
if ($group) {
|
||||
$map['group'] = $group;
|
||||
}
|
||||
@@ -38,17 +39,17 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
$list = $this->model->where($map)->order('id desc')->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$data = array(
|
||||
'group' => config('config_group_list'),
|
||||
'group' => config('config_group_list'),
|
||||
'config_type' => config('config_config_list'),
|
||||
'page' => $list->render(),
|
||||
'group_id' => $group,
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
'group_id' => $group,
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
$this->assign($data);
|
||||
@@ -62,7 +63,7 @@ class Config extends Admin {
|
||||
public function group($id = 1) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = $this->request->post('config/a');
|
||||
$model = model('Config');
|
||||
$model = model('Config');
|
||||
foreach ($config as $key => $value) {
|
||||
$model->where(array('name' => $key))->setField('value', $value);
|
||||
}
|
||||
@@ -71,12 +72,12 @@ class Config extends Admin {
|
||||
return $this->success("更新成功!");
|
||||
} else {
|
||||
$type = config('config_group_list');
|
||||
$list = db("Config")->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
$list = (new ConfigM())->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
if ($list) {
|
||||
$this->assign('list', $list);
|
||||
$this->data['list'] = $list;
|
||||
}
|
||||
$this->assign('id', $id);
|
||||
$this->setMeta($type[$id] . '设置');
|
||||
// $this->assign('id', $id);
|
||||
// $this->setMeta($type[$id] . '设置');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -88,7 +89,7 @@ class Config extends Admin {
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$id = $config->validate(true)->save($data);
|
||||
if ($id) {
|
||||
@@ -116,7 +117,7 @@ class Config extends Admin {
|
||||
public function edit($id = 0) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = $config->validate('Config.edit')->save($data, array('id' => $data['id']));
|
||||
if (false !== $result) {
|
||||
@@ -224,9 +225,9 @@ class Config extends Admin {
|
||||
$pc = config('pc_themes');
|
||||
$mobile = config('mobile_themes');
|
||||
$data = array(
|
||||
'pc' => $pc,
|
||||
'pc' => $pc,
|
||||
'mobile' => $mobile,
|
||||
'list' => $list,
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
$this->assign($data);
|
||||
@@ -238,12 +239,12 @@ class Config extends Admin {
|
||||
* @title 设置主题
|
||||
* @return json
|
||||
*/
|
||||
public function setthemes($name, $id){
|
||||
public function setthemes($name, $id) {
|
||||
$result = db('Config')->where('name', $name . '_themes')->setField('value', $id);
|
||||
if (false !== $result) {
|
||||
\think\Cache::clear();
|
||||
return $this->success('设置成功!');
|
||||
}else{
|
||||
} else {
|
||||
return $this->error('设置失败!');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user