修复后台模块
This commit is contained in:
@@ -42,6 +42,10 @@ function parse_field_bind(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function time_format($value){
|
||||||
|
return date('Y-m-d H:i:s', $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取客户端IP地址
|
* 获取客户端IP地址
|
||||||
* @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字
|
* @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ class Config extends Base {
|
|||||||
* @return json
|
* @return json
|
||||||
*/
|
*/
|
||||||
public function setthemes($name, $id) {
|
public function setthemes($name, $id) {
|
||||||
$result = ConfigM::where('name', $name . '_themes')->setField('value', $id);
|
$result = ConfigM::update(['value' => $id], ['name' => $name."_themes"]);
|
||||||
if (false !== $result) {
|
if (false !== $result) {
|
||||||
Cache::pull('system_config_data');
|
Cache::pull('system_config_data');
|
||||||
return $this->success('设置成功!');
|
return $this->success('设置成功!');
|
||||||
|
|||||||
@@ -9,14 +9,21 @@
|
|||||||
|
|
||||||
namespace app\controller\admin;
|
namespace app\controller\admin;
|
||||||
|
|
||||||
|
use think\facade\Db;
|
||||||
|
use app\model\Model;
|
||||||
|
use app\model\Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 内容管理
|
* @title 内容管理
|
||||||
*/
|
*/
|
||||||
class Content extends Base {
|
class Content extends Base {
|
||||||
|
|
||||||
|
public $modelInfo = [];
|
||||||
|
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
$this->getContentMenu();
|
$this->getContentMenu();
|
||||||
|
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,27 +35,25 @@ class Content extends Base {
|
|||||||
if ($this->modelInfo['list_grid'] == '') {
|
if ($this->modelInfo['list_grid'] == '') {
|
||||||
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||||||
}
|
}
|
||||||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
|
||||||
$order = "id desc";
|
$order = "id desc";
|
||||||
$map = $this->buildMap();
|
$map = [];
|
||||||
$field = array_filter($grid_list['fields']);
|
|
||||||
|
|
||||||
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
$list = Db::name($this->modelInfo['name'])->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
||||||
'query' => $this->request->param(),
|
'query' => $this->request->param(),
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = array(
|
$this->data = array(
|
||||||
'grid' => $grid_list,
|
'grid' => $this->modelInfo['grid_list'],
|
||||||
'list' => $list,
|
'list' => $list,
|
||||||
'page' => $list->render(),
|
'page' => $list->render(),
|
||||||
|
'model_name' => $this->modelInfo['name'],
|
||||||
|
'model_id' => $this->modelInfo['id']
|
||||||
);
|
);
|
||||||
if ($this->modelInfo['template_list']) {
|
if ($this->modelInfo['template_list']) {
|
||||||
$template = 'content/' . $this->modelInfo['template_list'];
|
$template = 'admin/content/' . $this->modelInfo['template_list'];
|
||||||
} else {
|
} else {
|
||||||
$template = 'content/index';
|
$template = 'admin/content/index';
|
||||||
}
|
}
|
||||||
$this->assign($data);
|
|
||||||
$this->setMeta($this->modelInfo['title'] . "列表");
|
|
||||||
return $this->fetch($template);
|
return $this->fetch($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,27 +65,25 @@ class Content extends Base {
|
|||||||
if ($this->request->isPost()) {
|
if ($this->request->isPost()) {
|
||||||
$result = $this->model->save($this->request->param());
|
$result = $this->model->save($this->request->param());
|
||||||
if ($result) {
|
if ($result) {
|
||||||
//记录行为
|
|
||||||
action_log('add_content', 'content', $result, session('auth_user.uid'));
|
|
||||||
return $this->success("添加成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
|
return $this->success("添加成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
|
||||||
} else {
|
} else {
|
||||||
return $this->error($this->model->getError(), url('admin/content/add', array('model_id' => $this->modelInfo['id'])));
|
return $this->error($this->model->getError(), url('admin/content/add', array('model_id' => $this->modelInfo['id'])));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$info = array(
|
$info = [
|
||||||
|
'model_name' => $this->modelInfo['name'],
|
||||||
'model_id' => $this->modelInfo['id'],
|
'model_id' => $this->modelInfo['id'],
|
||||||
);
|
];
|
||||||
$data = array(
|
$this->data = [
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
'fieldGroup' => $this->getField($this->modelInfo),
|
'fieldGroup' => $this->getField($this->modelInfo),
|
||||||
);
|
];
|
||||||
|
|
||||||
if ($this->modelInfo['template_add']) {
|
if ($this->modelInfo['template_add']) {
|
||||||
$template = 'content/' . $this->modelInfo['template_add'];
|
$template = 'content/' . $this->modelInfo['template_add'];
|
||||||
} else {
|
} else {
|
||||||
$template = 'public/edit';
|
$template = 'public/edit';
|
||||||
}
|
}
|
||||||
$this->assign($data);
|
|
||||||
$this->setMeta("添加" . $this->modelInfo['title']);
|
|
||||||
return $this->fetch($template);
|
return $this->fetch($template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,7 +193,7 @@ class Content extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获得数组的第一条数组
|
//获得数组的第一条数组
|
||||||
$rows = model('Attribute')->getFieldlist($map, 'id');
|
$rows = Attribute::getFieldlist($map, 'id');
|
||||||
if (!empty($rows)) {
|
if (!empty($rows)) {
|
||||||
foreach ($rows as $key => $value) {
|
foreach ($rows as $key => $value) {
|
||||||
$list[$value['group_id']][] = $value;
|
$list[$value['group_id']][] = $value;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
namespace app\controller\admin;
|
namespace app\controller\admin;
|
||||||
|
|
||||||
use app\model\Model as ModelM;
|
use app\model\Model as ModelM;
|
||||||
|
use app\model\Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 模型管理
|
* @title 模型管理
|
||||||
@@ -74,11 +75,11 @@ class Model extends Base {
|
|||||||
return $this->error($this->model->getError());
|
return $this->error($this->model->getError());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$info = $this->model->where('id', $request->param('id'))->find();
|
$info = ModelM::find($request->param('id'));
|
||||||
|
|
||||||
$field_group = parse_config_attr($info['attribute_group']);
|
$field_group = parse_config_attr($info['attribute_group']);
|
||||||
//获取字段列表
|
//获取字段列表
|
||||||
$rows = db('Attribute')->where('model_id', $request->param('id'))->where('is_show', 1)->order('group_id asc, sort asc')->select();
|
$rows = Attribute::where('model_id', $request->param('id'))->where('is_show', 1)->order('group_id asc, sort asc')->select();
|
||||||
if ($rows) {
|
if ($rows) {
|
||||||
// 梳理属性的可见性
|
// 梳理属性的可见性
|
||||||
foreach ($rows as $key => $field) {
|
foreach ($rows as $key => $field) {
|
||||||
@@ -90,13 +91,11 @@ class Model extends Base {
|
|||||||
} else {
|
} else {
|
||||||
$fields = array();
|
$fields = array();
|
||||||
}
|
}
|
||||||
$data = array(
|
$this->data = array(
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
'field_group' => $field_group,
|
'field_group' => $field_group,
|
||||||
'fields' => $fields,
|
'fields' => $fields,
|
||||||
);
|
);
|
||||||
$this->assign($data);
|
|
||||||
$this->setMeta('编辑模型');
|
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Index extends Base {
|
|||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ad(){
|
public function miss(){
|
||||||
return $this->fetch('ad');
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace app\model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置模型
|
|
||||||
*/
|
|
||||||
class Content extends Model {
|
|
||||||
|
|
||||||
protected $auto = ['update_time'];
|
|
||||||
protected $insert = ['create_time', 'status' => 1];
|
|
||||||
|
|
||||||
}
|
|
||||||
+17
-4
@@ -81,11 +81,24 @@ class Model extends \think\Model{
|
|||||||
return strtolower($value);
|
return strtolower($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGridListAttr($value, $data){
|
||||||
|
$list = [];
|
||||||
|
if ($data['list_grid'] !== '') {
|
||||||
|
$row = explode(PHP_EOL, $data['list_grid']);
|
||||||
|
foreach ($row as $r) {
|
||||||
|
list($field, $title) = explode(":", $r);
|
||||||
|
$list[$field] = ['field' => $field, 'title' => $title];
|
||||||
|
if (strrpos($title, "|")) {
|
||||||
|
$title = explode("|", $title);
|
||||||
|
$list[$field] = ['field' => $field, 'title' => $title[0], 'format' => $title[1]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
public function getStatusTextAttr($value, $data) {
|
public function getStatusTextAttr($value, $data) {
|
||||||
$status = array(
|
$status = [0 => '禁用', 1 => '启用'];
|
||||||
0 => '禁用',
|
|
||||||
1 => '启用',
|
|
||||||
);
|
|
||||||
return $status[$data['status']];
|
return $status[$data['status']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -9,6 +9,15 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
use think\facade\Route;
|
use think\facade\Route;
|
||||||
|
use app\model\Model;
|
||||||
|
|
||||||
|
$model = Model::where('status', '>', 0)->field(['id', 'name'])->select()->toArray();
|
||||||
|
|
||||||
|
foreach ($model as $value) {
|
||||||
|
Route::rule('/admin/' . $value['name'] . '/:function', 'admin.content/:function')->append(['name'=>$value['name']]);
|
||||||
|
Route::rule('/front/' . $value['name'] . '/:function', 'front.content/:function')->append(['name'=>$value['name']]);
|
||||||
|
Route::rule('/user/' . $value['name'] . '/:function', 'user.content/:function')->append(['name'=>$value['name']]);
|
||||||
|
}
|
||||||
|
|
||||||
Route::rule('/', 'Front.Index/index');
|
Route::rule('/', 'Front.Index/index');
|
||||||
Route::rule('search', 'Front.Content/search');
|
Route::rule('search', 'Front.Content/search');
|
||||||
@@ -48,4 +57,4 @@ Route::group('api', function () {
|
|||||||
'Access-Control-Allow-Headers' => 'authorization, token, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With',
|
'Access-Control-Allow-Headers' => 'authorization, token, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Route::miss('Index/miss');
|
Route::miss('front.Index/miss');
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
<h2>{$meta_title}</h2>
|
<h2>{$meta_title}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a class="btn btn-primary" href="{:url('admin/content/add?model_id='.$model_id)}">新 增</a>
|
<a class="btn btn-primary" href="{:url('/admin/'.$model_name.'/add')}">新 增</a>
|
||||||
<button class="btn btn-danger ajax-post confirm" url="{:url('admin/content/del?model_id='.$model_id)}" target-form="ids">删 除</button>
|
<button class="btn btn-danger ajax-post confirm" url="{:url('/admin/'.$model_name.'/del')}" target-form="ids">删 除</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
|
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
|
||||||
{volist name="grid['grids']" id="item"}
|
{volist name="grid" id="item"}
|
||||||
<th>{$item['title']}</th>
|
<th>{$item['title']}</th>
|
||||||
{/volist}
|
{/volist}
|
||||||
<th>操作</th>
|
<th>操作</th>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{if condition="empty($list)"}
|
{if condition="empty($list)"}
|
||||||
{php}
|
{php}
|
||||||
$cow = count($grid['grids'])+2;
|
$cow = count($grid)+2;
|
||||||
{/php}
|
{/php}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="{$cow}" align="center">暂无数据!</td>
|
<td colspan="{$cow}" align="center">暂无数据!</td>
|
||||||
@@ -56,30 +56,30 @@
|
|||||||
{volist name="list" id="item"}
|
{volist name="list" id="item"}
|
||||||
<tr>
|
<tr>
|
||||||
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
|
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
|
||||||
{volist name="grid['grids']" id="vo"}
|
{volist name="grid" id="vo"}
|
||||||
{if isset($vo['format'])}
|
{if isset($vo['format'])}
|
||||||
<td>{$item[$vo['field'][0]]|$vo['format']}</td>
|
<td>{$item[$vo['field']]|$vo['format']}</td>
|
||||||
{else/}
|
{else/}
|
||||||
<td>{$item[$vo['field'][0]]}</td>
|
<td>{$item[$vo['field']]}</td>
|
||||||
{/if}
|
{/if}
|
||||||
{/volist}
|
{/volist}
|
||||||
<td>
|
<td>
|
||||||
{if isset($item['is_top'])}
|
{if isset($item['is_top'])}
|
||||||
{if $item['is_top']}
|
{if $item['is_top']}
|
||||||
<a href="{:url('admin/content/settop?model_id='.$model_id,array('id'=>$item['id'],'is_top'=>'0'))}" class="ajax-get">取消置顶</a>
|
<a href="{:url('/admin/'.$model_name.'/settop', ['id'=>$item['id'],'is_top'=>'0'])}" class="ajax-get">取消置顶</a>
|
||||||
{else/}
|
{else/}
|
||||||
<a href="{:url('admin/content/settop?model_id='.$model_id,array('id'=>$item['id'],'is_top'=>'1'))}" class="ajax-get">置顶</a>
|
<a href="{:url('/admin/'.$model_name.'/settop', ['id'=>$item['id'],'is_top'=>'1'])}" class="ajax-get">置顶</a>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{if isset($item['status'])}
|
{if isset($item['status'])}
|
||||||
{if $item['status']}
|
{if $item['status']}
|
||||||
<a href="{:url('admin/content/status?model_id='.$model_id,array('id'=>$item['id'],'status'=>'0'))}" class="ajax-get">取消审核</a>
|
<a href="{:url('/admin/'.$model_name.'/status', ['id'=>$item['id'],'status'=>'0'])}" class="ajax-get">取消审核</a>
|
||||||
{else/}
|
{else/}
|
||||||
<a href="{:url('admin/content/status?model_id='.$model_id,array('id'=>$item['id'],'status'=>'1'))}" class="ajax-get">审核</a>
|
<a href="{:url('/admin/'.$model_name.'/status', ['id'=>$item['id'],'status'=>'1'])}" class="ajax-get">审核</a>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<a href="{:url('admin/content/edit?model_id='.$model_id,array('id'=>$item['id']))}" >编辑</a>
|
<a href="{:url('/admin/'.$model_name.'/edit', ['id'=>$item['id']])}" >编辑</a>
|
||||||
<a href="{:url('admin/content/del?model_id='.$model_id,array('id'=>$item['id']))}" class="ajax-get confirm">删除</a>
|
<a href="{:url('/admin/'.$model_name.'/del', ['id'=>$item['id']])}" class="ajax-get confirm">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/volist}
|
{/volist}
|
||||||
|
|||||||
Reference in New Issue
Block a user