权限节点的更新
This commit is contained in:
@@ -10,10 +10,14 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 行为管理
|
||||
* @description 行为管理
|
||||
*/
|
||||
class Action extends Admin {
|
||||
|
||||
/**
|
||||
* 用户行为列表
|
||||
* @title 用户行为列表
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function index() {
|
||||
@@ -37,7 +41,7 @@ class Action extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建用户行为
|
||||
* @title 新建用户行为
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function add() {
|
||||
@@ -62,7 +66,7 @@ class Action extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑用户行为
|
||||
* @title 编辑用户行为
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
@@ -92,7 +96,7 @@ class Action extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户行为状态
|
||||
* @title 删除用户行为
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function del() {
|
||||
@@ -111,7 +115,7 @@ class Action extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户行为状态
|
||||
* @title 修改用户行为状态
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function setstatus() {
|
||||
@@ -132,7 +136,7 @@ class Action extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 行为日志列表
|
||||
* @title 行为日志列表
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function log() {
|
||||
@@ -153,7 +157,7 @@ class Action extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 查看行为日志
|
||||
* @title 查看行为日志
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function detail($id = 0) {
|
||||
@@ -176,8 +180,9 @@ class Action extends Admin {
|
||||
$this->setMeta('查看行为日志');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除日志
|
||||
* @title 删除日志
|
||||
* @param mixed $id
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
@@ -195,8 +200,9 @@ class Action extends Admin {
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空日志
|
||||
* @title 清空日志
|
||||
*/
|
||||
public function clear($id = '') {
|
||||
$res = db('ActionLog')->where('1=1')->delete();
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 广告管理
|
||||
* @description 广告管理
|
||||
*/
|
||||
class Ad extends Admin {
|
||||
|
||||
protected $ad;
|
||||
@@ -20,8 +24,9 @@ class Ad extends Admin {
|
||||
$this->ad = db('Ad');
|
||||
$this->adplace = db('AdPlace');
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件列表
|
||||
* @title 广告位管理
|
||||
*/
|
||||
public function index() {
|
||||
$map = array();
|
||||
@@ -40,7 +45,7 @@ class Ad extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告位添加
|
||||
* @title 广告位添加
|
||||
*/
|
||||
public function add() {
|
||||
$place = model('AdPlace');
|
||||
@@ -61,6 +66,9 @@ class Ad extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 广告位编辑
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
$place = model('AdPlace');
|
||||
if ($this->request->isPost()) {
|
||||
@@ -85,6 +93,9 @@ class Ad extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 广告位删除
|
||||
*/
|
||||
public function del() {
|
||||
$id = $this->getArrayParam('id');
|
||||
|
||||
@@ -100,6 +111,9 @@ class Ad extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 广告列表
|
||||
*/
|
||||
public function lists($id = null) {
|
||||
$map['place_id'] = $id;
|
||||
$order = "id desc";
|
||||
@@ -117,6 +131,9 @@ class Ad extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加广告
|
||||
*/
|
||||
public function addad($id) {
|
||||
$ad = model('ad');
|
||||
if ($this->request->isPost()) {
|
||||
@@ -138,6 +155,9 @@ class Ad extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑广告
|
||||
*/
|
||||
public function editad($id = null) {
|
||||
$ad = model('ad');
|
||||
if ($this->request->isPost()) {
|
||||
@@ -162,6 +182,9 @@ class Ad extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除广告
|
||||
*/
|
||||
public function delad() {
|
||||
$id = $this->getArrayParam('id');
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 插件管理
|
||||
* @description 插件管理
|
||||
*/
|
||||
class Addons extends Admin {
|
||||
|
||||
protected $addons;
|
||||
@@ -22,7 +26,7 @@ class Addons extends Admin {
|
||||
$this->hooks = db('Hooks');
|
||||
}
|
||||
/**
|
||||
* 插件列表
|
||||
* @title 插件列表
|
||||
*/
|
||||
public function index($refresh = 0) {
|
||||
if ($refresh) {
|
||||
@@ -43,7 +47,9 @@ class Addons extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
//创建向导首页
|
||||
/**
|
||||
* @title 添加插件
|
||||
*/
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->addons->create();
|
||||
@@ -72,12 +78,8 @@ class Addons extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
//预览
|
||||
public function preview($output = true) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装插件
|
||||
* @title 安装插件
|
||||
*/
|
||||
public function install() {
|
||||
$addon_name = input('addon_name', '', 'trim,ucfirst');
|
||||
@@ -107,7 +109,7 @@ class Addons extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载插件
|
||||
* @title 卸载插件
|
||||
*/
|
||||
public function uninstall($id) {
|
||||
$result = $this->addons->uninstall($id);
|
||||
@@ -119,7 +121,7 @@ class Addons extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用插件
|
||||
* @title 启用插件
|
||||
*/
|
||||
public function enable() {
|
||||
$id = input('id');
|
||||
@@ -134,7 +136,7 @@ class Addons extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用插件
|
||||
* @title 禁用插件
|
||||
*/
|
||||
public function disable() {
|
||||
$id = input('id');
|
||||
@@ -149,7 +151,7 @@ class Addons extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置插件页面
|
||||
* @title 设置插件页面
|
||||
*/
|
||||
public function config() {
|
||||
if ($this->request->isPost()) {
|
||||
@@ -177,6 +179,7 @@ class Addons extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 检测插件
|
||||
* 获取插件所需的钩子是否存在,没有则新增
|
||||
* @param string $str 钩子名称
|
||||
* @param string $addons 插件名称
|
||||
@@ -199,7 +202,7 @@ class Addons extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除钩子
|
||||
* @title 删除钩子
|
||||
* @param string $hook 钩子名称
|
||||
*/
|
||||
public function deleteHook($hook) {
|
||||
@@ -212,7 +215,7 @@ class Addons extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 钩子列表
|
||||
* @title 钩子列表
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
@@ -234,6 +237,9 @@ class Addons extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加钩子
|
||||
*/
|
||||
public function addhook() {
|
||||
$hooks = model('Hooks');
|
||||
if ($this->request->isPost()) {
|
||||
@@ -254,7 +260,9 @@ class Addons extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
//钩子出编辑挂载插件页面
|
||||
/**
|
||||
* @title 编辑钩子
|
||||
*/
|
||||
public function edithook($id) {
|
||||
$hooks = model('Hooks');
|
||||
if ($this->request->isPost()) {
|
||||
@@ -277,7 +285,9 @@ class Addons extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
//超级管理员删除钩子
|
||||
/**
|
||||
* @title 删除钩子
|
||||
*/
|
||||
public function delhook() {
|
||||
$id = $this->getArrayParam('id');
|
||||
$map['id'] = array('IN', $id);
|
||||
@@ -289,6 +299,9 @@ class Addons extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 更新钩子
|
||||
*/
|
||||
public function updateHook() {
|
||||
$hookModel = D('Hooks');
|
||||
$data = $hookModel->create();
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 字段管理
|
||||
* @description 字段管理
|
||||
*/
|
||||
class Attribute extends Admin {
|
||||
|
||||
//保存的Model句柄
|
||||
@@ -42,7 +46,7 @@ class Attribute extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* index方法
|
||||
* @title 字段列表
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function index($model_id = null) {
|
||||
@@ -64,7 +68,7 @@ class Attribute extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建字段
|
||||
* @title 创建字段
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function add($model_id = '') {
|
||||
@@ -87,7 +91,7 @@ class Attribute extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑字段方法
|
||||
* @title 编辑字段
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function edit($id = '', $model_id = '') {
|
||||
@@ -111,7 +115,7 @@ class Attribute extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字段信息
|
||||
* @title 删除字段
|
||||
* @var delattr 是否删除字段表里的字段
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 分类管理
|
||||
* @description 分类管理
|
||||
*/
|
||||
class Category extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
@@ -17,6 +21,9 @@ class Category extends Admin {
|
||||
$this->getContentMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 分类列表
|
||||
*/
|
||||
public function index($model_id = '') {
|
||||
$map = array('status' => array('gt', -1));
|
||||
if ($model_id) {
|
||||
@@ -38,14 +45,18 @@ class Category extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/* 单字段编辑 */
|
||||
/**
|
||||
* @title 编辑字段
|
||||
*/
|
||||
public function editable($name = null, $value = null, $pk = null) {
|
||||
if ($name && ($value != null || $value != '') && $pk) {
|
||||
db('Category')->where(array('id' => $pk))->setField($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/* 编辑分类 */
|
||||
/**
|
||||
* @title 编辑分类
|
||||
*/
|
||||
public function edit($id = null, $pid = 0) {
|
||||
if ($this->request->isPost()) {
|
||||
$category = model('Category');
|
||||
@@ -81,7 +92,10 @@ class Category extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/* 新增分类 */
|
||||
|
||||
/**
|
||||
* @title 添加分类
|
||||
*/
|
||||
public function add($pid = 0) {
|
||||
$Category = model('Category');
|
||||
|
||||
@@ -116,7 +130,7 @@ class Category extends Admin {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除一个分类
|
||||
* @title 删除分类
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function remove($id) {
|
||||
@@ -181,8 +195,9 @@ class Category extends Admin {
|
||||
$this->setMeta($operate . '分类');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动分类
|
||||
* @title 移动分类
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function move() {
|
||||
@@ -195,8 +210,9 @@ class Category extends Admin {
|
||||
return $this->error('分类移动失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并分类
|
||||
* @title 合并分类
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function merge() {
|
||||
@@ -232,6 +248,10 @@ class Category extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 修改状态
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function status() {
|
||||
$id = $this->getArrayParam('id');
|
||||
$status = input('status', '0', 'trim,intval');
|
||||
@@ -248,42 +268,46 @@ class Category extends Admin {
|
||||
return $this->error("设置失败!");
|
||||
}
|
||||
}
|
||||
|
||||
public function add_channel() {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->param();
|
||||
if ($data) {
|
||||
$id = $Channel->save($data);
|
||||
if ($id) {
|
||||
$map['id'] = array('IN', $data['mid']);
|
||||
$result = db('Category')->where($map)->setField('ismenu',$Channel->id);
|
||||
return $this->success('生成成功',url('index'));
|
||||
//记录行为
|
||||
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
|
||||
} else {
|
||||
return $this->error('生成失败');
|
||||
}
|
||||
} else {
|
||||
$this->error($Channel->getError());
|
||||
}
|
||||
} else {
|
||||
$data = $this->request->param();
|
||||
$modelname = db('Model')->where( array('id' => $data['model_id']) )->field('id,name')->find();
|
||||
$data['url'] = $modelname['name'].'/list/'.$data['mid'];
|
||||
$pid = input('pid', 0);
|
||||
//获取父导航
|
||||
if (!empty($pid)) {
|
||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||
$this->assign('parent', $parent);
|
||||
}
|
||||
$pnav = db('Channel')->where(array('pid' => '0'))->select();
|
||||
$this->assign('pnav', $pnav);
|
||||
$this->assign('pid', $pid);
|
||||
$this->assign('info', $data);
|
||||
$this->assign('data',null );
|
||||
$this->setMeta('生成导航');
|
||||
return $this->fetch('edit_channel');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 生成频道
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function add_channel() {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->param();
|
||||
if ($data) {
|
||||
$id = $Channel->save($data);
|
||||
if ($id) {
|
||||
$map['id'] = array('IN', $data['mid']);
|
||||
$result = db('Category')->where($map)->setField('ismenu',$Channel->id);
|
||||
return $this->success('生成成功',url('index'));
|
||||
//记录行为
|
||||
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
|
||||
} else {
|
||||
return $this->error('生成失败');
|
||||
}
|
||||
} else {
|
||||
$this->error($Channel->getError());
|
||||
}
|
||||
} else {
|
||||
$data = $this->request->param();
|
||||
$modelname = db('Model')->where( array('id' => $data['model_id']) )->field('id,name')->find();
|
||||
$data['url'] = $modelname['name'].'/list/'.$data['mid'];
|
||||
$pid = input('pid', 0);
|
||||
//获取父导航
|
||||
if (!empty($pid)) {
|
||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||
$this->assign('parent', $parent);
|
||||
}
|
||||
$pnav = db('Channel')->where(array('pid' => '0'))->select();
|
||||
$this->assign('pnav', $pnav);
|
||||
$this->assign('pid', $pid);
|
||||
$this->assign('info', $data);
|
||||
$this->assign('data',null );
|
||||
$this->setMeta('生成导航');
|
||||
return $this->fetch('edit_channel');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,19 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 频道管理
|
||||
* @description 频道管理
|
||||
*/
|
||||
class Channel extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 频道列表
|
||||
*/
|
||||
public function index($type = 0) {
|
||||
/* 获取频道列表 */
|
||||
//$map = array('status' => array('gt', -1), 'pid'=>$pid);
|
||||
@@ -41,7 +48,9 @@ class Channel extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/* 单字段编辑 */
|
||||
/**
|
||||
* @title 单字段编辑
|
||||
*/
|
||||
public function editable($name = null, $value = null, $pk = null) {
|
||||
if ($name && ($value != null || $value != '') && $pk) {
|
||||
model('Channel')->where(array('id' => $pk))->setField($name, $value);
|
||||
@@ -49,7 +58,7 @@ class Channel extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加频道
|
||||
* @title 添加频道
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function add() {
|
||||
@@ -85,7 +94,7 @@ class Channel extends Admin {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑频道
|
||||
* @title 编辑频道
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function edit($id = 0) {
|
||||
@@ -128,7 +137,7 @@ class Channel extends Admin {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除频道
|
||||
* @title 删除频道
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function del() {
|
||||
@@ -151,7 +160,7 @@ class Channel extends Admin {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 导航排序
|
||||
* @title 导航排序
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function sort() {
|
||||
@@ -188,6 +197,9 @@ class Channel extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 设置状态
|
||||
*/
|
||||
public function setStatus() {
|
||||
$id = array_unique((array) input('ids', 0));
|
||||
$status = input('status', '0', 'trim');
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 客户端管理
|
||||
*/
|
||||
class Client extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
@@ -17,7 +20,9 @@ class Client extends Admin {
|
||||
$this->model = model('Client');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 客户端列表
|
||||
*/
|
||||
public function index(){
|
||||
$list = $this->model->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
@@ -31,6 +36,9 @@ class Client extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加客户端
|
||||
*/
|
||||
public function add(\think\Request $request){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
@@ -52,6 +60,9 @@ class Client extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑客户端
|
||||
*/
|
||||
public function edit(\think\Request $request){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
@@ -72,6 +83,9 @@ class Client extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除客户端
|
||||
*/
|
||||
public function del(\think\Request $request){
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 配置管理
|
||||
*/
|
||||
class Config extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
@@ -18,7 +21,7 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置管理
|
||||
* @title 配置管理
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function index() {
|
||||
@@ -53,6 +56,9 @@ class Config extends Admin {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 信息配置
|
||||
*/
|
||||
public function group($id = 1) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = $this->request->post('config/a');
|
||||
@@ -76,7 +82,7 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配置
|
||||
* @title 新增配置
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function add() {
|
||||
@@ -104,7 +110,7 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑配置
|
||||
* @title 编辑配置
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function edit($id = 0) {
|
||||
@@ -138,7 +144,7 @@ class Config extends Admin {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 批量保存配置
|
||||
* @title 批量保存配置
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function save($config) {
|
||||
@@ -152,8 +158,9 @@ class Config extends Admin {
|
||||
cache('db_config_data', null);
|
||||
return $this->success('保存成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配置
|
||||
* @title 删除配置
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function del() {
|
||||
@@ -175,7 +182,7 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置排序
|
||||
* @title 配置排序
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function sort() {
|
||||
@@ -209,7 +216,9 @@ class Config extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 主题选择
|
||||
*/
|
||||
public function themes() {
|
||||
$list = $this->model->getThemesList();
|
||||
$pc = config('pc_themes');
|
||||
@@ -226,7 +235,7 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置主题
|
||||
* @title 设置主题
|
||||
* @return json
|
||||
*/
|
||||
public function setthemes($name, $id){
|
||||
|
||||
@@ -130,8 +130,8 @@ class Group extends Admin {
|
||||
|
||||
//根据菜单更新节点
|
||||
public function upnode($type) {
|
||||
$rule = model('Menu')->getAuthNodes($type);
|
||||
$reuslt = $this->rule->uprule($rule, $type);
|
||||
//$rule = model('Menu')->getAuthNodes($type);
|
||||
$reuslt = $this->rule->uprule($type);
|
||||
return $this->success("更新成功!");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,29 @@ namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 首页
|
||||
* @description 后台首页
|
||||
*/
|
||||
class Index extends Admin {
|
||||
|
||||
/**
|
||||
* @title 后台首页
|
||||
* @return html
|
||||
*/
|
||||
public function index() {
|
||||
$methods = model('AuthRule')->updaterule('admin');
|
||||
dump($methods);
|
||||
exit();
|
||||
|
||||
$this->setMeta('后台首页');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 用户登录
|
||||
* @return html
|
||||
*/
|
||||
public function login($username = '', $password = '', $verify = '') {
|
||||
if ($this->request->isPost()) {
|
||||
if (!$username || !$password) {
|
||||
@@ -49,10 +65,10 @@ class Index extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* title : 后台退出
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @title 后台退出
|
||||
* @return html
|
||||
*/
|
||||
public function logout() {
|
||||
$user = model('Member');
|
||||
$user->logout();
|
||||
@@ -60,10 +76,10 @@ class Index extends Admin {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* title : 清除缓存
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @title 清除缓存
|
||||
* @return html
|
||||
*/
|
||||
public function clear() {
|
||||
if ($this->request->isPost()) {
|
||||
$clear = input('post.clear/a', array());
|
||||
|
||||
@@ -30,22 +30,67 @@ class AuthRule extends Base{
|
||||
array('name'=>'condition','title'=>'条件','type'=>'text','help'=>'')
|
||||
);
|
||||
|
||||
public function uprule($data, $type){
|
||||
public $filter_method = array('__construct', 'execute', 'sqlSplit', 'isMobile', 'is_wechat', '_initialize');
|
||||
|
||||
public function uprule($type){
|
||||
$data = $this->updaterule($type);
|
||||
foreach ($data as $value) {
|
||||
$id = $this->where(array('name' => $value['url']))->value('id');
|
||||
$save = array(
|
||||
'module' => $type,
|
||||
'type' => 2,
|
||||
'name' => $value['url'],
|
||||
'title' => $value['title'],
|
||||
'group' => $value['group'],
|
||||
'status' => 1,
|
||||
);
|
||||
$id = $this->where(array('name' => $value['name']))->value('id');
|
||||
if ($id) {
|
||||
$save['id'] = $id;
|
||||
}
|
||||
$list[] = $save;
|
||||
$list[] = $value;
|
||||
}
|
||||
return $this->saveAll($list);
|
||||
}
|
||||
|
||||
public function updaterule($type){
|
||||
$path = APP_PATH . $type . '/controller';
|
||||
$classname = $this->scanFile($path);
|
||||
foreach ($classname as $value) {
|
||||
$class = "\\app\\" . $type . "\\controller\\" . $value;
|
||||
if(class_exists($class)){
|
||||
$reflection = new \ReflectionClass($class);
|
||||
$group_doc = $this->Parser($reflection->getDocComment());
|
||||
$method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
|
||||
foreach ($method as $key => $v) {
|
||||
if (!in_array($v->name, $this->filter_method)) {
|
||||
$title_doc = $this->Parser($v->getDocComment());
|
||||
if (isset($title_doc['title']) && $title_doc['title']) {
|
||||
$list[] = array(
|
||||
'module' => $type,
|
||||
'type' => 2,
|
||||
'name' => $type . '/' . strtolower($value) . '/' . strtolower($v->name),
|
||||
'title' => trim($title_doc['title']),
|
||||
'group' => (isset($group_doc['title']) && $group_doc['title']) ? trim($group_doc['title']) : '',
|
||||
'status' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function scanFile($path){
|
||||
$result = array();
|
||||
$files = scandir($path);
|
||||
foreach ($files as $file) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (is_dir($path . '/' . $file)) {
|
||||
$this->scanFile($path . '/' . $file);
|
||||
} else {
|
||||
$result[] = substr(basename($file), 0 , -4);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function Parser($text){
|
||||
$doc = new \Doc\Doc();
|
||||
return $doc->parse($text);
|
||||
}
|
||||
}
|
||||
135
extend/doc/Doc.php
Normal file
135
extend/doc/Doc.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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 doc;
|
||||
|
||||
Class Doc{
|
||||
|
||||
private $params = array ();
|
||||
/**
|
||||
* 解析注释
|
||||
* @param string $doc
|
||||
* @return array
|
||||
*/
|
||||
public function parse($doc = '') {
|
||||
if ($doc == '' || !$doc) {
|
||||
return $this->params;
|
||||
}
|
||||
// Get the comment
|
||||
if (preg_match ( '#^/\*\*(.*)\*/#s', $doc, $comment ) === false)
|
||||
return $this->params;
|
||||
$comment = trim ( $comment [1] );
|
||||
// Get all the lines and strip the * from the first character
|
||||
if (preg_match_all ( '#^\s*\*(.*)#m', $comment, $lines ) === false)
|
||||
return $this->params;
|
||||
$this->parseLines ( $lines [1] );
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
private function parseLines($lines) {
|
||||
$desc = [];
|
||||
foreach ( $lines as $line ) {
|
||||
$parsedLine = $this->parseLine ( $line ); // Parse the line
|
||||
if ($parsedLine === false && ! isset ( $this->params ['description'] )) {
|
||||
if (isset ( $desc )) {
|
||||
// Store the first line in the short description
|
||||
$this->params ['description'] = implode ( PHP_EOL, $desc );
|
||||
}
|
||||
$desc = array ();
|
||||
} elseif ($parsedLine !== false) {
|
||||
$desc [] = $parsedLine; // Store the line in the long description
|
||||
}
|
||||
}
|
||||
$desc = implode ( ' ', $desc );
|
||||
if (! empty ( $desc ))
|
||||
$this->params ['long_description'] = $desc;
|
||||
}
|
||||
|
||||
private function parseLine($line) {
|
||||
// trim the whitespace from the line
|
||||
$line = trim ( $line );
|
||||
if (empty ( $line ))
|
||||
return false; // Empty line
|
||||
if (strpos ( $line, '@' ) === 0) {
|
||||
if (strpos ( $line, ' ' ) > 0) {
|
||||
// Get the parameter name
|
||||
$param = substr ( $line, 1, strpos ( $line, ' ' ) - 1 );
|
||||
$value = substr ( $line, strlen ( $param ) + 2 ); // Get the value
|
||||
} else {
|
||||
$param = substr ( $line, 1 );
|
||||
$value = '';
|
||||
}
|
||||
// Parse the line and return false if the parameter is valid
|
||||
if ($this->setParam ( $param, $value ))
|
||||
return false;
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
private function setParam($param, $value) {
|
||||
if ($param == 'param' || $param == 'header')
|
||||
$value = $this->formatParam( $value );
|
||||
if ($param == 'class')
|
||||
list ( $param, $value ) = $this->formatClass ( $value );
|
||||
if($param == 'return' || $param == 'param' || $param == 'header'){
|
||||
$this->params [$param][] = $value;
|
||||
}else if (empty ( $this->params [$param] )) {
|
||||
$this->params [$param] = $value;
|
||||
} else {
|
||||
$this->params [$param] = $this->params [$param] . $value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function formatClass($value) {
|
||||
$r = preg_split ( "[\(|\)]", $value );
|
||||
if (is_array ( $r )) {
|
||||
$param = $r [0];
|
||||
parse_str ( $r [1], $value );
|
||||
foreach ( $value as $key => $val ) {
|
||||
$val = explode ( ',', $val );
|
||||
if (count ( $val ) > 1)
|
||||
$value [$key] = $val;
|
||||
}
|
||||
} else {
|
||||
$param = 'Unknown';
|
||||
}
|
||||
return array (
|
||||
$param,
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
private function formatParam($string) {
|
||||
$string = $string." ";
|
||||
if(preg_match_all('/(\w+):(.*?)[\s\n]/s', $string, $meatchs)){
|
||||
$param = [];
|
||||
foreach ($meatchs[1] as $key=>$value){
|
||||
$param[$meatchs[1][$key]] = $this->getParamType($meatchs[2][$key]);
|
||||
}
|
||||
return $param;
|
||||
}else{
|
||||
return ''.$string;
|
||||
}
|
||||
}
|
||||
private function getParamType($type){
|
||||
$typeMaps = [
|
||||
'string' => '字符串',
|
||||
'int' => '整型',
|
||||
'float' => '浮点型',
|
||||
'boolean' => '布尔型',
|
||||
'date' => '日期',
|
||||
'array' => '数组',
|
||||
'fixed' => '固定值',
|
||||
'enum' => '枚举类型',
|
||||
'object' => '对象',
|
||||
];
|
||||
return array_key_exists($type,$typeMaps) ? $typeMaps[$type] : $type;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user