更新代码,完善功能

This commit is contained in:
2020-02-18 14:50:57 +08:00
parent 31fd944b9c
commit 8bc0f7534b
36 changed files with 283 additions and 280 deletions

View File

@@ -1,5 +1,5 @@
## SentCMS介绍 ## SentCMS介绍
> SentCMS网站管理系统是南昌腾速科技有限公司倾力打造的一款简单易用的网站管理系统SentCMS网站管理系统下文简称SentCMS继承了thinkphp5.0的优秀品质秉承“大道至简”的设计理念。SnetCMS为网站建设而生为网站建设减少90%的代码编写,只需前端设计师就可以设计出完美的网站,而如此完美的系统还是完全开源的。 > SentCMS网站管理系统是南昌腾速科技有限公司倾力打造的一款简单易用的网站管理系统SentCMS网站管理系统下文简称SentCMS继承了thinkphp的优秀品质秉承“大道至简”的设计理念。SnetCMS为网站建设而生为网站建设减少90%的代码编写,只需前端设计师就可以设计出完美的网站,而如此完美的系统还是完全开源的。
## 环境要求 ## 环境要求
@@ -12,12 +12,11 @@
> 最好是使用云主机进行安装,虚拟主机有很多局限性 > 最好是使用云主机进行安装,虚拟主机有很多局限性
``` ```
git clone -b 4.0 https://gitee.com/sentcms/sentcms.git sentcms git clone -b 4.0 https://gitee.com/sentcms/sentcms.git sentcms
cd sentcms cd sentcms
``` ```
如果是直接下载压缩包则直接进入解压文件夹,然后执行下面的代码
把根目录下的.example.env文件复制一份并命名为.env 把根目录下的.example.env文件复制一份并命名为.env
``` ```
@@ -47,7 +46,7 @@ composer install
* 简单易用的标签体系 * 简单易用的标签体系
* 便捷的文档系统无需程序即可设计出完美的模型做出完美的网站传送门http://www.kancloud.cn/tensent/sentcms3/169624 * 便捷的文档系统无需程序即可设计出完美的模型做出完美的网站传送门http://www.kancloud.cn/tensent/sentcms3/169624
下载最新版框架后,解压缩到web目录下面,可以看到初始的目录结构如下: 下载最新版框架后,解压缩到sentcms目录下面,可以看到初始的目录结构如下:
## 目录结构 ## 目录结构
~~~ ~~~
├─addons 扩展插件目录 ├─addons 扩展插件目录
@@ -89,3 +88,7 @@ composer install
> 3.0.1611https://git.oschina.net/sentcms/sentcms/repository/archive/3.0.1611 > 3.0.1611https://git.oschina.net/sentcms/sentcms/repository/archive/3.0.1611
> 3.0.1609https://git.oschina.net/sentcms/sentcms/repository/archive/3.0.1609 > 3.0.1609https://git.oschina.net/sentcms/sentcms/repository/archive/3.0.1609
> 4.0 正在路上
> ……

View File

