更新代码,完善功能
This commit is contained in:
13
README.md
13
README.md
@@ -1,5 +1,5 @@
|
||||
## 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
|
||||
cd sentcms
|
||||
```
|
||||
|
||||
如果是直接下载压缩包则直接进入解压文件夹,然后执行下面的代码
|
||||
把根目录下的.example.env文件复制一份并命名为.env
|
||||
|
||||
```
|
||||
@@ -47,7 +46,7 @@ composer install
|
||||
* 简单易用的标签体系
|
||||
* 便捷的文档系统,无需程序即可设计出完美的模型,做出完美的网站,传送门:http://www.kancloud.cn/tensent/sentcms3/169624
|
||||
|
||||
下载最新版框架后,解压缩到web目录下面,可以看到初始的目录结构如下:
|
||||
下载最新版框架后,解压缩到sentcms目录下面,可以看到初始的目录结构如下:
|
||||
## 目录结构
|
||||
~~~
|
||||
├─addons 扩展插件目录
|
||||
@@ -88,4 +87,8 @@ composer install
|
||||
|
||||
> 3.0.1611:https://git.oschina.net/sentcms/sentcms/repository/archive/3.0.1611
|
||||
|
||||
> 3.0.1609:https://git.oschina.net/sentcms/sentcms/repository/archive/3.0.1609
|
||||
> 3.0.1609:https://git.oschina.net/sentcms/sentcms/repository/archive/3.0.1609
|
||||
|
||||
> 4.0 正在路上
|
||||
|
||||
> ……
|
||||
@@ -6,9 +6,11 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Addons as AddonsM;
|
||||
use app\model\Hooks;
|
||||
|
||||
/**
|
||||
* @title 插件管理
|
||||
@@ -16,34 +18,19 @@ use app\controller\Admin;
|
||||
*/
|
||||
class Addons extends Admin {
|
||||
|
||||
protected $addons;
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
//加入菜单
|
||||
$this->getAddonsMenu();
|
||||
$this->addons = model('Addons');
|
||||
$this->hooks = db('Hooks');
|
||||
}
|
||||
/**
|
||||
* @title 插件列表
|
||||
*/
|
||||
public function index($refresh = 0) {
|
||||
public function index(AddonsM $addons, $refresh = 0) {
|
||||
if ($refresh) {
|
||||
$this->addons->refresh();
|
||||
$addons->refresh();
|
||||
}
|
||||
$list = $this->addons->order('id desc')->paginate(25, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
$list = $addons->order('id desc')->paginate($this->request->pageConfig);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->setMeta("插件管理");
|
||||
$this->assign($data);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -218,22 +205,15 @@ class Addons extends Admin {
|
||||
* @title 钩子列表
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
$map = array();
|
||||
$map = [];
|
||||
$order = "id desc";
|
||||
$list = model('Hooks')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
$list = Hooks::where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->setMeta("钩子管理");
|
||||
$this->assign($data);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace app\controller\admin;
|
||||
|
||||
use app\model\Category as CategoryM;
|
||||
use app\model\Attribute;
|
||||
use app\model\Module;
|
||||
use app\model\Model;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ class Category extends Admin {
|
||||
/**
|
||||
* @title 栏目列表
|
||||
*/
|
||||
public function index(CategoryM $category, Attribute $attr, Module $medule) {
|
||||
public function index(CategoryM $category, Attribute $attr, Model $model) {
|
||||
$param = $this->request->param();
|
||||
$map = [];
|
||||
|
||||
@@ -42,8 +42,8 @@ class Category extends Admin {
|
||||
$tree = new \sent\tree\Tree();
|
||||
$list = $tree->toFormatTree($list->toArray());
|
||||
}
|
||||
// $subsql = $attr->where('name', 'category_id')->fetchSql(true)->column('model_id');
|
||||
// $model_list = $medule->where('id IN ('. $subsql.')')->select();
|
||||
$subsql = $attr->where('name', 'category_id')->fetchSql(true)->column('model_id');
|
||||
$model_list = $model->where('id IN ('. $subsql.')')->select();
|
||||
|
||||
$this->data = [
|
||||
'tree' => $list,
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Channel as ChannelM;
|
||||
use sent\tree\Tree;
|
||||
|
||||
/**
|
||||
* @title 频道管理
|
||||
@@ -16,35 +19,27 @@ use app\controller\Admin;
|
||||
*/
|
||||
class Channel extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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));
|
||||
if ($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)) {
|
||||
$tree = new \com\Tree();
|
||||
$tree = new Tree();
|
||||
$list = $tree->toFormatTree($list);
|
||||
}
|
||||
|
||||
config('_sys_get_channel_tree_', true);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'tree' => $list,
|
||||
'type' => $type,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('导航管理');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\Client as ClientM;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
@@ -15,71 +17,65 @@ use app\controller\Admin;
|
||||
*/
|
||||
class Client extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->model = model('Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 客户端列表
|
||||
*/
|
||||
public function index() {
|
||||
$list = $this->model->paginate(25, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$data = array(
|
||||
$map = [];
|
||||
|
||||
$list = ClientM::where($map)->paginate($this->request->pageConfig);
|
||||
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('客户端列表');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加客户端
|
||||
*/
|
||||
public function add(\think\Request $request) {
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
$result = $this->model->validate(true)->save($data);
|
||||
$data = $this->request->param();
|
||||
|
||||
$result = ClientM::create($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('成功添加', url('client/index'));
|
||||
} else {
|
||||
return $this->error($this->model->getError());
|
||||
return $this->error('添加失败!');
|
||||
}
|
||||
} else {
|
||||
$info['appid'] = rand_string(10, 1); //八位数字appid
|
||||
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
||||
$data = array(
|
||||
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('添加客户端');
|
||||
return $this->fetch('add');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑客户端
|
||||
*/
|
||||
public function edit(\think\Request $request) {
|
||||
public function edit() {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
$result = $this->model->validate(true)->save($data, array('id' => $request->param('id')));
|
||||
$data = $this->request->param();
|
||||
|
||||
$result = ClientM::update($data, ['id' => $this->request->param('id')]);
|
||||
if (false !== $result) {
|
||||
return $this->success('修改添加', url('client/index'));
|
||||
} else {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
} else {
|
||||
$info = $this->model->where('id', $request->param('id'))->find();
|
||||
$data = array(
|
||||
$info = $ClientM::where('id', $request->param('id'))->find();
|
||||
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('编辑客户端');
|
||||
return $this->fetch('add');
|
||||
return $this->fetch('admin/client/add');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,18 +215,17 @@ class Config extends Admin {
|
||||
/**
|
||||
* @title 主题选择
|
||||
*/
|
||||
public function themes() {
|
||||
$list = $this->model->getThemesList();
|
||||
$pc = config('pc_themes');
|
||||
$mobile = config('mobile_themes');
|
||||
$data = array(
|
||||
public function themes(ConfigM $config) {
|
||||
$list = $config->getThemesList();
|
||||
$pc = config('system_config.pc_themes');
|
||||
$mobile = config('system_config.mobile_themes');
|
||||
|
||||
$this->data = array(
|
||||
'pc' => $pc,
|
||||
'mobile' => $mobile,
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
$this->assign($data);
|
||||
$this->setMeta('主题设置');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* @title 数据库管理
|
||||
@@ -20,54 +21,55 @@ class Database extends Admin {
|
||||
* @param String $type import-还原,export-备份
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function index($type = null) {
|
||||
public function index() {
|
||||
$type = $this->request->get('type', 'import');
|
||||
switch ($type) {
|
||||
/* 数据还原 */
|
||||
case 'import':
|
||||
//列出备份文件列表
|
||||
$path = config('data_backup_path');
|
||||
if (!is_dir($path)) {
|
||||
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;
|
||||
/* 数据还原 */
|
||||
case 'import':
|
||||
//列出备份文件列表
|
||||
$path = config('data_backup_path');
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
}
|
||||
$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('参数错误!');
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$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);
|
||||
|
||||
@@ -58,10 +58,9 @@ class Index extends Admin {
|
||||
* @title 后台退出
|
||||
* @return html
|
||||
*/
|
||||
public function logout() {
|
||||
$user = model('Member');
|
||||
$user->logout();
|
||||
$this->redirect('admin/index/login');
|
||||
public function logout(Member $user) {
|
||||
Session::delete('userInfo');
|
||||
$this->redirect('/admin/login');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,12 +86,10 @@ class Index extends Admin {
|
||||
),
|
||||
),
|
||||
);
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'keyList' => $keylist,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("更新缓存");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,9 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\Link as LinkM;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
@@ -19,20 +20,16 @@ class Link extends Admin {
|
||||
/**
|
||||
* @title 链接列表
|
||||
*/
|
||||
public function index() {
|
||||
public function index(LinkM $link) {
|
||||
$map = array();
|
||||
|
||||
$order = "id desc";
|
||||
$list = db('Link')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$list = $link->where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("友情链接");
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Model as ModelM;
|
||||
|
||||
/**
|
||||
* @title 模型管理
|
||||
@@ -18,7 +19,6 @@ class Model extends Admin {
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->getContentMenu();
|
||||
$this->model = model('Model');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,23 +26,17 @@ class Model extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function index() {
|
||||
$map = array('status' => array('gt', -1));
|
||||
$map = [];
|
||||
|
||||
$map[] = ['status', '>', '-1'];
|
||||
|
||||
$order = "id desc";
|
||||
$list = $this->model->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$list = ModelM::where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$this->assign($data);
|
||||
$this->setMeta('模型管理');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
17
app/model/Addons.php
Normal file
17
app/model/Addons.php
Normal 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 {
|
||||
|
||||
}
|
||||
@@ -12,44 +12,44 @@ namespace app\model;
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Attribute {
|
||||
class Attribute extends \think\Model {
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
protected static function init() {
|
||||
self::afterInsert(function ($data) {
|
||||
if ($data['model_id']) {
|
||||
$name = db('Model')->where('id', $data['model_id'])->value('name');
|
||||
$db = new \com\Datatable();
|
||||
$attr = $data->toArray();
|
||||
$model_attr = array(
|
||||
'model_id' => $data['model_id'],
|
||||
'attr_id' => $data->id,
|
||||
'group_id' => 0,
|
||||
'is_add_table' => 1,
|
||||
'is_show' => $data['is_show'],
|
||||
'is_must' => $data['is_must'],
|
||||
'sort' => 0,
|
||||
);
|
||||
$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();
|
||||
}
|
||||
});
|
||||
self::beforeUpdate(function ($data) {
|
||||
$attr = $data->toArray();
|
||||
$attr['action'] = 'CHANGE';
|
||||
$attr['oldname'] = db('Attribute')->where('id', $attr['id'])->value('name');
|
||||
if ($attr['id']) {
|
||||
$name = db('Model')->where('id', $attr['model_id'])->value('name');
|
||||
$db = new \com\Datatable();
|
||||
return $db->columField(strtolower($name), $attr)->query();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
// protected static function init() {
|
||||
// self::afterInsert(function ($data) {
|
||||
// if ($data['model_id']) {
|
||||
// $name = db('Model')->where('id', $data['model_id'])->value('name');
|
||||
// $db = new \com\Datatable();
|
||||
// $attr = $data->toArray();
|
||||
// $model_attr = array(
|
||||
// 'model_id' => $data['model_id'],
|
||||
// 'attr_id' => $data->id,
|
||||
// 'group_id' => 0,
|
||||
// 'is_add_table' => 1,
|
||||
// 'is_show' => $data['is_show'],
|
||||
// 'is_must' => $data['is_must'],
|
||||
// 'sort' => 0,
|
||||
// );
|
||||
// $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();
|
||||
// }
|
||||
// });
|
||||
// self::beforeUpdate(function ($data) {
|
||||
// $attr = $data->toArray();
|
||||
// $attr['action'] = 'CHANGE';
|
||||
// $attr['oldname'] = db('Attribute')->where('id', $attr['id'])->value('name');
|
||||
// if ($attr['id']) {
|
||||
// $name = db('Model')->where('id', $attr['model_id'])->value('name');
|
||||
// $db = new \com\Datatable();
|
||||
// return $db->columField(strtolower($name), $attr)->query();
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
protected function getTypeTextAttr($value, $data) {
|
||||
$type = config('config_type_list');
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace app\model;
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Channel {
|
||||
class Channel extends \think\Model {
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace app\model;
|
||||
/**
|
||||
* Client模型
|
||||
*/
|
||||
class Client {
|
||||
class Client extends \think\Model{
|
||||
protected $auto = array('update_time');
|
||||
protected $insert = array('create_time');
|
||||
|
||||
|
||||
@@ -79,4 +79,11 @@ class Config extends Model {
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getThemesList(){
|
||||
return [
|
||||
'pc' => [],
|
||||
'mobile' => []
|
||||
];
|
||||
}
|
||||
}
|
||||
17
app/model/Hooks.php
Normal file
17
app/model/Hooks.php
Normal 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 {
|
||||
|
||||
}
|
||||
@@ -6,14 +6,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\model;
|
||||
|
||||
/**
|
||||
* 友情链接类
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
class Link extends \app\common\model\Base {
|
||||
class Link extends \think\Model {
|
||||
|
||||
public $keyList = array(
|
||||
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace app\model;
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Module {
|
||||
class Model extends \think\Model{
|
||||
|
||||
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"];
|
||||
@@ -22,57 +22,57 @@ class Module {
|
||||
'update_time' => 'integer',
|
||||
);
|
||||
|
||||
protected static function init() {
|
||||
self::beforeInsert(function ($event) {
|
||||
$data = $event->toArray();
|
||||
$tablename = strtolower($data['name']);
|
||||
//实例化一个数据库操作类
|
||||
$db = new \com\Datatable();
|
||||
//检查表是否存在并创建
|
||||
if (!$db->CheckTable($tablename)) {
|
||||
//创建新表
|
||||
return $db->initTable($tablename, $data['title'], 'id')->query();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
self::afterInsert(function ($event) {
|
||||
$data = $event->toArray();
|
||||
// protected static function init() {
|
||||
// self::beforeInsert(function ($event) {
|
||||
// $data = $event->toArray();
|
||||
// $tablename = strtolower($data['name']);
|
||||
// //实例化一个数据库操作类
|
||||
// $db = new \com\Datatable();
|
||||
// //检查表是否存在并创建
|
||||
// if (!$db->CheckTable($tablename)) {
|
||||
// //创建新表
|
||||
// return $db->initTable($tablename, $data['title'], 'id')->query();
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
// self::afterInsert(function ($event) {
|
||||
// $data = $event->toArray();
|
||||
|
||||
$fields = include (APP_PATH . 'admin/fields.php');
|
||||
if (!empty($fields)) {
|
||||
foreach ($fields as $key => $value) {
|
||||
if ($data['is_doc']) {
|
||||
$fields[$key]['model_id'] = $data['id'];
|
||||
} else {
|
||||
if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) {
|
||||
$fields[$key]['model_id'] = $data['id'];
|
||||
} else {
|
||||
unset($fields[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
model('Attribute')->saveAll($fields);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
self::beforeUpdate(function ($event) {
|
||||
$data = $event->toArray();
|
||||
if (isset($data['attribute_sort']) && $data['attribute_sort']) {
|
||||
$attribute_sort = json_decode($data['attribute_sort'], true);
|
||||
// $fields = include (APP_PATH . 'admin/fields.php');
|
||||
// if (!empty($fields)) {
|
||||
// foreach ($fields as $key => $value) {
|
||||
// if ($data['is_doc']) {
|
||||
// $fields[$key]['model_id'] = $data['id'];
|
||||
// } else {
|
||||
// if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) {
|
||||
// $fields[$key]['model_id'] = $data['id'];
|
||||
// } else {
|
||||
// unset($fields[$key]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// model('Attribute')->saveAll($fields);
|
||||
// }
|
||||
// return true;
|
||||
// });
|
||||
// self::beforeUpdate(function ($event) {
|
||||
// $data = $event->toArray();
|
||||
// if (isset($data['attribute_sort']) && $data['attribute_sort']) {
|
||||
// $attribute_sort = json_decode($data['attribute_sort'], true);
|
||||
|
||||
if (!empty($attribute_sort)) {
|
||||
foreach ($attribute_sort as $key => $value) {
|
||||
db('Attribute')->where('id', 'IN', $value)->setField('group_id', $key);
|
||||
foreach ($value as $k => $v) {
|
||||
db('Attribute')->where('id', $v)->setField('sort', $k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
// if (!empty($attribute_sort)) {
|
||||
// foreach ($attribute_sort as $key => $value) {
|
||||
// db('Attribute')->where('id', 'IN', $value)->setField('group_id', $key);
|
||||
// foreach ($value as $k => $v) {
|
||||
// db('Attribute')->where('id', $v)->setField('sort', $k);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// });
|
||||
// }
|
||||
|
||||
protected function setAttributeSortAttr($value) {
|
||||
return $value ? json_encode($value) : '';
|
||||
@@ -60,7 +60,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- 分页 -->
|
||||
{$page}
|
||||
{$page|raw}
|
||||
<!-- /分页 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- 分页 -->
|
||||
{$page}
|
||||
{$page|raw}
|
||||
<!-- /分页 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
{/notempty}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{extend name="admin/public/base"/}
|
||||
{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 name="body"}
|
||||
<div class="main-box clearfix">
|
||||
@@ -9,8 +9,8 @@
|
||||
<h2>{$meta_title}</h2>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-primary" href="{:url('add')}">新 增</a>
|
||||
<button class="btn btn-danger ajax-post confirm" url="{:url('delete')}" target-form="ids">删 除</button>
|
||||
<a class="btn btn-primary" href="{:url('/admin/link/add')}">新 增</a>
|
||||
<button class="btn btn-danger ajax-post confirm" url="{:url('/admin/link/delete')}" target-form="ids">删 除</button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="main-box-body clearfix">
|
||||
@@ -33,16 +33,16 @@
|
||||
<td>{$item['id']}</td>
|
||||
<td>{$item['title']}</td>
|
||||
<td>{$item['sort']}</td>
|
||||
<td>{$item['update_time']|date='Y-m-d',###}</td>
|
||||
<td>{$item['update_time']}</td>
|
||||
<td>
|
||||
<a href="{:url('edit?id='.$item['id'])}">编辑</a>
|
||||
<a href="{:url('delete?id='.$item['id'])}" class="confirm ajax-get">删除</a>
|
||||
<a href="{:url('/admin/link/edit?id='.$item['id'])}">编辑</a>
|
||||
<a href="{:url('/admin/link/delete?id='.$item['id'])}" class="confirm ajax-get">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
</table>
|
||||
|
||||
</div>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
@@ -17,23 +17,23 @@
|
||||
<li class="dropdown profile-dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<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>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li>
|
||||
<a href="{:url('admin/User/edit')}">
|
||||
<a href="{:url('/admin/User/edit')}">
|
||||
<i class="fa fa-user"></i>
|
||||
修改资料
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{:url('admin/User/editpwd')}">
|
||||
<a href="{:url('/admin/User/editpwd')}">
|
||||
<i class="fa fa-cog"></i>
|
||||
修改密码
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{:url('admin/index/logout')}">
|
||||
<a href="{:url('/admin/index/logout')}">
|
||||
<i class="fa fa-power-off"></i>
|
||||
退出后台
|
||||
</a>
|
||||
@@ -71,23 +71,23 @@
|
||||
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<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>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li>
|
||||
<a href="{:url('admin/User/edit')}">
|
||||
<a href="{:url('/admin/User/edit')}">
|
||||
<i class="fa fa-user"></i>
|
||||
修改资料
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{:url('admin/User/editpwd')}">
|
||||
<a href="{:url('/admin/User/editpwd')}">
|
||||
<i class="fa fa-cog"></i>
|
||||
修改密码
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{:url('admin/index/logout')}">
|
||||
<a href="{:url('/admin/index/logout')}">
|
||||
<i class="fa fa-power-off"></i>
|
||||
退出后台
|
||||
</a>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user