更新
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
// | 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;
|
||||
|
||||
/**
|
||||
* @title 内容管理
|
||||
@@ -20,7 +19,7 @@ class Content extends Admin {
|
||||
parent::_initialize();
|
||||
$this->getContentMenu();
|
||||
$this->model_id = $model_id = $this->request->param('model_id');
|
||||
$list = db('Model')->column('*', 'id');
|
||||
$list = db('Model')->column('*', 'id');
|
||||
|
||||
if (empty($list[$model_id])) {
|
||||
return $this->error("无此模型!");
|
||||
@@ -43,14 +42,13 @@ class Content extends Admin {
|
||||
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||||
}
|
||||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
||||
$order = "id desc";
|
||||
$map = $this->buildMap();
|
||||
$field = array_filter($grid_list['fields']);
|
||||
|
||||
$order = "id desc";
|
||||
$map = $this->buildMap();
|
||||
$field = array_filter($grid_list['fields']);
|
||||
|
||||
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'grid' => $grid_list,
|
||||
@@ -86,7 +84,7 @@ class Content extends Admin {
|
||||
'model_id' => $this->modelInfo['id'],
|
||||
);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'fieldGroup' => $this->getField($this->modelInfo),
|
||||
);
|
||||
if ($this->modelInfo['template_add']) {
|
||||
@@ -106,7 +104,7 @@ class Content extends Admin {
|
||||
*/
|
||||
public function edit($id) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->save($this->request->param(), array('id'=> $id));
|
||||
$result = $this->model->save($this->request->param(), array('id' => $id));
|
||||
if ($result !== false) {
|
||||
//记录行为
|
||||
action_log('update_content', 'content', $result, session('auth_user.uid'));
|
||||
@@ -123,8 +121,8 @@ class Content extends Admin {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
$info['model_id'] = $this->modelInfo['id'];
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'fieldGroup' => $this->getField($this->modelInfo),
|
||||
);
|
||||
if ($this->modelInfo['template_edit']) {
|
||||
@@ -150,7 +148,7 @@ class Content extends Admin {
|
||||
}
|
||||
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = $this->model->where($map)->delete();
|
||||
$result = $this->model->where($map)->delete();
|
||||
|
||||
if (false !== $result) {
|
||||
//记录行为
|
||||
@@ -167,7 +165,7 @@ class Content extends Admin {
|
||||
*/
|
||||
public function status($id, $status) {
|
||||
$map['id'] = $id;
|
||||
$result = $this->model->where($map)->setField('status', $status);
|
||||
$result = $this->model->where($map)->setField('status', $status);
|
||||
if (false !== $result) {
|
||||
return $this->success("操作成功!");
|
||||
} else {
|
||||
@@ -181,7 +179,7 @@ class Content extends Admin {
|
||||
*/
|
||||
public function settop($id, $is_top) {
|
||||
$map['id'] = $id;
|
||||
$result = $this->model->where($map)->setField('is_top', $is_top);
|
||||
$result = $this->model->where($map)->setField('is_top', $is_top);
|
||||
if (false !== $result) {
|
||||
return $this->success("操作成功!");
|
||||
} else {
|
||||
@@ -205,7 +203,7 @@ class Content extends Admin {
|
||||
}
|
||||
|
||||
//获得数组的第一条数组
|
||||
$rows = model('Attribute')->getFieldlist($map, 'id');
|
||||
$rows = model('Attribute')->getFieldlist($map, 'id');
|
||||
if (!empty($rows)) {
|
||||
foreach ($rows as $key => $value) {
|
||||
$list[$value['group_id']][] = $value;
|
||||
@@ -213,7 +211,7 @@ class Content extends Admin {
|
||||
foreach ($field_group as $key => $value) {
|
||||
$fields[$value] = isset($list[$key]) ? $list[$key] : array();
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$fields = array();
|
||||
}
|
||||
return $fields;
|
||||
@@ -224,7 +222,7 @@ class Content extends Admin {
|
||||
* @return [array] [查询条件]
|
||||
*/
|
||||
protected function buildMap() {
|
||||
$map = array();
|
||||
$map = array();
|
||||
$data = $this->request->param();
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value) {
|
||||
|
||||
Reference in New Issue
Block a user