@@ -6,9 +6,11 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin; use app\controller\Admin;
use app\model\Addons as AddonsM;
use app\model\Hooks;
/** /**
* @title 插件管理 * @title 插件管理
@@ -16,34 +18,19 @@ use app\controller\Admin;
*/ */
class Addons extends Admin { class Addons extends Admin {
protected $addons;
public function _initialize() {
parent::_initialize();
//加入菜单
$this->getAddonsMenu();
$this->addons = model('Addons');
$this->hooks = db('Hooks');
}
/** /**
* @title 插件列表 * @title 插件列表
*/ */
public function index($refresh = 0) { public function index(AddonsM $addons, $refresh = 0) {
if ($refresh) { if ($refresh) {
$this->addons->refresh(); $addons->refresh();
} }
$list = $this->addons->order('id desc')->paginate(25, false, array( $list = $addons->order('id desc')->paginate($this->request->pageConfig);
'query' => $this->request->param(),
));
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$data = array( $this->data = array(
'list' => $list, 'list' => $list,
'page' => $list->render(), 'page' => $list->render(),
); );
$this->setMeta("插件管理");
$this->assign($data);
return $this->fetch(); return $this->fetch();
} }
@@ -218,22 +205,15 @@ class Addons extends Admin {
* @title 钩子列表 * @title 钩子列表
*/ */
public function hooks() { public function hooks() {
$map = [];
$map = array();
$order = "id desc"; $order = "id desc";
$list = model('Hooks')->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param(),
));
// 记录当前列表页的cookie $list = Hooks::where($map)->order($order)->paginate($this->request->pageConfig);
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$data = array( $this->data = array(
'list' => $list, 'list' => $list,
'page' => $list->render(), 'page' => $list->render(),
); );
$this->setMeta("钩子管理");
$this->assign($data);
return $this->fetch(); return $this->fetch();
} }

View File

@@ -11,7 +11,7 @@ namespace app\controller\admin;
use app\model\Category as CategoryM; use app\model\Category as CategoryM;
use app\model\Attribute; use app\model\Attribute;
use app\model\Module; use app\model\Model;
use app\controller\Admin; use app\controller\Admin;
/** /**
@@ -28,7 +28,7 @@ class Category extends Admin {
/** /**
* @title 栏目列表 * @title 栏目列表
*/ */
public function index(CategoryM $category, Attribute $attr, Module $medule) { public function index(CategoryM $category, Attribute $attr, Model $model) {
$param = $this->request->param(); $param = $this->request->param();
$map = []; $map = [];
@@ -42,8 +42,8 @@ class Category extends Admin {
$tree = new \sent\tree\Tree(); $tree = new \sent\tree\Tree();
$list = $tree->toFormatTree($list->toArray()); $list = $tree->toFormatTree($list->toArray());
} }
// $subsql = $attr->where('name', 'category_id')->fetchSql(true)->column('model_id'); $subsql = $attr->where('name', 'category_id')->fetchSql(true)->column('model_id');
// $model_list = $medule->where('id IN ('. $subsql.')')->select(); $model_list = $model->where('id IN ('. $subsql.')')->select();
$this->data = [ $this->data = [
'tree' => $list, 'tree' => $list,

View File

@@ -8,7 +8,10 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin; use app\controller\Admin;
use app\model\Channel as ChannelM;
use sent\tree\Tree;
/** /**
* @title 频道管理 * @title 频道管理
@@ -16,35 +19,27 @@ use app\controller\Admin;
*/ */
class Channel extends Admin { class Channel extends Admin {
public function _initialize() {
parent::_initialize();
}
/** /**
* @title 频道列表 * @title 频道列表
*/ */
public function index($type = 0) { public function index(ChannelM $channel, $type = 0) {
/* 获取频道列表 */ /* 获取频道列表 */
//$map = array('status' => array('gt', -1), 'pid'=>$pid); //$map = array('status' => array('gt', -1), 'pid'=>$pid);
$map = array('status' => array('gt', -1)); $map = array('status' => array('gt', -1));
if ($type) { if ($type) {
$map['type'] = $type; $map['type'] = $type;
} }
$list = db('Channel')->where($map)->order('sort asc,id asc')->column('*', 'id'); $list = $channel->where($map)->order('sort asc,id asc')->column('*', 'id');
if (!empty($list)) { if (!empty($list)) {
$tree = new \com\Tree(); $tree = new Tree();
$list = $tree->toFormatTree($list); $list = $tree->toFormatTree($list);
} }
config('_sys_get_channel_tree_', true); $this->data = array(
$data = array(
'tree' => $list, 'tree' => $list,
'type' => $type, 'type' => $type,
); );
$this->assign($data);
$this->setMeta('导航管理');
return $this->fetch(); return $this->fetch();
} }

View File

@@ -8,6 +8,8 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\model\Client as ClientM;
use app\controller\Admin; use app\controller\Admin;
/** /**
@@ -15,71 +17,65 @@ use app\controller\Admin;
*/ */
class Client extends Admin { class Client extends Admin {
public function _initialize() {
parent::_initialize();
$this->model = model('Client');
}
/** /**
* @title 客户端列表 * @title 客户端列表
*/ */
public function index() { public function index() {
$list = $this->model->paginate(25, false, array( $map = [];
'query' => $this->request->param(),
)); $list = ClientM::where($map)->paginate($this->request->pageConfig);
$data = array(
$this->data = array(
'list' => $list, 'list' => $list,
'page' => $list->render(), 'page' => $list->render(),
); );
$this->assign($data);
$this->setMeta('客户端列表');
return $this->fetch(); return $this->fetch();
} }
/** /**
* @title 添加客户端 * @title 添加客户端
*/ */
public function add(\think\Request $request) { public function add() {
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $request->param(); $data = $this->request->param();
$result = $this->model->validate(true)->save($data);
$result = ClientM::create($data);
if (false !== $result) { if (false !== $result) {
return $this->success('成功添加', url('client/index')); return $this->success('成功添加', url('client/index'));
} else { } else {
return $this->error($this->model->getError()); return $this->error('添加失败!');
} }
} else { } else {
$info['appid'] = rand_string(10, 1); //八位数字appid $info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥 $info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$data = array(
$this->data = array(
'info' => $info, 'info' => $info,
); );
$this->assign($data); return $this->fetch();
$this->setMeta('添加客户端');
return $this->fetch('add');
} }
} }
/** /**
* @title 编辑客户端 * @title 编辑客户端
*/ */
public function edit(\think\Request $request) { public function edit() {
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $request->param(); $data = $this->request->param();
$result = $this->model->validate(true)->save($data, array('id' => $request->param('id')));
$result = ClientM::update($data, ['id' => $this->request->param('id')]);
if (false !== $result) { if (false !== $result) {
return $this->success('修改添加', url('client/index')); return $this->success('修改添加', url('client/index'));
} else { } else {
return $this->error($this->model->getError()); return $this->error($this->model->getError());
} }
} else { } else {
$info = $this->model->where('id', $request->param('id'))->find(); $info = $ClientM::where('id', $request->param('id'))->find();
$data = array(
$this->data = array(
'info' => $info, 'info' => $info,
); );
$this->assign($data); return $this->fetch('admin/client/add');
$this->setMeta('编辑客户端');
return $this->fetch('add');
} }
} }

View File

@@ -215,18 +215,17 @@ class Config extends Admin {
/** /**
* @title 主题选择 * @title 主题选择
*/ */
public function themes() { public function themes(ConfigM $config) {
$list = $this->model->getThemesList(); $list = $config->getThemesList();
$pc = config('pc_themes'); $pc = config('system_config.pc_themes');
$mobile = config('mobile_themes'); $mobile = config('system_config.mobile_themes');
$data = array(
$this->data = array(
'pc' => $pc, 'pc' => $pc,
'mobile' => $mobile, 'mobile' => $mobile,
'list' => $list, 'list' => $list,
); );
$this->assign($data);
$this->setMeta('主题设置');
return $this->fetch(); return $this->fetch();
} }

View File

@@ -7,8 +7,9 @@
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\admin\controller; namespace app\controller\admin;
use app\common\controller\Admin;
use app\controller\Admin;
/** /**
* @title 数据库管理 * @title 数据库管理
@@ -20,54 +21,55 @@ class Database extends Admin {
* @param String $type import-还原export-备份 * @param String $type import-还原export-备份
* @author 麦当苗儿 <zuojiazi@vip.qq.com> * @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/ */
public function index($type = null) { public function index() {
$type = $this->request->get('type', 'import');
switch ($type) { switch ($type) {
/* 数据还原 */ /* 数据还原 */
case 'import': case 'import':
//列出备份文件列表 //列出备份文件列表
$path = config('data_backup_path'); $path = config('data_backup_path');
if (!is_dir($path)) { if (!is_dir($path)) {
mkdir($path, 0755, true); mkdir($path, 0755, true);
}
$path = realpath($path);
$flag = \FilesystemIterator::KEY_AS_FILENAME;
$glob = new \FilesystemIterator($path, $flag);
$list = array();
foreach ($glob as $name => $file) {
if (preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql(?:\.gz)?$/', $name)) {
$name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
$date = "{$name[0]}-{$name[1]}-{$name[2]}";
$time = "{$name[3]}:{$name[4]}:{$name[5]}";
$part = $name[6];
if (isset($list["{$date} {$time}"])) {
$info = $list["{$date} {$time}"];
$info['part'] = max($info['part'], $part);
$info['size'] = $info['size'] + $file->getSize();
} else {
$info['part'] = $part;
$info['size'] = $file->getSize();
}
$extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
$info['compress'] = ($extension === 'SQL') ? '-' : $extension;
$info['time'] = strtotime("{$date} {$time}");
$list["{$date} {$time}"] = $info;
} }
} $path = realpath($path);
$title = '数据还原'; $flag = \FilesystemIterator::KEY_AS_FILENAME;
break; $glob = new \FilesystemIterator($path, $flag);
/* 数据备份 */
case 'export': $list = array();
$Db = \think\Db::connect(); foreach ($glob as $name => $file) {
$list = $Db->query('SHOW TABLE STATUS'); if (preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql(?:\.gz)?$/', $name)) {
$list = array_map('array_change_key_case', $list); $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
$title = '数据备份';
break; $date = "{$name[0]}-{$name[1]}-{$name[2]}";
default: $time = "{$name[3]}:{$name[4]}:{$name[5]}";
return $this->error('参数错误!'); $part = $name[6];
if (isset($list["{$date} {$time}"])) {
$info = $list["{$date} {$time}"];
$info['part'] = max($info['part'], $part);
$info['size'] = $info['size'] + $file->getSize();
} else {
$info['part'] = $part;
$info['size'] = $file->getSize();
}
$extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
$info['compress'] = ($extension === 'SQL') ? '-' : $extension;
$info['time'] = strtotime("{$date} {$time}");
$list["{$date} {$time}"] = $info;
}
}
$title = '数据还原';
break;
/* 数据备份 */
case 'export':
$Db = \think\Db::connect();
$list = $Db->query('SHOW TABLE STATUS');
$list = array_map('array_change_key_case', $list);
$title = '数据备份';
break;
default:
return $this->error('参数错误!');
} }
//渲染模板 //渲染模板
$this->setMeta($title); $this->setMeta($title);

View File

@@ -58,10 +58,9 @@ class Index extends Admin {
* @title 后台退出 * @title 后台退出
* @return html * @return html
*/ */
public function logout() { public function logout(Member $user) {
$user = model('Member'); Session::delete('userInfo');
$user->logout(); $this->redirect('/admin/login');
$this->redirect('admin/index/login');
} }
/** /**
@@ -87,12 +86,10 @@ class Index extends Admin {
), ),
), ),
); );
$data = array( $this->data = array(
'keyList' => $keylist, 'keyList' => $keylist,
); );
$this->assign($data); return $this->fetch('admin/public/edit');
$this->setMeta("更新缓存");
return $this->fetch('public/edit');
} }
} }
} }

View File

@@ -6,8 +6,9 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\model\Link as LinkM;
use app\controller\Admin; use app\controller\Admin;
/** /**
@@ -19,20 +20,16 @@ class Link extends Admin {
/** /**
* @title 链接列表 * @title 链接列表
*/ */
public function index() { public function index(LinkM $link) {
$map = array(); $map = array();
$order = "id desc"; $order = "id desc";
$list = db('Link')->where($map)->order($order)->paginate(10, false, array( $list = $link->where($map)->order($order)->paginate($this->request->pageConfig);
'query' => $this->request->param(),
));
$data = array( $this->data = array(
'list' => $list, 'list' => $list,
'page' => $list->render(), 'page' => $list->render(),
); );
$this->assign($data);
$this->setMeta("友情链接");
return $this->fetch(); return $this->fetch();
} }

View File

@@ -6,9 +6,10 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin; use app\controller\Admin;
use app\model\Model as ModelM;
/** /**
* @title 模型管理 * @title 模型管理
@@ -18,7 +19,6 @@ class Model extends Admin {
public function _initialize() { public function _initialize() {
parent::_initialize(); parent::_initialize();
$this->getContentMenu(); $this->getContentMenu();
$this->model = model('Model');
} }
/** /**
@@ -26,23 +26,17 @@ class Model extends Admin {
* @author huajie <banhuajie@163.com> * @author huajie <banhuajie@163.com>
*/ */
public function index() { public function index() {
$map = array('status' => array('gt', -1)); $map = [];
$map[] = ['status', '>', '-1'];
$order = "id desc"; $order = "id desc";
$list = $this->model->where($map)->order($order)->paginate(10, false, array( $list = ModelM::where($map)->order($order)->paginate($this->request->pageConfig);
'query' => $this->request->param(),
));
$data = array( $this->data = array(
'list' => $list, 'list' => $list,
'page' => $list->render(), 'page' => $list->render(),
); );
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$this->assign($data);
$this->setMeta('模型管理');
return $this->fetch(); return $this->fetch();
} }

17
app/model/Addons.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 分类模型
*/
class Addons extends \think\Model {
}

View File

@@ -12,44 +12,44 @@ namespace app\model;
/** /**
* 设置模型 * 设置模型
*/ */
class Attribute { class Attribute extends \think\Model {
protected $type = array( protected $type = array(
'id' => 'integer', 'id' => 'integer',
); );
protected static function init() { // protected static function init() {
self::afterInsert(function ($data) { // self::afterInsert(function ($data) {
if ($data['model_id']) { // if ($data['model_id']) {
$name = db('Model')->where('id', $data['model_id'])->value('name'); // $name = db('Model')->where('id', $data['model_id'])->value('name');
$db = new \com\Datatable(); // $db = new \com\Datatable();
$attr = $data->toArray(); // $attr = $data->toArray();
$model_attr = array( // $model_attr = array(
'model_id' => $data['model_id'], // 'model_id' => $data['model_id'],
'attr_id' => $data->id, // 'attr_id' => $data->id,
'group_id' => 0, // 'group_id' => 0,
'is_add_table' => 1, // 'is_add_table' => 1,
'is_show' => $data['is_show'], // 'is_show' => $data['is_show'],
'is_must' => $data['is_must'], // 'is_must' => $data['is_must'],
'sort' => 0, // 'sort' => 0,
); // );
$attr['after'] = db('Attribute')->where('name', '<>', $data['name'])->where('model_id', $data['model_id'])->order('id desc')->value('name'); // $attr['after'] = db('Attribute')->where('name', '<>', $data['name'])->where('model_id', $data['model_id'])->order('id desc')->value('name');
return $db->columField(strtolower($name), $attr)->query(); // return $db->columField(strtolower($name), $attr)->query();
} // }
}); // });
self::beforeUpdate(function ($data) { // self::beforeUpdate(function ($data) {
$attr = $data->toArray(); // $attr = $data->toArray();
$attr['action'] = 'CHANGE'; // $attr['action'] = 'CHANGE';
$attr['oldname'] = db('Attribute')->where('id', $attr['id'])->value('name'); // $attr['oldname'] = db('Attribute')->where('id', $attr['id'])->value('name');
if ($attr['id']) { // if ($attr['id']) {
$name = db('Model')->where('id', $attr['model_id'])->value('name'); // $name = db('Model')->where('id', $attr['model_id'])->value('name');
$db = new \com\Datatable(); // $db = new \com\Datatable();
return $db->columField(strtolower($name), $attr)->query(); // return $db->columField(strtolower($name), $attr)->query();
} else { // } else {
return false; // return false;
} // }
}); // });
} // }
protected function getTypeTextAttr($value, $data) { protected function getTypeTextAttr($value, $data) {
$type = config('config_type_list'); $type = config('config_type_list');

View File

@@ -12,7 +12,7 @@ namespace app\model;
/** /**
* 设置模型 * 设置模型
*/ */
class Channel { class Channel extends \think\Model {
protected $type = array( protected $type = array(
'id' => 'integer', 'id' => 'integer',

View File

@@ -12,7 +12,7 @@ namespace app\model;
/** /**
* Client模型 * Client模型
*/ */
class Client { class Client extends \think\Model{
protected $auto = array('update_time'); protected $auto = array('update_time');
protected $insert = array('create_time'); protected $insert = array('create_time');

View File

@@ -79,4 +79,11 @@ class Config extends Model {
} }
return $data; return $data;
} }
public function getThemesList(){
return [
'pc' => [],
'mobile' => []
];
}
} }

17
app/model/Hooks.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 分类模型
*/
class Hooks extends \think\Model {
}

View File

@@ -6,14 +6,13 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\model; namespace app\model;
/** /**
* 友情链接类 * 友情链接类
* @author molong <molong@tensent.cn> * @author molong <molong@tensent.cn>
*/ */
class Link extends \app\common\model\Base { class Link extends \think\Model {
public $keyList = array( public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'), array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),

View File

@@ -12,7 +12,7 @@ namespace app\model;
/** /**
* 设置模型 * 设置模型
*/ */
class Module { class Model extends \think\Model{
protected $auto = ['update_time']; protected $auto = ['update_time'];
protected $insert = ['name', 'create_time', 'status' => 1, 'list_grid' => "id:ID\r\ntitle:标题\r\ncreate_time:添加时间|time_format\r\nupdate_time:更新时间|time_format"]; protected $insert = ['name', 'create_time', 'status' => 1, 'list_grid' => "id:ID\r\ntitle:标题\r\ncreate_time:添加时间|time_format\r\nupdate_time:更新时间|time_format"];
@@ -22,57 +22,57 @@ class Module {
'update_time' => 'integer', 'update_time' => 'integer',
); );
protected static function init() { // protected static function init() {
self::beforeInsert(function ($event) { // self::beforeInsert(function ($event) {
$data = $event->toArray(); // $data = $event->toArray();
$tablename = strtolower($data['name']); // $tablename = strtolower($data['name']);
//实例化一个数据库操作类 // //实例化一个数据库操作类
$db = new \com\Datatable(); // $db = new \com\Datatable();
//检查表是否存在并创建 // //检查表是否存在并创建
if (!$db->CheckTable($tablename)) { // if (!$db->CheckTable($tablename)) {
//创建新表 // //创建新表
return $db->initTable($tablename, $data['title'], 'id')->query(); // return $db->initTable($tablename, $data['title'], 'id')->query();
} else { // } else {
return false; // return false;
} // }
}); // });
self::afterInsert(function ($event) { // self::afterInsert(function ($event) {
$data = $event->toArray(); // $data = $event->toArray();
$fields = include (APP_PATH . 'admin/fields.php'); // $fields = include (APP_PATH . 'admin/fields.php');
if (!empty($fields)) { // if (!empty($fields)) {
foreach ($fields as $key => $value) { // foreach ($fields as $key => $value) {
if ($data['is_doc']) { // if ($data['is_doc']) {
$fields[$key]['model_id'] = $data['id']; // $fields[$key]['model_id'] = $data['id'];
} else { // } else {
if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) { // if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) {
$fields[$key]['model_id'] = $data['id']; // $fields[$key]['model_id'] = $data['id'];
} else { // } else {
unset($fields[$key]); // unset($fields[$key]);
} // }
} // }
} // }
model('Attribute')->saveAll($fields); // model('Attribute')->saveAll($fields);
} // }
return true; // return true;
}); // });
self::beforeUpdate(function ($event) { // self::beforeUpdate(function ($event) {
$data = $event->toArray(); // $data = $event->toArray();
if (isset($data['attribute_sort']) && $data['attribute_sort']) { // if (isset($data['attribute_sort']) && $data['attribute_sort']) {
$attribute_sort = json_decode($data['attribute_sort'], true); // $attribute_sort = json_decode($data['attribute_sort'], true);
if (!empty($attribute_sort)) { // if (!empty($attribute_sort)) {
foreach ($attribute_sort as $key => $value) { // foreach ($attribute_sort as $key => $value) {
db('Attribute')->where('id', 'IN', $value)->setField('group_id', $key); // db('Attribute')->where('id', 'IN', $value)->setField('group_id', $key);
foreach ($value as $k => $v) { // foreach ($value as $k => $v) {
db('Attribute')->where('id', $v)->setField('sort', $k); // db('Attribute')->where('id', $v)->setField('sort', $k);
} // }
} // }
} // }
} // }
return true; // return true;
}); // });
} // }
protected function setAttributeSortAttr($value) { protected function setAttributeSortAttr($value) {
return $value ? json_encode($value) : ''; return $value ? json_encode($value) : '';

View File

@@ -60,7 +60,7 @@
</tbody> </tbody>
</table> </table>
<!-- 分页 --> <!-- 分页 -->
{$page} {$page|raw}
<!-- /分页 --> <!-- /分页 -->
</div> </div>
</div> </div>

View File

@@ -42,7 +42,7 @@
</tbody> </tbody>
</table> </table>
<!-- 分页 --> <!-- 分页 -->
{$page} {$page|raw}
<!-- /分页 --> <!-- /分页 -->
</div> </div>
</div> </div>

View File

@@ -45,7 +45,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -42,7 +42,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -58,7 +58,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -42,7 +42,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -41,7 +41,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -87,7 +87,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -42,7 +42,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -62,7 +62,7 @@
{/notempty} {/notempty}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -52,7 +52,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -66,7 +66,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
{/if} {/if}
</div> </div>

View File

@@ -61,7 +61,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
{/if} {/if}
</div> </div>

View File

@@ -1,6 +1,6 @@
{extend name="admin/public/base"/} {extend name="admin/public/base"/}
{block name="style"} {block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css"> <link rel="stylesheet" type="text/css" href="__static__/common/css/bootstrap-editable.css">
{/block} {/block}
{block name="body"} {block name="body"}
<div class="main-box clearfix"> <div class="main-box clearfix">
@@ -9,8 +9,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('add')}">新 增</a> <a class="btn btn-primary" href="{:url('/admin/link/add')}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('delete')}" target-form="ids">删 除</button> <button class="btn btn-danger ajax-post confirm" url="{:url('/admin/link/delete')}" target-form="ids">删 除</button>
</div> </div>
</header> </header>
<div class="main-box-body clearfix"> <div class="main-box-body clearfix">
@@ -33,16 +33,16 @@
<td>{$item['id']}</td> <td>{$item['id']}</td>
<td>{$item['title']}</td> <td>{$item['title']}</td>
<td>{$item['sort']}</td> <td>{$item['sort']}</td>
<td>{$item['update_time']|date='Y-m-d',###}</td> <td>{$item['update_time']}</td>
<td> <td>
<a href="{:url('edit?id='.$item['id'])}">编辑</a> <a href="{:url('/admin/link/edit?id='.$item['id'])}">编辑</a>
<a href="{:url('delete?id='.$item['id'])}" class="confirm ajax-get">删除</a> <a href="{:url('/admin/link/delete?id='.$item['id'])}" class="confirm ajax-get">删除</a>
</td> </td>
</tr> </tr>
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -65,7 +65,7 @@
</table> </table>
</div> </div>
{$page} {$page|raw}
</div> </div>
</div> </div>
{/block} {/block}

View File

@@ -17,23 +17,23 @@
<li class="dropdown profile-dropdown"> <li class="dropdown profile-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="__img__/samples/scarlet-159.png" alt=""/> <img src="__img__/samples/scarlet-159.png" alt=""/>
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b> <span class="hidden-xs">{:session('userInfo.nickname')}</span> <b class="caret"></b>
</a> </a>
<ul class="dropdown-menu dropdown-menu-right"> <ul class="dropdown-menu dropdown-menu-right">
<li> <li>
<a href="{:url('admin/User/edit')}"> <a href="{:url('/admin/User/edit')}">
<i class="fa fa-user"></i> <i class="fa fa-user"></i>
修改资料 修改资料
</a> </a>
</li> </li>
<li> <li>
<a href="{:url('admin/User/editpwd')}"> <a href="{:url('/admin/User/editpwd')}">
<i class="fa fa-cog"></i> <i class="fa fa-cog"></i>
修改密码 修改密码
</a> </a>
</li> </li>
<li> <li>
<a href="{:url('admin/index/logout')}"> <a href="{:url('/admin/index/logout')}">
<i class="fa fa-power-off"></i> <i class="fa fa-power-off"></i>
退出后台 退出后台
</a> </a>
@@ -71,23 +71,23 @@
<li class="dropdown profile-dropdown hidden-sm hidden-xs"> <li class="dropdown profile-dropdown hidden-sm hidden-xs">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="__img__/samples/scarlet-159.png" alt=""/> <img src="__img__/samples/scarlet-159.png" alt=""/>
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b> <span class="hidden-xs">{:session('userInfo.nickname')}</span> <b class="caret"></b>
</a> </a>
<ul class="dropdown-menu dropdown-menu-right"> <ul class="dropdown-menu dropdown-menu-right">
<li> <li>
<a href="{:url('admin/User/edit')}"> <a href="{:url('/admin/User/edit')}">
<i class="fa fa-user"></i> <i class="fa fa-user"></i>
修改资料 修改资料
</a> </a>
</li> </li>
<li> <li>
<a href="{:url('admin/User/editpwd')}"> <a href="{:url('/admin/User/editpwd')}">
<i class="fa fa-cog"></i> <i class="fa fa-cog"></i>
修改密码 修改密码
</a> </a>
</li> </li>
<li> <li>
<a href="{:url('admin/index/logout')}"> <a href="{:url('/admin/index/logout')}">
<i class="fa fa-power-off"></i> <i class="fa fa-power-off"></i>
退出后台 退出后台
</a> </a>

View File

@@ -44,7 +44,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -78,7 +78,7 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
{$page} {$page|raw}
</div> </div>
</div> </div>
</div> </div>