This commit is contained in:
2020-02-17 22:34:34 +08:00
parent 58d999ed73
commit 259d232d89
109 changed files with 10344 additions and 89 deletions
+68 -70
View File
@@ -10,85 +10,83 @@ use think\Validate;
/** /**
* 控制器基础类 * 控制器基础类
*/ */
abstract class BaseController abstract class BaseController {
{ /**
/** * Request实例
* Request实例 * @var \think\Request
* @var \think\Request */
*/ protected $request;
protected $request;
/** /**
* 应用实例 * 应用实例
* @var \think\App * @var \think\App
*/ */
protected $app; protected $app;
/** /**
* 是否批量验证 * 是否批量验证
* @var bool * @var bool
*/ */
protected $batchValidate = false; protected $batchValidate = false;
/** /**
* 控制器中间件 * 控制器中间件
* @var array * @var array
*/ */
protected $middleware = []; protected $middleware = [];
/** /**
* 构造方法 * 构造方法
* @access public * @access public
* @param App $app 应用对象 * @param App $app 应用对象
*/ */
public function __construct(App $app) public function __construct(App $app) {
{ $this->app = $app;
$this->app = $app; $this->request = $this->app->request;
$this->request = $this->app->request;
// 控制器初始化 // 控制器初始化
$this->initialize(); $this->initialize();
} }
// 初始化 // 初始化
protected function initialize() protected function initialize() {
{}
/** }
* 验证数据
* @access protected
* @param array $data 数据
* @param string|array $validate 验证器名或者验证规则数组
* @param array $message 提示信息
* @param bool $batch 是否批量验证
* @return array|string|true
* @throws ValidateException
*/
protected function validate(array $data, $validate, array $message = [], bool $batch = false)
{
if (is_array($validate)) {
$v = new Validate();
$v->rule($validate);
} else {
if (strpos($validate, '.')) {
// 支持场景
[$validate, $scene] = explode('.', $validate);
}
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
$v = new $class();
if (!empty($scene)) {
$v->scene($scene);
}
}
$v->message($message); /**
* 验证数据
* @access protected
* @param array $data 数据
* @param string|array $validate 验证器名或者验证规则数组
* @param array $message 提示信息
* @param bool $batch 是否批量验证
* @return array|string|true
* @throws ValidateException
*/
protected function validate(array $data, $validate, array $message = [], bool $batch = false) {
if (is_array($validate)) {
$v = new Validate();
$v->rule($validate);
} else {
if (strpos($validate, '.')) {
// 支持场景
[$validate, $scene] = explode('.', $validate);
}
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
$v = new $class();
if (!empty($scene)) {
$v->scene($scene);
}
}
// 是否批量验证 $v->message($message);
if ($batch || $this->batchValidate) {
$v->batch(true);
}
return $v->failException(true)->check($data); // 是否批量验证
} if ($batch || $this->batchValidate) {
$v->batch(true);
}
return $v->failException(true)->check($data);
}
} }
+42
View File
@@ -8,9 +8,51 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// 应用公共文件 // 应用公共文件
define("SENTCMS_VERSION", '4.0.20200217');
/** /**
* *
*/ */
function is_login() { function is_login() {
return false; return false;
}
/**
* 获取客户端IP地址
* @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字
* @param boolean $adv 是否进行高级模式获取(有可能被伪装)
* @return mixed
*/
function get_client_ip($type = 0, $adv = false) {
$type = $type ? 1 : 0;
static $ip = NULL;
if ($ip !== NULL) {
return $ip[$type];
}
if ($adv) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$pos = array_search('unknown', $arr);
if (false !== $pos) {
unset($arr[$pos]);
}
$ip = trim($arr[0]);
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
}
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
}
// IP地址合法验证
$long = sprintf("%u", ip2long($ip));
$ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
return $ip[$type];
}
function avatar($uid, $size = 'middle') {
return request()->root(true) . '/static/common/images/default_avatar_' . $size . '.jpg';
} }
+6 -8
View File
@@ -8,8 +8,6 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller; namespace app\controller;
use think\facade\Db;
/** /**
* @title 后端公共模块 * @title 后端公共模块
*/ */
@@ -26,14 +24,14 @@ class Admin extends Base {
], ],
]; ];
protected $middleware = [ // protected $middleware = [
'\app\http\middleware\Validate', // '\app\http\middleware\Validate',
'\app\http\middleware\Admin', // '\app\http\middleware\Admin',
]; // ];
protected function initialize() { protected function initialize() {
Db::name('config')->select(); $url = str_replace(".", "/", strtolower($this->request->controller())) . '/' . $this->request->action();
if (!is_login() and !in_array($this->request->url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) { if (!is_login() and !in_array($url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
$this->redirect('admin/index/login'); $this->redirect('admin/index/login');
} }
} }
+79 -3
View File
@@ -8,13 +8,37 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller; namespace app\controller;
use app\BaseController; use think\App;
use think\exception\ValidateException;
use think\facade\View; use think\facade\View;
use think\Validate;
class Base extends BaseController { class Base {
use \liliuwei\think\Jump; use \liliuwei\think\Jump;
/**
* Request实例
* @var \think\Request
*/
protected $request;
/**
* 应用实例
* @var \think\App
*/
protected $app;
/**
* 是否批量验证
* @var bool
*/
protected $batchValidate = false;
/**
* 控制器中间件
* @var array
*/
protected $middleware = [];
// 使用内置PHP模板引擎渲染模板输出 // 使用内置PHP模板引擎渲染模板输出
protected $tpl_config = [ protected $tpl_config = [
'view_dir_name' => 'public' . DIRECTORY_SEPARATOR . 'template', 'view_dir_name' => 'public' . DIRECTORY_SEPARATOR . 'template',
@@ -29,9 +53,61 @@ class Base extends BaseController {
public $data = []; //渲染数据 public $data = []; //渲染数据
/**
* 构造方法
* @access public
* @param App $app 应用对象
*/
public function __construct(App $app) {
$this->app = $app;
$this->request = $this->app->request;
// 控制器初始化
$this->initialize();
}
// 初始化
protected function initialize() {}
/**
* 验证数据
* @access protected
* @param array $data 数据
* @param string|array $validate 验证器名或者验证规则数组
* @param array $message 提示信息
* @param bool $batch 是否批量验证
* @return array|string|true
* @throws ValidateException
*/
protected function validate(array $data, $validate, array $message = [], bool $batch = false) {
if (is_array($validate)) {
$v = new Validate();
$v->rule($validate);
} else {
if (strpos($validate, '.')) {
// 支持场景
list($validate, $scene) = explode('.', $validate);
}
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
$v = new $class();
if (!empty($scene)) {
$v->scene($scene);
}
}
$v->message($message);
// 是否批量验证
if ($batch || $this->batchValidate) {
$v->batch(true);
}
return $v->failException(true)->check($data);
}
protected function fetch($template = '') { protected function fetch($template = '') {
View::config($this->tpl_config); View::config($this->tpl_config);
View::assign($this->data); View::assign($this->data);
View::fetch($template); return View::fetch($template);
} }
} }
+217
View File
@@ -0,0 +1,217 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 行为管理
* @description 行为管理
*/
class Action extends Admin {
/**
* @title 用户行为列表
* @author huajie <banhuajie@163.com>
*/
public function index() {
$map = array('status' => array('gt', -1));
$order = "id desc";
//获取列表数据
$list = model('Action')->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param()
));
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta('用户行为');
return $this->fetch();
}
/**
* @title 新建用户行为
* @author colin <colin@tensent.cn>
*/
public function add() {
$model = model('Action');
if ($this->request->isPost()) {
$data = input('post.');
$result = $model->save($data);
if (false != $result) {
action_log('add_action', 'Action', $result, session('user_auth.uid'));
return $this->success('添加成功!', url('index'));
} else {
return $this->error($model->getError());
}
} else {
$data = array(
'keyList' => $model->fieldlist,
);
$this->assign($data);
$this->setMeta("添加行为");
return $this->fetch('public/edit');
}
}
/**
* @title 编辑用户行为
* @author colin <colin@tensent.cn>
*/
public function edit($id = null) {
$model = model('Action');
if ($this->request->isPost()) {
$data = input('post.');
$result = $model->save($data, array('id' => $data['id']));
if ($result !== false) {
action_log('edit_action', 'Action', $id, session('user_auth.uid'));
return $this->success('编辑成功!', url('index'));
} else {
return $this->error($model->getError());
}
} else {
$info = $model::where(array('id' => $id))->find();
if (!$info) {
return $this->error("非法操作!");
}
$data = array(
'info' => $info,
'keyList' => $model->fieldlist,
);
$this->assign($data);
$this->setMeta("编辑行为");
return $this->fetch('public/edit');
}
}
/**
* @title 删除用户行为
* @author colin <colin@tensent.cn>
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!", '');
}
$map['id'] = array('IN', $id);
$result = db('Action')->where($map)->delete();
if ($result) {
action_log('delete_action', 'Action', $id, session('user_auth.uid'));
return $this->success('删除成功!');
} else {
return $this->error('删除失败!');
}
}
/**
* @title 修改用户行为状态
* @author colin <colin@tensent.cn>
*/
public function setstatus() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!", '');
}
$status = input('get.status', '', 'trim,intval');
$message = !$status ? '禁用' : '启用';
$map['id'] = array('IN', $id);
$result = db('Action')->where($map)->setField('status', $status);
if ($result !== false) {
action_log('setstatus_action', 'Action', $id, session('user_auth.uid'));
return $this->success('设置' . $message . '状态成功!');
} else {
return $this->error('设置' . $message . '状态失败!');
}
}
/**
* @title 行为日志列表
* @author huajie <banhuajie@163.com>
*/
public function log() {
//获取列表数据
$map['status'] = array('gt', -1);
$order = "id desc";
//获取列表数据
$list = model('ActionLog')->where($map)->order($order)->paginate(10);
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta('行为日志');
return $this->fetch();
}
/**
* @title 查看行为日志
* @author huajie <banhuajie@163.com>
*/
public function detail($id = 0) {
$model = model('ActionLog');
if (empty($id)) {
return $this->error('参数错误!');
}
$info = $model::get($id);
$info['title'] = get_action($info['action_id'], 'title');
$info['user_id'] = get_username($info['user_id']);
$info['action_ip'] = long2ip($info['action_ip']);
$info['create_time'] = date('Y-m-d H:i:s', $info['create_time']);
$data = array(
'info' => $info,
'keyList' => $model->keyList,
);
$this->assign($data);
$this->setMeta('查看行为日志');
return $this->fetch();
}
/**
* @title 删除日志
* @param mixed $id
* @author huajie <banhuajie@163.com>
*/
public function dellog() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!", '');
}
$map['id'] = array('IN', $id);
$res = db('ActionLog')->where($map)->delete();
if ($res !== false) {
action_log('delete_actionlog', 'ActionLog', $id, session('user_auth.uid'));
return $this->success('删除成功!');
} else {
return $this->error('删除失败!');
}
}
/**
* @title 清空日志
*/
public function clear($id = '') {
$res = db('ActionLog')->where('1=1')->delete();
if ($res !== false) {
//记录行为
action_log('clear_actionlog', 'ActionLog', $id, session('user_auth.uid'));
return $this->success('日志清空成功!');
} else {
return $this->error('日志清空失败!');
}
}
}
+207
View File
@@ -0,0 +1,207 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 广告管理
* @description 广告管理
*/
class Ad extends Admin {
protected $ad;
protected $adplace;
public function _initialize() {
parent::_initialize();
$this->ad = db('Ad');
$this->adplace = db('AdPlace');
}
/**
* @title 广告位管理
*/
public function index() {
$map = array();
$order = "id desc";
$list = db('AdPlace')->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta("广告管理");
return $this->fetch();
}
/**
* @title 广告位添加
*/
public function add() {
$place = model('AdPlace');
if ($this->request->isPost()) {
$result = $place->change();
if (!empty($_POST['name'])){
$result = $place->change();
if ($result) {
return $this->success("添加成功!");
} else {
return $this->error($place->getError());
}
}else{
return $this->error("标识不能为空!");
}
} else {
$data = array(
'keyList' => $place->keyList,
);
$this->assign($data);
$this->setMeta("添加广告位");
return $this->fetch('public/edit');
}
}
/**
* @title 广告位编辑
*/
public function edit($id = null) {
$place = model('AdPlace');
if ($this->request->isPost()) {
$result = $place->change();
if ($result) {
return $this->success("修改成功!", url('admin/ad/index'));
} else {
return $this->error($this->adplace->getError());
}
} else {
$info = db('AdPlace')->where(array('id' => $id))->find();
if (!$info) {
return $this->error("非法操作!");
}
$data = array(
'info' => $info,
'keyList' => $place->keyList,
);
$this->assign($data);
$this->setMeta("编辑广告位");
return $this->fetch('public/edit');
}
}
/**
* @title 广告位删除
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!");
}
$map['id'] = array('IN', $id);
$result = $this->adplace->where($map)->delete();
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
/**
* @title 广告列表
*/
public function lists($id = null) {
$map['place_id'] = $id;
$order = "id desc";
$list = db('Ad')->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param()
));
$data = array(
'id' => $id,
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta("广告管理");
return $this->fetch();
}
/**
* @title 添加广告
*/
public function addad($id) {
$ad = model('ad');
if ($this->request->isPost()) {
$result = $ad->change();
if ($result) {
return $this->success("添加成功!", url('admin/ad/lists', array('id' => $this->request->param('place_id'))));
} else {
return $this->error($ad->getError());
}
} else {
$info['place_id'] = $id;
$data = array(
'info' => $info,
'keyList' => $ad->keyList,
);
$this->assign($data);
$this->setMeta("添加广告位");
return $this->fetch('public/edit');
}
}
/**
* @title 编辑广告
*/
public function editad($id = null) {
$ad = model('ad');
if ($this->request->isPost()) {
$result = $ad->change();
if ($result) {
return $this->success("修改成功!", url('admin/ad/lists', array('id' => $this->request->param('place_id'))));
} else {
return $this->error($ad->getError());
}
} else {
$info = db('ad')->where(array('id' => $id))->find();
if (!$info) {
return $this->error("非法操作!");
}
$data = array(
'info' => $info,
'keyList' => $ad->keyList,
);
$this->assign($data);
$this->setMeta("编辑广告位");
return $this->fetch('public/edit');
}
}
/**
* @title 删除广告
*/
public function delad() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!");
}
$map['id'] = array('IN', $id);
$result = db('ad')->where($map)->delete();
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
}
+330
View File
@@ -0,0 +1,330 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 插件管理
* @description 插件管理
*/
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) {
if ($refresh) {
$this->addons->refresh();
}
$list = $this->addons->order('id desc')->paginate(25, false, array(
'query' => $this->request->param()
));
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->setMeta("插件管理");
$this->assign($data);
return $this->fetch();
}
/**
* @title 添加插件
*/
public function add() {
if ($this->request->isPost()) {
$data = $this->addons->create();
if ($data) {
if ($result) {
return $this->success("创建成功!", url('admin/addons/index'));
} else {
return $this->error("创建失败!");
}
} else {
return $this->error($this->addons->getError());
}
} else {
$hooks = db('Hooks')->field('name,description')->select();
$this->assign('Hooks', $hooks);
$hook = db('Hooks')->field(true)->select();
foreach ($hook as $key => $value) {
$addons_opt[$value['name']] = $value['name'];
}
$addons_opt = array(array('type' => 'select', 'opt' => $addons_opt));
if (!is_writable(SENT_ADDON_PATH)) {
return $this->error('您没有创建目录写入权限,无法使用此功能');
}
$this->setMeta("添加插件");
return $this->fetch();
}
}
/**
* @title 安装插件
*/
public function install() {
$addon_name = input('addon_name', '', 'trim,ucfirst');
$class = get_addon_class($addon_name);
if (class_exists($class)) {
$addons = new $class;
$info = $addons->info;
if (!$info || !$addons->checkInfo()) {
//检测信息的正确性
return $this->error('插件信息缺失');
}
session('addons_install_error', null);
$install_flag = $addons->install();
if (!$install_flag) {
return $this->error('执行插件预安装操作失败' . session('addons_install_error'));
}
$result = $this->addons->install($info);
if ($result) {
cache('hooks', null);
return $this->success('安装成功');
} else {
return $this->error($this->addons->getError());
}
} else {
return $this->error('插件不存在');
}
}
/**
* @title 卸载插件
*/
public function uninstall($id) {
$result = $this->addons->uninstall($id);
if ($result === false) {
return $this->error($this->addons->getError(), '');
} else {
return $this->success('卸载成功!');
}
}
/**
* @title 启用插件
*/
public function enable() {
$id = input('id');
cache('hooks', null);
$model = model('Addons');
$result = $model::where(array('id' => $id))->update(array('status' => 1));
if ($result) {
return $this->success('启用成功');
} else {
return $this->error("启用失败!");
}
}
/**
* @title 禁用插件
*/
public function disable() {
$id = input('id');
cache('hooks', null);
$model = model('Addons');
$result = $model::where(array('id' => $id))->update(array('status' => 0));
if ($result) {
return $this->success('禁用成功');
} else {
return $this->error("禁用失败!");
}
}
/**
* @title 设置插件页面
*/
public function config() {
if ($this->request->isPost()) {
# code...
} else {
$id = input('id', '', 'trim,intval');
if (!$id) {
return $this->error("非法操作!");
}
$info = $this->addons->find($id);
if (!empty($info)) {
$class = get_addon_class($info['name']);
$keyList = array();
$data = array(
'keyList' => $keyList,
);
$this->assign($data);
$this->setMeta($info['title'] . " - 设置");
return $this->fetch('public/edit');
} else {
return $this->error("未安装此插件!");
}
}
}
/**
* @title 检测插件
* 获取插件所需的钩子是否存在,没有则新增
* @param string $str 钩子名称
* @param string $addons 插件名称
* @param string $addons 插件简介
*/
public function existHook($str, $addons, $msg = '') {
$hook_mod = db('Hooks');
$where['name'] = $str;
$gethook = $hook_mod->where($where)->find();
if (!$gethook || empty($gethook) || !is_array($gethook)) {
$data['name'] = $str;
$data['description'] = $msg;
$data['type'] = 1;
$data['update_time'] = time();
$data['addons'] = $addons;
if (false !== $hook_mod->create($data)) {
$hook_mod->add();
}
}
}
/**
* @title 删除钩子
* @param string $hook 钩子名称
*/
public function deleteHook($hook) {
$model = db('hooks');
$condition = array(
'name' => $hook,
);
$model->where($condition)->delete();
S('hooks', null);
}
/**
* @title 钩子列表
*/
public function hooks() {
$map = array();
$order = "id desc";
$list = model('Hooks')->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param()
));
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->setMeta("钩子管理");
$this->assign($data);
return $this->fetch();
}
/**
* @title 添加钩子
*/
public function addhook() {
$hooks = model('Hooks');
if ($this->request->isPost()) {
$result = $hooks->change();
if ($result !== false) {
return $this->success("修改成功");
} else {
return $this->error($hooks->getError());
}
} else {
$keylist = $hooks->getaddons();
$data = array(
'keyList' => $keylist,
);
$this->assign($data);
$this->setMeta('编辑钩子');
return $this->fetch('public/edit');
}
}
/**
* @title 编辑钩子
*/
public function edithook($id) {
$hooks = model('Hooks');
if ($this->request->isPost()) {
$result = $hooks->change();
if ($result !== false) {
return $this->success("修改成功");
} else {
return $this->error($hooks->getError());
}
} else {
$info = db('Hooks')->find($id);
$keylist = $hooks->getaddons($info['addons']);
$data = array(
'info' => $info,
'keyList' => $keylist,
);
$this->assign($data);
$this->setMeta('编辑钩子');
return $this->fetch('public/edit');
}
}
/**
* @title 删除钩子
*/
public function delhook() {
$id = $this->getArrayParam('id');
$map['id'] = array('IN', $id);
$result = $this->hooks->where($map)->delete();
if ($result !== false) {
return $this->success('删除成功');
} else {
return $this->error('删除失败');
}
}
/**
* @title 更新钩子
*/
public function updateHook() {
$hookModel = D('Hooks');
$data = $hookModel->create();
if ($data) {
if ($data['id']) {
$flag = $hookModel->save($data);
if ($flag !== false) {
S('hooks', null);
$this->success('更新成功', Cookie('__forward__'));
} else {
$this->error('更新失败');
}
} else {
$flag = $hookModel->add($data);
if ($flag) {
S('hooks', null);
$this->success('新增成功', Cookie('__forward__'));
} else {
$this->error('新增失败');
}
}
} else {
$this->error($hookModel->getError());
}
}
}
+165
View File
@@ -0,0 +1,165 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 字段管理
* @description 字段管理
*/
class Attribute extends Admin {
//保存的Model句柄
protected $model;
protected $attr;
//初始化
public function _initialize() {
parent::_initialize();
$this->getContentMenu();
$this->model = model('Attribute');
//遍历属性列表
foreach (get_attribute_type() as $key => $value) {
$this->attr[$key] = $value[0];
}
$this->validate_rule = array(
0 => '请选择',
'regex' => '正则验证',
'function' => '函数验证',
'unique' => '唯一验证',
'length' => '长度验证',
'in' => '验证在范围内',
'notin' => '验证不在范围内',
'between' => '区间验证',
'notbetween' => '不在区间验证',
);
$this->auto_type = array(0 => '请选择', 'function' => '函数', 'field' => '字段', 'string' => '字符串');
$this->the_time = array(0 => '请选择', '3' => '始 终', '1' => '新 增', '2' => '编 辑');
$this->field = $this->getField();
}
/**
* @title 字段列表
* @author colin <colin@tensent.cn>
*/
public function index($model_id = null) {
if (!$model_id) {
return $this->error('非法操作!');
}
$list = model('Attribute')->where('model_id', $model_id)->order('id desc')->paginate(25, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'model_id' => $model_id,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta('字段管理');
return $this->fetch();
}
/**
* @title 创建字段
* @author colin <colin@tensent.cn>
*/
public function add($model_id = '') {
if ($this->request->isPost()) {
$result = $this->model->validate('attribute.add')->save($this->request->param());
if (false !== $result) {
return $this->success("创建成功!", url('Attribute/index', array('model_id' => $model_id)));
} else {
return $this->error($this->model->getError());
}
} else {
$data = array(
'info' => array('model_id' => $model_id),
'fieldGroup' => $this->field,
);
$this->assign($data);
$this->setMeta('添加字段');
return $this->fetch('public/edit');
}
}
/**
* @title 编辑字段
* @author colin <colin@tensent.cn>
*/
public function edit($id = '', $model_id = '') {
if ($this->request->isPost()) {
$result = $this->model->validate('attribute.edit')->save($this->request->param(), array('id'=>$id));
if ($result) {
return $this->success("修改成功!", url('Attribute/index', array('model_id' => $model_id)));
} else {
return $this->error($this->model->getError());
}
} else {
$info = db('Attribute')->find($id);
$data = array(
'info' => $info,
'fieldGroup' => $this->field,
);
$this->assign($data);
$this->setMeta('编辑字段');
return $this->fetch('public/edit');
}
}
/**
* @title 删除字段
* @var delattr 是否删除字段表里的字段
* @author colin <colin@tensent.cn>
*/
public function del(\think\Request $request) {
$id = $request->param('id');
$model_id = $request->param('model_id');
if (!$id) {
return $this->error("非法操作!");
}
$result = $this->model->del($id, $model_id);
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error($this->model->getError());
}
}
//字段编辑所需字段
protected function getField() {
return array(
'基础' => array(
array('name' => 'id', 'title' => 'id', 'help' => '', 'type' => 'hidden'),
array('name' => 'model_id', 'title' => 'model_id', 'help' => '', 'type' => 'hidden'),
array('name' => 'name', 'title' => '字段名', 'help' => '英文字母开头,长度不超过30', 'type' => 'text'),
array('name' => 'title', 'title' => '字段标题', 'help' => '请输入字段标题,用于表单显示', 'type' => 'text'),
array('name' => 'type', 'title' => '字段类型', 'help' => '用于表单中的展示方式', 'type' => 'select', 'option' => $this->attr, 'help' => ''),
array('name' => 'length', 'title' => '字段长度', 'help' => '字段的长度值', 'type' => 'text'),
array('name' => 'extra', 'title' => '参数', 'help' => '布尔、枚举、多选字段类型的定义数据', 'type' => 'textarea'),
array('name' => 'value', 'title' => '默认值', 'help' => '字段的默认值', 'type' => 'text'),
array('name' => 'remark', 'title' => '字段备注', 'help' => '用于表单中的提示', 'type' => 'text'),
array('name' => 'is_show', 'title' => '是否显示', 'help' => '是否显示在表单中', 'type' => 'select', 'option' => array('1' => '始终显示', '2' => '新增显示', '3' => '编辑显示', '0' => '不显示'), 'value' => 1),
array('name' => 'is_must', 'title' => '是否必填', 'help' => '用于自动验证', 'type' => 'select', 'option' => array('0' => '否', '1' => '是')),
),
'高级' => array(
array('name' => 'validate_type', 'title' => '验证方式', 'type' => 'select', 'option' => $this->validate_rule, 'help' => ''),
array('name' => 'validate_rule', 'title' => '验证规则', 'help' => '根据验证方式定义相关验证规则', 'type' => 'text'),
array('name' => 'error_info', 'title' => '出错提示', 'type' => 'text', 'help' => ''),
array('name' => 'validate_time', 'title' => '验证时间', 'help' => '英文字母开头,长度不超过30', 'type' => 'select', 'option' => $this->the_time, 'help' => ''),
array('name' => 'auto_type', 'title' => '自动完成方式', 'help' => '英文字母开头,长度不超过30', 'type' => 'select', 'option' => $this->auto_type, 'help' => ''),
array('name' => 'auto_rule', 'title' => '自动完成规则', 'help' => '根据完成方式订阅相关规则', 'type' => 'text'),
array('name' => 'auto_time', 'title' => '自动完成时间', 'help' => '英文字母开头,长度不超过30', 'type' => 'select', 'option' => $this->the_time),
),
);
}
}
+313
View File
@@ -0,0 +1,313 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 分类管理
* @description 分类管理
*/
class Category extends Admin {
public function _initialize() {
parent::_initialize();
$this->getContentMenu();
}
/**
* @title 分类列表
*/
public function index($model_id = '') {
$map = array('status' => array('gt', -1));
if ($model_id) {
$map['model_id'] = $model_id;
}
$list = db('Category')->where($map)->order('sort asc,id asc')->column('*', 'id');
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
$subsql = db('Attribute')->where('name', 'category_id')->fetchSql(true)->column('model_id');
$model_list = model('Model')->where('id IN ('. $subsql.')')->select();
$this->assign('tree', $list);
$this->assign('model_list', $model_list);
$this->assign('model_id', $model_id);
$this->setMeta('栏目列表');
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');
//提交表单
$result = $category->change();
if (false !== $result) {
//记录行为
action_log('update_category', 'category', $id, session('user_auth.uid'));
return $this->success('编辑成功!', url('index'));
} else {
$error = $category->getError();
return $this->error(empty($error) ? '未知错误!' : $error);
}
} else {
$cate = '';
if ($pid) {
/* 获取上级分类信息 */
$cate = db('Category')->find($pid);
if (!($cate && 1 == $cate['status'])) {
return $this->error('指定的上级分类不存在或被禁用!');
}
}
$subsql = db('Attribute')->where('name', 'category_id')->fetchSql(true)->column('model_id');
$model_list = model('Model')->where('id IN ('. $subsql.')')->select();
/* 获取分类信息 */
$info = $id ? db('Category')->find($id) : '';
$this->assign('info', $info);
$this->assign('model_list', $model_list);
$this->assign('category', $cate);
$this->setMeta('编辑分类');
return $this->fetch();
}
}
/**
* @title 添加分类
*/
public function add($pid = 0) {
$Category = model('Category');
if ($this->request->isPost()) {
//提交表单
$id = $Category->change();
if (false !== $id) {
action_log('update_category', 'category', $id, session('user_auth.uid'));
return $this->success('新增成功!', url('index'));
} else {
$error = $Category->getError();
return $this->error(empty($error) ? '未知错误!' : $error);
}
} else {
$cate = array();
if ($pid) {
/* 获取上级分类信息 */
$cate = $Category->info($pid, 'id,name,title,status');
if (!($cate && 1 == $cate['status'])) {
return $this->error('指定的上级分类不存在或被禁用!');
}
}
$subsql = db('Attribute')->where('name', 'category_id')->fetchSql(true)->column('model_id');
$model_list = model('Model')->where('id IN ('. $subsql.')')->select();
/* 获取分类信息 */
$this->assign('info', null);
$this->assign('model_list', $model_list);
$this->assign('category', $cate);
$this->setMeta('新增分类');
return $this->fetch('edit');
}
}
/**
* @title 删除分类
* @author huajie <banhuajie@163.com>
*/
public function remove($id) {
if (empty($id)) {
return $this->error('参数错误!');
}
//判断该分类下有没有子分类,有则不允许删除
$child = db('Category')->where(array('pid' => $id))->field('id')->select();
if (!empty($child)) {
return $this->error('请先删除该分类下的子分类');
}
//判断该分类下有没有内容
// $document_list = db('Document')->where(array('category_id' => $id))->field('id')->select();
// if (!empty($document_list)) {
// return $this->error('请先删除该分类下的文章(包含回收站)');
// }
//删除该分类信息
$res = db('Category')->where(array('id' => $id))->delete();
if ($res !== false) {
//记录行为
action_log('update_category', 'category', $id, session('user_auth.uid'));
return $this->success('删除分类成功!');
} else {
return $this->error('删除分类失败!');
}
}
/**
* 操作分类初始化
* @param string $type
* @author huajie <banhuajie@163.com>
*/
public function operate($type = 'move', $from = '') {
//检查操作参数
if ($type == 'move') {
$operate = '移动';
} elseif ($type == 'merge') {
$operate = '合并';
} else {
return $this->error('参数错误!');
}
if (empty($from)) {
return $this->error('参数错误!');
}
//获取分类
$map = array('status' => 1, 'id' => array('neq', $from));
$list = db('Category')->where($map)->field('id,pid,title')->select();
//移动分类时增加移至根分类
if ($type == 'move') {
//不允许移动至其子孙分类
$list = tree_to_list(list_to_tree($list));
$pid = db('Category')->getFieldById($from, 'pid');
$pid && array_unshift($list, array('id' => 0, 'title' => '根分类'));
}
$this->assign('type', $type);
$this->assign('operate', $operate);
$this->assign('from', $from);
$this->assign('list', $list);
$this->setMeta($operate . '分类');
return $this->fetch();
}
/**
* @title 移动分类
* @author huajie <banhuajie@163.com>
*/
public function move() {
$to = input('post.to');
$from = input('post.from');
$res = db('Category')->where(array('id' => $from))->setField('pid', $to);
if ($res !== false) {
return $this->success('分类移动成功!', url('index'));
} else {
return $this->error('分类移动失败!');
}
}
/**
* @title 合并分类
* @author huajie <banhuajie@163.com>
*/
public function merge() {
$to = input('post.to');
$from = input('post.from');
$Model = model('Category');
//检查分类绑定的模型
$from_models = explode(',', $Model->getFieldById($from, 'model'));
$to_models = explode(',', $Model->getFieldById($to, 'model'));
foreach ($from_models as $value) {
if (!in_array($value, $to_models)) {
return $this->error('请给目标分类绑定' . get_document_model($value, 'title') . '模型');
}
}
//检查分类选择的文档类型
$from_types = explode(',', $Model->getFieldById($from, 'type'));
$to_types = explode(',', $Model->getFieldById($to, 'type'));
foreach ($from_types as $value) {
if (!in_array($value, $to_types)) {
$types = config('document_model_type');
return $this->error('请给目标分类绑定文档类型:' . $types[$value]);
}
}
//合并文档
$res = db('Document')->where(array('category_id' => $from))->setField('category_id', $to);
if ($res !== false) {
//删除被合并的分类
$Model->delete($from);
return $this->success('合并分类成功!', url('index'));
} else {
return $this->error('合并分类失败!');
}
}
/**
* @title 修改状态
* @author huajie <banhuajie@163.com>
*/
public function status() {
$id = $this->getArrayParam('id');
$status = input('status', '0', 'trim,intval');
if (!$id) {
return $this->error("非法操作!");
}
$map['id'] = array('IN', $id);
$result = db('Category')->where($map)->setField('status', $status);
if ($result) {
return $this->success("设置成功!");
} else {
return $this->error("设置失败!");
}
}
/**
* @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');
}
}
}
+219
View File
@@ -0,0 +1,219 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\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);
$map = array('status' => array('gt', -1));
if ($type) {
$map['type'] = $type;
}
$list = db('Channel')->where($map)->order('sort asc,id asc')->column('*', 'id');
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
config('_sys_get_channel_tree_', true);
$data = array(
'tree' => $list,
'type' => $type
);
$this->assign($data);
$this->setMeta('导航管理');
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);
}
}
/**
* @title 添加频道
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function add() {
if ($this->request->isPost()) {
$Channel = model('Channel');
$data = $this->request->post();
if ($data) {
$id = $Channel->save($data);
if ($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 {
$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', null);
$this->setMeta('新增导航');
return $this->fetch('edit');
}
}
/**
* @title 编辑频道
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function edit($id = 0) {
if ($this->request->isPost()) {
$Channel = model('Channel');
$data = $this->request->post();
if ($data) {
if (false !== $Channel->save($data, array('id' => $data['id']))) {
//记录行为
action_log('update_channel', 'channel', $data['id'], session('user_auth.uid'));
return $this->success('编辑成功', url('index'));
} else {
return $this->error('编辑失败');
}
} else {
return $this->error($Channel->getError());
}
} else {
$info = array();
/* 获取数据 */
$info = db('Channel')->find($id);
if (false === $info) {
return $this->error('获取配置信息错误');
}
$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', $info);
$this->setMeta('编辑导航');
return $this->fetch();
}
}
/**
* @title 删除频道
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
if (db('Channel')->where($map)->delete()) {
//删除category中的ismenu字段记录
$map = array('ismenu' => array('in', $id));
db('Category')->where($map)->setField('ismenu',0);
//记录行为
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
return $this->success('删除成功');
} else {
return $this->error('删除失败!');
}
}
/**
* @title 导航排序
* @author huajie <banhuajie@163.com>
*/
public function sort() {
if ($this->request->isGet()) {
$ids = input('ids');
$pid = input('pid');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {
$map['id'] = array('in', $ids);
} else {
if ($pid !== '') {
$map['pid'] = $pid;
}
}
$list = db('Channel')->where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->assign('list', $list);
$this->setMeta('导航排序');
return $this->fetch();
} elseif ($this->request->isPost()) {
$ids = input('post.ids');
$ids = explode(',', $ids);
foreach ($ids as $key => $value) {
$res = db('Channel')->where(array('id' => $value))->setField('sort', $key + 1);
}
if ($res !== false) {
return $this->success('排序成功!', url('admin/channel/index'));
} else {
return $this->error('排序失败!');
}
} else {
return $this->error('非法请求!');
}
}
/**
* @title 设置状态
*/
public function setStatus() {
$id = array_unique((array) input('ids', 0));
$status = input('status', '0', 'trim');
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
$result = db('Channel')->where($map)->update(array('status' => $status));
if ($result) {
return $this->success("操作成功!");
} else {
return $this->error("操作失败!");
}
}
}
+92
View File
@@ -0,0 +1,92 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 客户端管理
*/
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(
'list' => $list,
'page' => $list->render()
);
$this->assign($data);
$this->setMeta('客户端列表');
return $this->fetch();
}
/**
* @title 添加客户端
*/
public function add(\think\Request $request){
if ($this->request->isPost()) {
$data = $request->param();
$result = $this->model->validate(true)->save($data);
if (false !== $result) {
return $this->success('成功添加', url('client/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$data = array(
'info' => $info
);
$this->assign($data);
$this->setMeta('添加客户端');
return $this->fetch('add');
}
}
/**
* @title 编辑客户端
*/
public function edit(\think\Request $request){
if ($this->request->isPost()) {
$data = $request->param();
$result = $this->model->validate(true)->save($data, array('id'=>$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' => $info
);
$this->assign($data);
$this->setMeta('编辑客户端');
return $this->fetch('add');
}
}
/**
* @title 删除客户端
*/
public function del(\think\Request $request){
}
}
+250
View File
@@ -0,0 +1,250 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 配置管理
*/
class Config extends Admin {
public function _initialize() {
parent::_initialize();
$this->model = model('Config');
}
/**
* @title 配置管理
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function index() {
$group = input('group', 0, 'trim');
$name = input('name', '', 'trim');
/* 查询条件初始化 */
$map = array('status' => 1);
if ($group) {
$map['group'] = $group;
}
if ($name) {
$map['name'] = array('like', '%' . $name . '%');
}
$list = $this->model->where($map)->order('id desc')->paginate(25, false, array(
'query' => $this->request->param()
));
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$data = array(
'group' => config('config_group_list'),
'config_type' => config('config_config_list'),
'page' => $list->render(),
'group_id' => $group,
'list' => $list,
);
$this->assign($data);
$this->setMeta('配置管理');
return $this->fetch();
}
/**
* @title 信息配置
*/
public function group($id = 1) {
if ($this->request->isPost()) {
$config = $this->request->post('config/a');
$model = model('Config');
foreach ($config as $key => $value) {
$model->where(array('name' => $key))->setField('value', $value);
}
//清除db_config_data缓存
cache('db_config_data', null);
return $this->success("更新成功!");
} else {
$type = config('config_group_list');
$list = db("Config")->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
if ($list) {
$this->assign('list', $list);
}
$this->assign('id', $id);
$this->setMeta($type[$id] . '设置');
return $this->fetch();
}
}
/**
* @title 新增配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function add() {
if ($this->request->isPost()) {
$config = model('Config');
$data = $this->request->post();
if ($data) {
$id = $config->validate(true)->save($data);
if ($id) {
cache('db_config_data', null);
//记录行为
action_log('update_config', 'config', $id, session('user_auth.uid'));
return $this->success('新增成功', url('index'));
} else {
return $this->error('新增失败');
}
} else {
return $this->error($config->getError());
}
} else {
$this->setMeta('新增配置');
$this->assign('info', null);
return $this->fetch('edit');
}
}
/**
* @title 编辑配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function edit($id = 0) {
if ($this->request->isPost()) {
$config = model('Config');
$data = $this->request->post();
if ($data) {
$result = $config->validate('Config.edit')->save($data, array('id' => $data['id']));
if (false !== $result) {
cache('db_config_data', null);
//记录行为
action_log('update_config', 'config', $data['id'], session('user_auth.uid'));
return $this->success('更新成功', Cookie('__forward__'));
} else {
return $this->error($config->getError(), '');
}
} else {
return $this->error($config->getError());
}
} else {
$info = array();
/* 获取数据 */
$info = db('Config')->field(true)->find($id);
if (false === $info) {
return $this->error('获取配置信息错误');
}
$this->assign('info', $info);
$this->setMeta('编辑配置');
return $this->fetch();
}
}
/**
* @title 批量保存配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function save($config) {
if ($config && is_array($config)) {
$Config = db('Config');
foreach ($config as $name => $value) {
$map = array('name' => $name);
$Config->where($map)->setField('value', $value);
}
}
cache('db_config_data', null);
return $this->success('保存成功!');
}
/**
* @title 删除配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function del() {
$id = array_unique((array) input('id', 0));
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
if (db('Config')->where($map)->delete()) {
cache('DB_CONFIG_DATA', null);
//记录行为
action_log('update_config', 'config', $id, session('user_auth.uid'));
return $this->success('删除成功');
} else {
return $this->error('删除失败!');
}
}
/**
* @title 配置排序
* @author huajie <banhuajie@163.com>
*/
public function sort() {
if ($this->request->isGet()) {
$ids = input('ids');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {
$map['id'] = array('in', $ids);
} elseif (input('group')) {
$map['group'] = input('group');
}
$list = db('Config')->where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->assign('list', $list);
$this->setMeta('配置排序');
return $this->fetch();
} elseif ($this->request->isPost()) {
$ids = input('post.ids');
$ids = explode(',', $ids);
foreach ($ids as $key => $value) {
$res = db('Config')->where(array('id' => $value))->setField('sort', $key + 1);
}
if ($res !== false) {
return $this->success('排序成功!', Cookie('__forward__'));
} else {
return $this->error('排序失败!');
}
} else {
return $this->error('非法请求!');
}
}
/**
* @title 主题选择
*/
public function themes() {
$list = $this->model->getThemesList();
$pc = config('pc_themes');
$mobile = config('mobile_themes');
$data = array(
'pc' => $pc,
'mobile' => $mobile,
'list' => $list,
);
$this->assign($data);
$this->setMeta('主题设置');
return $this->fetch();
}
/**
* @title 设置主题
* @return json
*/
public function setthemes($name, $id){
$result = db('Config')->where('name', $name . '_themes')->setField('value', $id);
if (false !== $result) {
\think\Cache::clear();
return $this->success('设置成功!');
}else{
return $this->error('设置失败!');
}
}
}
+278
View File
@@ -0,0 +1,278 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 内容管理
*/
class Content extends Admin {
public function _initialize() {
parent::_initialize();
$this->getContentMenu();
$this->model_id = $model_id = $this->request->param('model_id');
$list = db('Model')->column('*', 'id');
if (empty($list[$model_id])) {
return $this->error("无此模型!");
} else {
$this->modelInfo = $list[$model_id];
$this->model = M($this->modelInfo['name']);
}
$this->assign('model_id', $model_id);
$this->assign('model_list', $list);
}
/**
* @title 内容列表
* @return [html] [页面内容]
* @author molong <ycgpp@126.com>
*/
public function index() {
if ($this->modelInfo['list_grid'] == '') {
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
}
$grid_list = get_grid_list($this->modelInfo['list_grid']);
$order = "id desc";
$map = $this->buildMap();
$field = array_filter($grid_list['fields']);
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
'query' => $this->request->param()
));
$data = array(
'grid' => $grid_list,
'list' => $list,
'page' => $list->render(),
);
if ($this->modelInfo['template_list']) {
$template = 'content/' . $this->modelInfo['template_list'];
} else {
$template = 'content/index';
}
$this->assign($data);
$this->setMeta($this->modelInfo['title'] . "列表");
return $this->fetch($template);
}
/**
* @title 内容添加
* @author molong <ycgpp@126.com>
*/
public function add() {
if ($this->request->isPost()) {
$result = $this->model->save($this->request->param());
if ($result) {
//记录行为
action_log('add_content', 'content', $result, session('auth_user.uid'));
return $this->success("添加成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
} else {
return $this->error($this->model->getError(), url('admin/content/add', array('model_id' => $this->modelInfo['id'])));
}
} else {
$info = array(
'model_id' => $this->modelInfo['id'],
);
$data = array(
'info' => $info,
'fieldGroup' => $this->getField($this->modelInfo),
);
if ($this->modelInfo['template_add']) {
$template = 'content/' . $this->modelInfo['template_add'];
} else {
$template = 'public/edit';
}
$this->assign($data);
$this->setMeta("添加" . $this->modelInfo['title']);
return $this->fetch($template);
}
}
/**
* @title 内容修改
* @author molong <ycgpp@126.com>
*/
public function edit($id) {
if ($this->request->isPost()) {
$result = $this->model->save($this->request->param(), array('id'=> $id));
if ($result !== false) {
//记录行为
action_log('update_content', 'content', $result, session('auth_user.uid'));
return $this->success("更新成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
} else {
return $this->error($this->model->getError(), url('admin/content/edit', array('model_id' => $this->modelInfo['id'], 'id' => $id)));
}
} else {
if (!$id) {
return $this->error("非法操作!");
}
$info = $this->model->find($id);
if (!$info) {
return $this->error($this->model->getError());
}
$info['model_id'] = $this->modelInfo['id'];
$data = array(
'info' => $info,
'fieldGroup' => $this->getField($this->modelInfo),
);
if ($this->modelInfo['template_edit']) {
$template = 'content/' . $this->modelInfo['template_edit'];
} else {
$template = 'public/edit';
}
$this->assign($data);
$this->setMeta("编辑" . $this->modelInfo['title']);
return $this->fetch($template);
}
}
/**
* @title 内容删除
* @author molong <ycgpp@126.com>
*/
public function del() {
$param = $this->request->param();
$id = $param['id'];
if (empty($id)) {
return $this->error("非法操作!");
}
$map['id'] = array('IN', $id);
$result = $this->model->where($map)->delete();
if (false !== $result) {
//记录行为
action_log('delete_content', 'content', $result, session('auth_user.uid'));
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
/**
* @title 设置状态
* @author molong <ycgpp@126.com>
*/
public function status($id, $status) {
$map['id'] = $id;
$result = $this->model->where($map)->setField('status', $status);
if (false !== $result) {
return $this->success("操作成功!");
} else {
return $this->error("操作失败!!");
}
}
/**
* @title 设置置顶
* @author molong <ycgpp@126.com>
*/
public function settop($id, $is_top) {
$map['id'] = $id;
$result = $this->model->where($map)->setField('is_top', $is_top);
if (false !== $result) {
return $this->success("操作成功!");
} else {
return $this->error("操作失败!!");
}
}
/**
* @title 获取字段信息
* @return array 字段数组
* @author molong <ycgpp@126.com>
*/
protected function getField() {
$field_group = parse_config_attr($this->modelInfo['attribute_group']);
$map['model_id'] = $this->modelInfo['id'];
if ($this->request->action() == 'add') {
$map['is_show'] = array('in', array('1', '2'));
} elseif ($this->request->action() == 'edit') {
$map['is_show'] = array('in', array('1', '3'));
}
//获得数组的第一条数组
$rows = model('Attribute')->getFieldlist($map, 'id');
if (!empty($rows)) {
foreach ($rows as $key => $value) {
$list[$value['group_id']][] = $value;
}
foreach ($field_group as $key => $value) {
$fields[$value] = isset($list[$key]) ? $list[$key] : array();
}
}else{
$fields = array();
}
return $fields;
}
/**
* @title 创建搜索
* @return [array] [查询条件]
*/
protected function buildMap() {
$map = array();
$data = $this->request->param();
foreach ($data as $key => $value) {
if ($value) {
if ($key == 'keyword') {
$map['title'] = array("LIKE", "%$value%");
} elseif ($key == 'category') {
$map['category_id'] = $value;
} elseif ($key == 'create_time') {
$map['create_time'] = array('BETWEEN', array(strtotime($value[0]), strtotime($value[1])));
} else {
$map[$key] = $value;
}
}
}
if (isset($map['page'])) {
unset($map['page']);
}
if (isset($map['model_id'])) {
unset($map['model_id']);
}
$this->assign($data);
return $map;
}
/**
* 检测需要动态判断的文档类目有关的权限
*
* @return boolean|null
* 返回true则表示当前访问有权限
* 返回false则表示当前访问无权限
* 返回null,则会进入checkRule根据节点授权判断权限
*
* @author 朱亚杰 <xcoolcc@gmail.com>
*/
protected function checkDynamic() {
$model_id = $this->request->param('model_id');
if (IS_ROOT) {
return true; //管理员允许访问任何页面
}
$models = model('AuthGroup')->getAuthModels(session('user_auth.uid'));
if (!$model_id) {
return false;
} elseif (in_array($model_id, $models)) {
//返回null继续判断操作权限
return null;
} else {
return false; //无权限
}
return false;
}
}
+287
View File
@@ -0,0 +1,287 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 数据库管理
* @description 数据库管理
*/
class Database extends Admin {
/**
* 数据库备份/还原列表
* @param String $type import-还原,export-备份
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function index($type = null) {
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;
}
}
$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->assign('list', $list);
return $this->fetch($type);
}
/**
* @title 优化表
* @param String $tables 表名
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function optimize($tables = null) {
if ($tables) {
$Db = \think\Db::connect();
if (is_array($tables)) {
$tables = implode('`,`', $tables);
$list = $Db->query("OPTIMIZE TABLE `{$tables}`");
if ($list) {
return $this->success("数据表优化完成!");
} else {
return $this->error("数据表优化出错请重试!");
}
} else {
$list = $Db->query("OPTIMIZE TABLE `{$tables}`");
if ($list) {
return $this->success("数据表'{$tables}'优化完成!");
} else {
return $this->error("数据表'{$tables}'优化出错请重试!");
}
}
} else {
return $this->error("请指定要优化的表!");
}
}
/**
* @title 修复表
* @param String $tables 表名
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function repair($tables = null) {
if ($tables) {
$Db = \think\Db::connect();
if (is_array($tables)) {
$tables = implode('`,`', $tables);
$list = $Db->query("REPAIR TABLE `{$tables}`");
if ($list) {
return $this->success("数据表修复完成!");
} else {
return $this->error("数据表修复出错请重试!");
}
} else {
$list = $Db->query("REPAIR TABLE `{$tables}`");
if ($list) {
return $this->success("数据表'{$tables}'修复完成!");
} else {
return $this->error("数据表'{$tables}'修复出错请重试!");
}
}
} else {
return $this->error("请指定要修复的表!");
}
}
/**
* @title 删除备份文件
* @param Integer $time 备份时间
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function del($time = 0) {
if ($time) {
$name = date('Ymd-His', $time) . '-*.sql*';
$path = realpath(config('DATA_BACKUP_PATH')) . DIRECTORY_SEPARATOR . $name;
array_map("unlink", glob($path));
if (count(glob($path))) {
return $this->error('备份文件删除失败,请检查权限!');
} else {
return $this->success('备份文件删除成功!');
}
} else {
return $this->error('参数错误!');
}
}
/**
* @title 备份数据库
* @param String $tables 表名
* @param Integer $id 表ID
* @param Integer $start 起始行数
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function export($tables = null, $id = null, $start = null) {
if ($this->request->isPost() && !empty($tables) && is_array($tables)) {
//初始化
$path = config('data_backup_path');
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
//读取备份配置
$config = array('path' => realpath($path) . DIRECTORY_SEPARATOR, 'part' => config('data_backup_part_size'), 'compress' => config('data_backup_compress'), 'level' => config('data_backup_compress_level'));
//检查是否有正在执行的任务
$lock = "{$config['path']}backup.lock";
if (is_file($lock)) {
return $this->error('检测到有一个备份任务正在执行,请稍后再试!');
} else {
//创建锁文件
file_put_contents($lock, time());
}
//检查备份目录是否可写
if (!is_writeable($config['path'])) {
return $this->error('备份目录不存在或不可写,请检查后重试!');
}
session('backup_config', $config);
//生成备份文件信息
$file = array('name' => date('Ymd-His', time()), 'part' => 1);
session('backup_file', $file);
//缓存要备份的表
session('backup_tables', $tables);
//创建备份文件
$Database = new \com\Database($file, $config);
if (false !== $Database->create()) {
$tab = array('id' => 0, 'start' => 0);
return $this->success('初始化成功!', '', array('tables' => $tables, 'tab' => $tab));
} else {
return $this->error('初始化失败,备份文件创建失败!');
}
} elseif ($this->request->isGet() && is_numeric($id) && is_numeric($start)) {
//备份数据
$tables = session('backup_tables');
//备份指定表
$Database = new \com\Database(session('backup_file'), session('backup_config'));
$start = $Database->backup($tables[$id], $start);
if (false === $start) {
//出错
return $this->error('备份出错!');
} elseif (0 === $start) {
//下一表
if (isset($tables[++$id])) {
$tab = array('id' => $id, 'start' => 0);
return $this->success('备份完成!', '', array('tab' => $tab));
} else {
//备份完成,清空缓存
unlink(session('backup_config.path') . 'backup.lock');
session('backup_tables', null);
session('backup_file', null);
session('backup_config', null);
return $this->success('备份完成!');
}
} else {
$tab = array('id' => $id, 'start' => $start[0]);
$rate = floor(100 * ($start[0] / $start[1]));
return $this->success("正在备份...({$rate}%)", '', array('tab' => $tab));
}
} else {
//出错
return $this->error('参数错误!');
}
}
/**
* @title 还原数据库
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function import($time = 0, $part = null, $start = null) {
if (is_numeric($time) && is_null($part) && is_null($start)) {
//初始化
//获取备份文件信息
$name = date('Ymd-His', $time) . '-*.sql*';
$path = realpath(config('data_backup_path')) . DIRECTORY_SEPARATOR . $name;
$files = glob($path);
$list = array();
foreach ($files as $name) {
$basename = basename($name);
$match = sscanf($basename, '%4s%2s%2s-%2s%2s%2s-%d');
$gz = preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql.gz$/', $basename);
$list[$match[6]] = array($match[6], $name, $gz);
}
ksort($list);
//检测文件正确性
$last = end($list);
if (count($list) === $last[0]) {
session('backup_list', $list); //缓存备份列表
return $this->success('初始化完成!', '', array('part' => 1, 'start' => 0));
} else {
return $this->error('备份文件可能已经损坏,请检查!');
}
} elseif (is_numeric($part) && is_numeric($start)) {
$list = session('backup_list');
$db = new \com\Database($list[$part], array('path' => realpath(config('data_backup_path')) . DIRECTORY_SEPARATOR, 'compress' => $list[$part][2]));
$start = $db->import($start);
if (false === $start) {
return $this->error('还原数据出错!');
} elseif (0 === $start) {
//下一卷
if (isset($list[++$part])) {
$data = array('part' => $part, 'start' => 0);
return $this->success("正在还原...#{$part}", '', $data);
} else {
session('backup_list', null);
return $this->success('还原完成!');
}
} else {
$data = array('part' => $part, 'start' => $start[0]);
if ($start[1]) {
$rate = floor(100 * ($start[0] / $start[1]));
return $this->success("正在还原...#{$part} ({$rate}%)", '', $data);
} else {
$data['gz'] = 1;
return $this->success("正在还原...#{$part}", '', $data);
}
}
} else {
return $this->error('参数错误!');
}
}
}
+296
View File
@@ -0,0 +1,296 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 自定义表单
* @description 自定义表单
*/
class Form extends Admin {
public function _initialize() {
parent::_initialize();
$this->model = model('Form');
$this->Fattr = model('FormAttr');
//遍历属性列表
foreach (get_attribute_type() as $key => $value) {
$this->attr[$key] = $value[0];
}
$this->field = $this->getField();
}
/**
* @title 表单列表
*/
public function index() {
$map = array();
$order = "id desc";
$list = $this->model->where($map)->order($order)->paginate(25, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->setMeta('自定义表单');
$this->assign($data);
return $this->fetch();
}
/**
* @title 添加表单
*/
public function add(\think\Request $request) {
if ($this->request->isPost()) {
$result = $this->model->validate('Form')->save($request->post());
if (false !== $result) {
return $this->success('添加成功!', url('admin/form/index'));
} else {
return $this->error($this->model->getError());
}
} else {
$data = array(
'keyList' => $this->model->addField,
);
$this->assign($data);
$this->setMeta('添加表单');
return $this->fetch('public/edit');
}
}
/**
* @title 编辑表单
*/
public function edit(\think\Request $request) {
if ($this->request->isPost()) {
$result = $this->model->validate('Form')->save($request->post(), array('id' => $request->post('id')));
if (false !== $result) {
return $this->success('修改成功!', url('admin/form/index'));
} else {
return $this->error($this->model->getError());
}
} else {
$info = $this->model->where('id', $request->param('id'))->find();
$data = array(
'info' => $info,
'keyList' => $this->model->editField,
);
$this->assign($data);
$this->setMeta('编辑表单');
return $this->fetch('public/edit');
}
}
/**
* @title 删除表单
*/
public function del() {
$id = $this->getArrayParam('id');
$result = false;
if (false !== $result) {
return $this->success('删除成功!');
} else {
return $this->error('删除失败!');
}
}
/**
* @title 表单数据
* @description 表单数据
* @Author molong
* @DateTime 2017-06-30
* @return html 页面
*/
public function lists($form_id = '') {
$form = $this->model->where('id', $form_id)->find();
$list = M($form['name'], 'form')->order('id desc')->paginate(25);
$data = array(
'form_id' => $form_id,
'list' => $list,
'page' => $list->render()
);
$this->assign($data);
$this->setMeta('数据列表');
return $this->fetch('list_'.$form['name']);
}
/**
* @title 数据详情
*/
public function detail($form_id = '', $id = ''){
$form = $this->model->where('id', $form_id)->find();
$info = M($form['name'], 'form')->where('id', $id)->find();
$data = array(
'info' => $info
);
$this->assign($data);
$this->setMeta('数据详情');
return $this->fetch('detail_'.$form['name']);
}
/**
* @title 数据导出
*/
public function outxls($form_id = '') {
$form = $this->model->where('id', $form_id)->find();
$attr = $this->Fattr->where('form_id', $form_id)->where('is_show', 1)->select();
foreach ($attr as $key => $value) {
$title[$value['name']] = $value['title'];
}
$data[] = $title;
$res = M($form['name'], 'form')->order('id desc')->select();
foreach ($res as $key => $value) {
$data[] = $value;
}
$out = new \com\Outxls($data, date('Y-m-d'));
$out->out();
}
/**
* @title 表单字段
*/
public function attr($form_id = '') {
$map = array();
$order = "id desc";
$list = $this->Fattr->where($map)->order($order)->paginate(25);
$data = array(
'list' => $list,
'form_id' => $form_id,
'page' => $list->render(),
);
$this->setMeta('表单字段');
$this->assign($data);
return $this->fetch();
}
/**
* @title 添加表单字段
*/
public function addattr(){
$form_id = $this->request->param('form_id', '');
if (!$form_id) {
return $this->error('非法操作!');
}
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $this->Fattr->save($data);
if (false !== $result) {
return $this->success('添加成功!', url('admin/form/attr?form_id='.$form_id));
}else{
return $this->error($this->Fattr->getError());
}
}else{
$info = array(
'form_id' => $form_id
);
$data = array(
'info' => $info,
'keyList' => $this->field
);
$this->assign($data);
$this->setMeta('添加字段');
return $this->fetch('public/edit');
}
}
/**
* @title 编辑表单字段
*/
public function editattr(\think\Request $request){
$param = $this->request->param();
$form_id = isset($param['form_id']) ? $param['form_id'] : '';
$id = isset($param['id']) ? $param['id'] : '';
if (!$form_id || !$id) {
return $this->error('非法操作!');
}
if ($this->request->isPost()) {
$data = $request->post();
$result = $this->Fattr->save($data, array('id'=>$data['id']));
if (false !== $result) {
return $this->success('修改成功!', url('admin/form/attr?form_id='.$form_id));
}else{
return $this->error($this->Fattr->getError());
}
}else{
$info = $this->Fattr->where('id', $id)->find();
$data = array(
'info' => $info,
'keyList' => $this->field
);
$this->assign($data);
$this->setMeta('添加字段');
return $this->fetch('public/edit');
}
}
/**
* @title 删除表单字段
*/
public function delattr(\think\Request $request){
$id = $request->param('id', 0);
if (!$id) {
return $this->error('非法操作!');
}
$result = $this->Fattr->where('id', $id)->delete();
if (false !== $result) {
return $this->success('添加成功!');
}else{
return $this->error($this->Fattr->getError());
}
}
protected function getField(){
return array(
array('name' => 'id', 'title' => 'id', 'help' => '', 'type' => 'hidden'),
array('name' => 'form_id', 'title' => 'model_id', 'help' => '', 'type' => 'hidden'),
array('name' => 'name', 'title' => '字段名', 'help' => '英文字母开头,长度不超过30', 'type' => 'text'),
array('name' => 'title', 'title' => '字段标题', 'help' => '请输入字段标题,用于表单显示', 'type' => 'text'),
array('name' => 'type', 'title' => '字段类型', 'help' => '用于表单中的展示方式', 'type' => 'select', 'option' => $this->attr, 'help' => ''),
array('name' => 'length', 'title' => '字段长度', 'help' => '字段的长度值', 'type' => 'text'),
array('name' => 'extra', 'title' => '参数', 'help' => '布尔、枚举、多选字段类型的定义数据', 'type' => 'textarea'),
array('name' => 'value', 'title' => '默认值', 'help' => '字段的默认值', 'type' => 'text'),
array('name' => 'remark', 'title' => '字段备注', 'help' => '用于表单中的提示', 'type' => 'text'),
array('name' => 'is_show', 'title' => '是否显示', 'help' => '是否显示在表单中', 'type' => 'select', 'option' => array('1' => '始终显示', '2' => '新增显示', '3' => '编辑显示', '0' => '不显示'), 'value' => 1),
array('name' => 'is_must', 'title' => '是否必填', 'help' => '用于自动验证', 'type' => 'select', 'option' => array('0' => '否', '1' => '是')),
);
}
/**
* @title 修改状态
* @author K先森 <77413254@qq.com>
*/
public function status() {
$id = $this->getArrayParam('id');
$status = input('status', '0', 'trim,intval');
if (!$id) {
return $this->error("非法操作!");
}
$map['id'] = array('IN', $id);
$result = db('form')->where($map)->setField('status', $status);
if ($result) {
return $this->success("设置成功!");
} else {
return $this->error("设置失败!");
}
}
}
+283
View File
@@ -0,0 +1,283 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 用户组管理
* @description 用户组管理
*/
class Group extends Admin {
protected $model;
protected $rule;
public function _initialize() {
parent::_initialize();
$this->group = model('AuthGroup');
$this->rule = model('AuthRule');
}
/**
* @title 用户组列表
*/
public function index($type = 'admin') {
$map['module'] = $type;
$list = db('AuthGroup')->where($map)->order('id desc')->paginate(10, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'page' => $list->render(),
'type' => $type,
);
$this->assign($data);
$this->setMeta('用户组管理');
return $this->fetch();
}
/**
* @title 添加用户组
*/
public function add($type = 'admin') {
if ($this->request->isPost()) {
$result = $this->group->change();
if ($result) {
return $this->success("添加成功!", url('admin/group/index'));
} else {
return $this->error("添加失败!");
}
} else {
$data = array(
'info' => array('module' => $type, 'status' => 1),
'keyList' => $this->group->keyList,
);
$this->assign($data);
$this->setMeta('添加用户组');
return $this->fetch('public/edit');
}
}
/**
* @title 编辑用户组
*/
public function edit($id) {
if (!$id) {
return $this->error("非法操作!");
}
if ($this->request->isPost()) {
$result = $this->group->change();
if ($result) {
return $this->success("编辑成功!", url('admin/group/index'));
} else {
return $this->error("编辑失败!");
}
} else {
$info = $this->group->where(array('id' => $id))->find();
$data = array(
'info' => $info,
'keyList' => $this->group->keyList,
);
$this->assign($data);
$this->setMeta('编辑用户组');
return $this->fetch('public/edit');
}
}
/**
* @title 编辑用户组单字段
*/
public function editable() {
$pk = input('pk', '', 'trim,intval');
$name = input('name', '', 'trim');
$value = input('value', '', 'trim');
$result = $this->group->where(array('id' => $pk))->setField($name, $value);
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
/**
* @title 删除用户组
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!");
}
$result = $this->group->where(array('id' => array('IN', $id)))->delete();
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
/**
* @title 权限节点
*/
public function access($type = 'admin') {
$map['module'] = $type;
$list = db('AuthRule')->where($map)->order('id desc')->paginate(15, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'page' => $list->render(),
'type' => $type,
);
$this->assign($data);
$this->setMeta('权限节点');
return $this->fetch();
}
/**
* @title 更新权限
*/
public function upnode($type) {
//$rule = model('Menu')->getAuthNodes($type);
$reuslt = $this->rule->uprule($type);
return $this->success("更新成功!");
}
/**
* @title 用户组授权
*/
public function auth($id) {
if (!$id) {
return $this->error("非法操作!");
}
if ($this->request->isPost()) {
$rule = $this->request->post('rule/a', array());
$extend_rule = $this->request->post('extend_rule/a', array());
$extend_result = $rule_result = false;
//扩展权限
$extend_data = array();
foreach ($extend_rule as $key => $value) {
foreach ($value as $item) {
$extend_data[] = array('group_id' => $id, 'extend_id' => $item, 'type' => $key);
}
}
if (!empty($extend_data)) {
db('AuthExtend')->where(array('group_id' => $id))->delete();
$extend_result = db('AuthExtend')->insertAll($extend_data);
}
if ($rule) {
$rules = implode(',', $rule);
$rule_result = $this->group->where(array('id' => $id))->setField('rules', $rules);
}
if ($rule_result !== false || $extend_result !== false) {
return $this->success("授权成功!", url('admin/group/index'));
} else {
return $this->error("授权失败!");
}
} else {
$group = $this->group->where(array('id' => $id))->find();
$map['module'] = $group['module'];
$row = db('AuthRule')->where($map)->order('id desc')->select();
$list = array();
foreach ($row as $key => $value) {
$list[$value['group']][] = $value;
}
//模块
$model = db('model')->field('id,title,name')
->where(array('status' => array('gt', 0)))
->select();
//扩展权限
$extend_auth = db('AuthExtend')->where(array('group_id' => $id, 'type' => 2))->column('extend_id');
$data = array(
'list' => $list,
'model' => $model,
'extend_auth' => $extend_auth,
'auth_list' => explode(',', $group['rules']),
'id' => $id,
);
$this->assign($data);
$this->setMeta('授权');
return $this->fetch();
}
}
/**
* @title 添加节点
*/
public function addnode($type = 'admin') {
if ($this->request->isPost()) {
$result = $this->rule->change();
if ($result) {
return $this->success("创建成功!", url('admin/group/access'));
} else {
return $this->error($this->rule->getError());
}
} else {
$data = array(
'info' => array('module' => $type, 'status' => 1),
'keyList' => $this->rule->keyList,
);
$this->assign($data);
$this->setMeta('添加节点');
return $this->fetch('public/edit');
}
}
/**
* @title 编辑节点
*/
public function editnode($id) {
if ($this->request->isPost()) {
$result = $this->rule->change();
if (false !== $result) {
return $this->success("更新成功!", url('admin/group/access'));
} else {
return $this->error("更新失败!");
}
} else {
if (!$id) {
return $this->error("非法操作!");
}
$info = $this->rule->find($id);
$data = array(
'info' => $info,
'keyList' => $this->rule->keyList,
);
$this->assign($data);
$this->setMeta('编辑节点');
return $this->fetch('public/edit');
}
}
/**
* @title 删除节点
*/
public function delnode($id) {
if (!$id) {
return $this->error("非法操作!");
}
$result = $this->rule->where(array('id' => $id))->delete();
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
}
+68 -6
View File
@@ -9,6 +9,7 @@
namespace app\controller\admin; namespace app\controller\admin;
use app\controller\Admin; use app\controller\Admin;
use app\model\Member;
/** /**
* @title 后端公共模块 * @title 后端公共模块
@@ -24,18 +25,79 @@ class Index extends Admin {
} }
/** /**
* @title 后台登录 * @title 用户登录
* @return html [description] * @return html
*/ */
public function login() { public function login(Member $user, $username = '', $password = '', $verify = '') {
return $this->fetch(); if ($this->request->isPost()) {
if (!$username || !$password) {
return $this->error('用户名或者密码不能为空!', '');
}
//验证码验证
if (!captcha_check($verify)) {
return $this->error('验证码错误!', '');
}
$userinfo = $user->login($this->request);
if ($userinfo) {
// return $this->success('登录成功!', url('admin/index/index'));
} else {
print_r($user->error);
// switch ($uid) {
// case -1:$error = '用户不存在或被禁用!';
// break; //系统级别禁用
// case -2:$error = '密码错误!';
// break;
// default:$error = '未知错误!';
// break; // 0-接口参数错误(调试阶段使用)
// }
return $this->error($error, '');
}
} else {
return $this->fetch();
}
} }
/** /**
* @title 后台退出 * @title 后台退出
* @return html [description] * @return html
*/ */
public function logout() { public function logout() {
return $this->fetch(); $user = model('Member');
$user->logout();
$this->redirect('admin/index/login');
}
/**
* @title 清除缓存
* @return html
*/
public function clear() {
if ($this->request->isPost()) {
$clear = input('post.clear/a', array());
foreach ($clear as $key => $value) {
if ($value == 'cache') {
\think\Cache::clear(); // 清空缓存数据
} elseif ($value == 'log') {
\think\Log::clear();
}
}
return $this->success("更新成功!", url('admin/index/index'));
} else {
$keylist = array(
array('name' => 'clear', 'title' => '更新缓存', 'type' => 'checkbox', 'help' => '', 'option' => array(
'cache' => '缓存数据',
'log' => '日志数据',
),
),
);
$data = array(
'keyList' => $keylist,
);
$this->assign($data);
$this->setMeta("更新缓存");
return $this->fetch('public/edit');
}
} }
} }
+118
View File
@@ -0,0 +1,118 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 友情链接
* @description 友情链接
*/
class Link extends Admin {
/**
* @title 链接列表
*/
public function index() {
$map = array();
$order = "id desc";
$list = db('Link')->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta("友情链接");
return $this->fetch();
}
/**
* @title 添加链接
*/
public function add() {
$link = model('Link');
if ($this->request->isPost()) {
$data = input('post.');
if ($data) {
unset($data['id']);
$result = $link->save($data);
if ($result) {
return $this->success("添加成功!", url('Link/index'));
} else {
return $this->error($link->getError());
}
} else {
return $this->error($link->getError());
}
} else {
$data = array(
'keyList' => $link->keyList,
);
$this->assign($data);
$this->setMeta("添加友链");
return $this->fetch('public/edit');
}
}
/**
* @title 修改链接
*/
public function edit() {
$link = model('Link');
$id = input('id', '', 'trim,intval');
if ($this->request->isPost()) {
$data = input('post.');
if ($data) {
$result = $link->save($data, array('id' => $data['id']));
if ($result) {
return $this->success("修改成功!", url('Link/index'));
} else {
return $this->error("修改失败!");
}
} else {
return $this->error($link->getError());
}
} else {
$map = array('id' => $id);
$info = db('Link')->where($map)->find();
$data = array(
'keyList' => $link->keyList,
'info' => $info,
);
$this->assign($data);
$this->setMeta("编辑友链");
return $this->fetch('public/edit');
}
}
/**
* @title 删除链接
*/
public function delete() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error('非法操作!');
}
$link = db('Link');
$map = array('id' => array('IN', $id));
$result = $link->where($map)->delete();
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
}
+263
View File
@@ -0,0 +1,263 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 菜单管理
*/
class Menu extends Admin {
public function _initialize() {
parent::_initialize();
}
/**
* @title 菜单列表
*/
public function index() {
$map = array();
$title = trim(input('get.title'));
$list = db("Menu")->where($map)->field(true)->order('sort asc,id asc')->column('*', 'id');
int_to_string($list, array('hide' => array(1 => '是', 0 => '否'), 'is_dev' => array(1 => '是', 0 => '否')));
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$this->setMeta('菜单列表');
$this->assign('list', $list);
return $this->fetch();
}
/**
* @title 编辑菜单字段
*/
public function editable($name = null, $value = null, $pk = null) {
if ($name && ($value != null || $value != '') && $pk) {
db('Menu')->where(array('id' => $pk))->setField($name, $value);
}
}
/**
* @title 新增菜单
* @author yangweijie <yangweijiester@gmail.com>
*/
public function add() {
if ($this->request->isPost()) {
$Menu = model('Menu');
$data = input('post.');
$id = $Menu->save($data);
if ($id) {
session('admin_menu_list', null);
//记录行为
action_log('update_menu', 'Menu', $id, session('user_auth.uid'));
return $this->success('新增成功', Cookie('__forward__'));
} else {
return $this->error('新增失败');
}
} else {
$this->assign('info', array('pid' => input('pid')));
$menus = db('Menu')->select();
$tree = new \com\Tree();
$menus = $tree->toFormatTree($menus);
if (!empty($menus)) {
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
} else {
$menus = array(0 => array('id' => 0, 'title_show' => '顶级菜单'));
}
$this->assign('Menus', $menus);
$this->setMeta('新增菜单');
return $this->fetch('edit');
}
}
/**
* @title 编辑配置
* @author yangweijie <yangweijiester@gmail.com>
*/
public function edit($id = 0) {
if ($this->request->isPost()) {
$Menu = model('Menu');
$data = input('post.');
if ($Menu->save($data, array('id' => $data['id'])) !== false) {
session('admin_menu_list', null);
//记录行为
action_log('update_menu', 'Menu', $data['id'], session('user_auth.uid'));
return $this->success('更新成功', Cookie('__forward__'));
} else {
return $this->error('更新失败');
}
} else {
$info = array();
/* 获取数据 */
$info = db('Menu')->field(true)->find($id);
$menus = db('Menu')->field(true)->select();
$tree = new \com\Tree();
$menus = $tree->toFormatTree($menus);
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
$this->assign('Menus', $menus);
if (false === $info) {
return $this->error('获取后台菜单信息错误');
}
$this->assign('info', $info);
$this->setMeta('编辑后台菜单');
return $this->fetch();
}
}
/**
* @title 删除菜单
* @author yangweijie <yangweijiester@gmail.com>
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
if (db('Menu')->where($map)->delete()) {
session('admin_menu_list', null);
//记录行为
action_log('update_menu', 'Menu', $id, session('user_auth.uid'));
return $this->success('删除成功');
} else {
return $this->error('删除失败!');
}
}
public function toogleHide($id, $value = 1) {
session('admin_menu_list', null);
$result = db('Menu')->where(array('id' => $id))->setField(array('hide' => $value));
if ($result !== false) {
return $this->success('操作成功!');
} else {
return $this->error('操作失败!');
}
}
public function toogleDev($id, $value = 1) {
session('admin_menu_list', null);
$result = db('Menu')->where(array('id' => $id))->setField(array('is_dev' => $value));
if ($result !== false) {
return $this->success('操作成功!');
} else {
return $this->error('操作失败!');
}
}
public function importFile($tree = null, $pid = 0) {
if ($tree == null) {
$file = APP_PATH . "Admin/Conf/Menu.php";
$tree = require_once $file;
}
$menuModel = D('Menu');
foreach ($tree as $value) {
$add_pid = $menuModel->add(
array(
'title' => $value['title'],
'url' => $value['url'],
'pid' => $pid,
'hide' => isset($value['hide']) ? (int) $value['hide'] : 0,
'tip' => isset($value['tip']) ? $value['tip'] : '',
'group' => $value['group'],
)
);
if ($value['operator']) {
$this->import($value['operator'], $add_pid);
}
}
}
public function import() {
if ($this->request->isPost()) {
$tree = input('post.tree');
$lists = explode(PHP_EOL, $tree);
$menuModel = db('Menu');
if ($lists == array()) {
return $this->error('请按格式填写批量导入的菜单,至少一个菜单');
} else {
$pid = input('post.pid');
foreach ($lists as $key => $value) {
$record = explode('|', $value);
if (count($record) == 4) {
$menuModel->add(array(
'title' => $record[0],
'url' => $record[1],
'pid' => $record[2],
'sort' => 0,
'hide' => 0,
'tip' => '',
'is_dev' => 0,
'group' => $record[3],
));
}
}
session('admin_menu_list', null);
return $this->success('导入成功', url('index?pid=' . $pid));
}
} else {
$this->setMeta('批量导入后台菜单');
$pid = (int) input('get.pid');
$this->assign('pid', $pid);
$data = db('Menu')->where("id={$pid}")->field(true)->find();
$this->assign('data', $data);
return $this->fetch();
}
}
/**
* @title 菜单排序
* @author huajie <banhuajie@163.com>
*/
public function sort() {
if ($this->request->isGet()) {
$ids = input('ids');
$pid = input('pid');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {
$map['id'] = array('in', $ids);
} else {
if ($pid !== '') {
$map['pid'] = $pid;
}
}
$list = db('Menu')->where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->assign('list', $list);
$this->setMeta('菜单排序');
return $this->fetch();
} elseif ($this->request->isPost()) {
$ids = input('post.ids');
$ids = explode(',', $ids);
foreach ($ids as $key => $value) {
$res = db('Menu')->where(array('id' => $value))->setField('sort', $key + 1);
}
if ($res !== false) {
session('admin_menu_list', null);
return $this->success('排序成功!');
} else {
return $this->error('排序失败!');
}
} else {
return $this->error('非法请求!');
}
}
}
+157
View File
@@ -0,0 +1,157 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 模型管理
*/
class Model extends Admin {
public function _initialize() {
parent::_initialize();
$this->getContentMenu();
$this->model = model('Model');
}
/**
* @title 模型列表
* @author huajie <banhuajie@163.com>
*/
public function index() {
$map = array('status' => array('gt', -1));
$order = "id desc";
$list = $this->model->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'page' => $list->render(),
);
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$this->assign($data);
$this->setMeta('模型管理');
return $this->fetch();
}
/**
* @title 新增模型
* @author huajie <banhuajie@163.com>
*/
public function add(\think\Request $request) {
if ($this->request->isPost()) {
$result = $this->model->validate('Model.add')->save($request->post());
if (false !== $result) {
//记录行为
action_log('add_model', 'model', $result, session('auth_user.uid'));
$this->success('创建成功!', url('admin/model/index'));
} else {
return $this->error($this->model->getError() ? $this->model->getError() : '模型标识为保留名称!');
}
} else {
$this->setMeta('新增模型');
return $this->fetch();
}
}
/**
* @title 编辑模型
* @author molong <molong@tensent.cn>
*/
public function edit(\think\Request $request) {
if ($this->request->isPost()) {
$result = $this->model->validate('Model.edit')->save($request->post(), array('id' => $request->post('id')));
if (false !== $result) {
//记录行为
action_log('update_model', 'model', $request->post('id'), session('auth_user.uid'));
$this->success('更新成功!', url('admin/model/index'));
} else {
return $this->error($this->model->getError());
}
} else {
$info = $this->model->where('id', $request->param('id'))->find();
$field_group = parse_config_attr($info['attribute_group']);
//获取字段列表
$rows = db('Attribute')->where('model_id', $request->param('id'))->where('is_show', 1)->order('group_id asc, sort asc')->select();
if ($rows) {
// 梳理属性的可见性
foreach ($rows as $key => $field) {
$list[$field['group_id']][] = $field;
}
foreach ($field_group as $key => $value) {
$fields[$key] = isset($list[$key]) ? $list[$key] : array();
}
} else {
$fields = array();
}
$data = array(
'info' => $info,
'field_group' => $field_group,
'fields' => $fields,
);
$this->assign($data);
$this->setMeta('编辑模型');
return $this->fetch();
}
}
/**
* @title 删除模型
* @author huajie <banhuajie@163.com>
*/
public function del() {
$result = $this->model->del();
if ($result) {
return $this->success('删除模型成功!');
} else {
return $this->error($this->mdoel->getError());
}
}
public function update() {
$res = \think\Loader::model('Model')->change();
if ($res['status']) {
return $this->success($res['info'], url('index'));
} else {
return $this->error($res['info']);
}
}
/**
* @title 更新数据
* @author colin <colin@tensent.cn>
*/
public function status(\think\Request $request) {
$map['id'] = $request->param('id');
$data['status'] = $request->param('status');
if (null == $map['id'] || null == $data['status']) {
return $this->error('参数不正确!');
}
$model = $this->model->where($map)->find();
if ($model['list_grid'] == '' && $data['status'] == 1) {
return $this->error('模型列表未定义');
}
$result = $this->model->where($map)->update($data);
if (false !== $result) {
return $this->success('状态设置成功!');
} else {
return $this->error($this->model->getError());
}
}
}
+185
View File
@@ -0,0 +1,185 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title SEO管理
*/
class Seo extends Admin {
protected $seo;
protected $rewrite;
public function _initialize() {
parent::_initialize();
$this->seo = model('SeoRule');
$this->rewrite = model('Rewrite');
}
/**
* @title SEO列表
*/
public function index($page = 1, $r = 20) {
//读取规则列表
$map = array('status' => array('EGT', 0));
$list = $this->seo->where($map)->order('sort asc')->paginate(10, false, array(
'query' => $this->request->param()
));
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta("规则列表");
return $this->fetch();
}
/**
* @title 添加SEO
*/
public function add() {
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $this->seo->save($data);
if ($result) {
return $this->success("添加成功!");
} else {
return $this->error("添加失败!");
}
} else {
$data = array(
'keyList' => $this->seo->keyList,
);
$this->assign($data);
$this->setMeta("添加规则");
return $this->fetch('public/edit');
}
}
/**
* @title 编辑SEO
*/
public function edit($id = null) {
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $this->seo->save($data, array('id' => $data['id']));
if (false !== $result) {
return $this->success("修改成功!");
} else {
return $this->error("修改失败!");
}
} else {
$id = input('id', '', 'trim,intval');
$info = $this->seo->where(array('id' => $id))->find();
$data = array(
'info' => $info,
'keyList' => $this->seo->keyList,
);
$this->assign($data);
$this->setMeta("编辑规则");
return $this->fetch('public/edit');
}
}
/**
* @title 删除SEO
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!");
}
$result = $this->seo->where(array('id' => array('IN', $id)))->delete();
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
/**
* @title 伪静态列表
*/
public function rewrite() {
$list = db('Rewrite')->paginate(10);
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta("路由规则");
return $this->fetch();
}
/**
* @title 添加静态规则
*/
public function addrewrite() {
if ($this->request->isPost()) {
$result = model('Rewrite')->change();
if (false != $result) {
return $this->success("添加成功!", url('admin/seo/rewrite'));
} else {
return $this->error(model('Rewrite')->getError());
}
} else {
$data = array(
'keyList' => $this->rewrite->keyList,
);
$this->assign($data);
$this->setMeta("添加路由规则");
return $this->fetch('public/edit');
}
}
/**
* @title 编辑静态规则
*/
public function editrewrite() {
if ($this->request->isPost()) {
$result = model('Rewrite')->change();
if (false != $result) {
return $this->success("更新成功!", url('admin/seo/rewrite'));
} else {
return $this->error(model('Rewrite')->getError());
}
} else {
$id = input('id', '', 'trim,intval');
$info = db('Rewrite')->where(array('id' => $id))->find();
$data = array(
'info' => $info,
'keyList' => $this->rewrite->keyList,
);
$this->assign($data);
$this->setMeta("编辑路由规则");
return $this->fetch('public/edit');
}
}
/**
* @title 删除静态规则
*/
public function delrewrite() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error("非法操作!");
}
$result = db('Rewrite')->where(array('id' => array('IN', $id)))->delete();
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
}
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
class Upload extends Admin {
public function _empty() {
$controller = controller('common/Upload');
$action = $this->request->action();
return $controller->$action();
}
}
+278
View File
@@ -0,0 +1,278 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
/**
* @title 用户管理
*/
class User extends Admin {
/**
* @title 用户列表
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function index() {
$param = $this->request->param();
$map['status'] = array('egt', 0);
if (isset($param['nickname']) && $param['nickname']) {
$map['nickname'] = array('like', '%' . $param['nickname'] . '%');
}
if (isset($param['username']) && $param['username']) {
$map['username'] = array('like', '%' . (string) $param['nickname'] . '%');
}
$order = "uid desc";
$list = model('Member')->where($map)->order($order)
->paginate(15, false, array(
'param' => $param
));
$data = array(
'list' => $list,
'page' => $list->render(),
'param' => $param
);
$this->assign($data);
$this->setMeta('用户信息');
return $this->fetch();
}
/**
* @title 添加用户
* @author colin <molong@tensent.cn>
*/
public function add() {
$model = \think\Loader::model('Member');
if ($this->request->isPost()) {
$data = $this->request->param();
//创建注册用户
$result = $model->register($data['username'], $data['password'], $data['repassword'], $data['email'], false);
if ($result) {
return $this->success('用户添加成功!', url('admin/user/index'));
} else {
return $this->error($model->getError());
}
} else {
$data = array(
'keyList' => $model->addfield,
);
$this->assign($data);
$this->setMeta("添加用户");
return $this->fetch('public/edit');
}
}
/**
* @title 修改用户
* @author huajie <banhuajie@163.com>
*/
public function edit() {
$model = model('Member');
if ($this->request->isPost()) {
$data = $this->request->post();
$reuslt = $model->editUser($data, true);
if (false !== $reuslt) {
return $this->success('修改成功!', url('admin/user/index'));
} else {
return $this->error($model->getError(), '');
}
} else {
$info = $this->getUserinfo();
$data = array(
'info' => $info,
'keyList' => $model->editfield,
);
$this->assign($data);
$this->setMeta("编辑用户");
return $this->fetch('public/edit');
}
}
/**
* @title 删除用户
* @author colin <colin@tensent.cn>
*/
public function del($id) {
$uid = array('IN', is_array($id) ? implode(',', $id) : $id);
//获取用户信息
$find = $this->getUserinfo($uid);
model('Member')->where(array('uid' => $uid))->delete();
return $this->success('删除用户成功!');
}
/**
* @title 用户授权
* @author colin <colin@tensent.cn>
*/
public function auth() {
$access = model('AuthGroupAccess');
$group = model('AuthGroup');
if ($this->request->isPost()) {
$uid = input('uid', '', 'trim,intval');
$access->where(array('uid' => $uid))->delete();
$group_type = config('user_group_type');
foreach ($group_type as $key => $value) {
$group_id = input($key, '', 'trim,intval');
if ($group_id) {
$add = array(
'uid' => $uid,
'group_id' => $group_id,
);
$access->save($add);
}
}
return $this->success("设置成功!");
} else {
$uid = input('id', '', 'trim,intval');
$row = $group::select();
$auth = $access::where(array('uid' => $uid))->select();
$auth_list = array();
foreach ($auth as $key => $value) {
$auth_list[] = $value['group_id'];
}
foreach ($row as $key => $value) {
$list[$value['module']][] = $value;
}
$data = array(
'uid' => $uid,
'auth_list' => $auth_list,
'list' => $list,
);
$this->assign($data);
$this->setMeta("用户分组");
return $this->fetch();
}
}
/**
* @title 获取某个用户的信息
* @var uid 针对状态和删除启用
* @var pass 是查询password
* @var errormasg 错误提示
* @author colin <colin@tensent.cn>
*/
private function getUserinfo($uid = null, $pass = null, $errormsg = null) {
$user = model('Member');
$uid = $uid ? $uid : input('id');
//如果无UID则修改当前用户
$uid = $uid ? $uid : session('user_auth.uid');
$map['uid'] = $uid;
if ($pass != null) {
unset($map);
$map['password'] = $pass;
}
$list = $user::where($map)->field('uid,username,nickname,sex,email,qq,score,signature,status,salt')->find();
if (!$list) {
return $this->error($errormsg ? $errormsg : '不存在此用户!');
}
return $list;
}
/**
* @title 修改昵称
* @author huajie <banhuajie@163.com>
*/
public function submitNickname() {
//获取参数
$nickname = input('post.nickname');
$password = input('post.password');
if (empty($nickname)) {
return $this->error('请输入昵称');
}
if (empty($password)) {
return $this->error('请输入密码');
}
//密码验证
$User = new UserApi();
$uid = $User->login(UID, $password, 4);
if ($uid == -2) {
return $this->error('密码不正确');
}
$Member = model('Member');
$data = $Member->create(array('nickname' => $nickname));
if (!$data) {
return $this->error($Member->getError());
}
$res = $Member->where(array('uid' => $uid))->save($data);
if ($res) {
$user = session('user_auth');
$user['username'] = $data['nickname'];
session('user_auth', $user);
session('user_auth_sign', data_auth_sign($user));
return $this->success('修改昵称成功!');
} else {
return $this->error('修改昵称失败!');
}
}
/**
* @title 修改密码初始化
* @author huajie <banhuajie@163.com>
*/
public function editpwd() {
if ($this->request->isPost()) {
$user = model('Member');
$data = $this->request->post();
$res = $user->editpw($data);
if ($res) {
return $this->success('修改密码成功!');
} else {
return $this->error($user->getError());
}
} else {
$this->setMeta('修改密码');
return $this->fetch();
}
}
/**
* @title 会员状态修改
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
public function changeStatus($method = null) {
$id = array_unique((array) input('id', 0));
if (in_array(config('user_administrator'), $id)) {
return $this->error("不允许对超级管理员执行该操作!");
}
$id = is_array($id) ? implode(',', $id) : $id;
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map['uid'] = array('in', $id);
switch (strtolower($method)) {
case 'forbiduser':
$this->forbid('Member', $map);
break;
case 'resumeuser':
$this->resume('Member', $map);
break;
case 'deleteuser':
$this->delete('Member', $map);
break;
default:
return $this->error('参数非法');
}
}
}
+41
View File
@@ -0,0 +1,41 @@
<?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 Action {
protected function getStatusTextAttr($value, $data) {
$status = array(-1 => '删除', 0 => '禁用', 1 => '正常', 2 => '待审核');
return $status[$data['status']];
}
public $fieldlist = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),
array('name' => 'name', 'title' => '行为标识', 'type' => 'text', 'help' => '输入行为标识 英文字母'),
array('name' => 'title', 'title' => '行为名称', 'type' => 'text', 'help' => '输入行为名称'),
array('name' => 'type', 'title' => '行为类型', 'type' => 'select', 'help' => '选择行为类型', 'option' => ''),
array('name' => 'remark', 'title' => '行为描述', 'type' => 'textarea', 'help' => '输入行为描述'),
array('name' => 'rule', 'title' => '行为规则', 'type' => 'textarea', 'help' => '输入行为规则,不写则只记录日志'),
array('name' => 'log', 'title' => '日志规则', 'type' => 'textarea', 'help' => '记录日志备注时按此规则来生成,支持[变量|函数]。目前变量有:user,time,model,record,data'),
);
public function _initialize() {
parent::_initialize();
foreach ($this->fieldlist as $key => $value) {
if ($value['name'] == 'type') {
$value['option'] = get_action_type(null, true);
}
$this->fieldlist[$key] = $value;
}
}
}
+21
View File
@@ -0,0 +1,21 @@
<?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 ActionLog {
protected function getModelIdAttr($value, $data) {
$value = get_document_field($data['model'], "name", "id");
return $value ? $value : 0;
}
}
+36
View File
@@ -0,0 +1,36 @@
<?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 Ad {
protected $auto = array('update_time');
protected $insert = array('create_time');
protected $type = array(
'id' => 'integer',
'cover_id' => 'integer',
);
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'place_id', 'title' => 'PLACE_ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'title', 'title' => '广告名称', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'cover_id', 'title' => '广告图片', 'type' => 'image', 'help' => '', 'option' => ''),
array('name' => 'url', 'title' => '广告链接', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'photolist', 'title' => '辅助图片', 'type' => 'images', 'help' => '', 'option' => ''),
array('name' => 'listurl', 'title' => '辅助链接', 'type' => 'textarea', 'help' => '对应辅助图片的排序,一行一个', 'option' => ''),
array('name' => 'background', 'title' => '广告背景颜色', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'content', 'title' => '广告描述', 'type' => 'textarea', 'help' => '', 'option' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => array('1' => '开启', '0' => '禁用')),
);
}
+54
View File
@@ -0,0 +1,54 @@
<?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 AdPlace {
protected $auto = array('update_time');
protected $insert = array('create_time');
protected $type = array(
'start_time' => 'integer',
'end_time' => 'integer',
);
public $show_type = array(
'1' => '幻灯片',
'2' => '对联',
'3' => '图片列表',
'4' => '图文列表',
'5' => '文字列表',
'6' => '代码广告',
);
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'title', 'title' => '广告位名称', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'name', 'title' => '广告位标识', 'type' => 'text', 'help' => '调用使用{:ad("广告位标识",参数)}', 'option' => ''),
array('name' => 'show_type', 'title' => '类型', 'type' => 'select', 'help' => '', 'option' => ''),
array('name' => 'show_num', 'title' => '显示条数', 'type' => 'num', 'help' => '', 'option' => ''),
array('name' => 'start_time', 'title' => '开始时间', 'type' => 'datetime', 'help' => '', 'option' => ''),
array('name' => 'end_time', 'title' => '结束时间', 'type' => 'datetime', 'help' => '', 'option' => ''),
array('name' => 'template', 'title' => '广告模版', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => array('1' => '开启', '0' => '禁用')),
);
public function initialize() {
parent::initialize();
foreach ($this->keyList as $key => $value) {
if ($value['name'] == 'show_type') {
$value['option'] = $this->show_type;
}
$this->keyList[$key] = $value;
}
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 设置模型
*/
class Attribute {
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 function getTypeTextAttr($value, $data) {
$type = config('config_type_list');
$type_text = explode(',', $type[$data['type']]);
return $type_text[0];
}
public function getFieldlist($map, $index = 'id') {
$list = array();
$row = db('Attribute')->field('*,remark as help,type,extra as "option",model_id')->where($map)->order('group_id asc, sort asc')->select();
foreach ($row as $key => $value) {
if (in_array($value['type'], array('checkbox', 'radio', 'select', 'bool'))) {
$value['option'] = parse_field_attr($value['extra']);
} elseif ($value['type'] == 'bind') {
$extra = parse_field_bind($value['extra'], '', $value['model_id']);
$option = array();
foreach ($extra as $k => $v) {
$option[$v['id']] = $v['title_show'];
}
$value['option'] = $option;
}
$list[$value['id']] = $value;
}
return $list;
}
public function del($id, $model_id) {
$map['id'] = $id;
$info = $this->find($id);
$tablename = db('Model')->where(array('id' => $model_id))->value('name');
//先删除字段表内的数据
$result = $this->where($map)->delete();
if ($result) {
$tablename = strtolower($tablename);
//删除模型表中字段
$db = new \com\Datatable();
if (!$db->CheckField($tablename, $info['name'])) {
return true;
}
$result = $db->delField($tablename, $info['name'])->query();
if ($result) {
return true;
} else {
$this->error = "删除失败!";
return false;
}
} else {
$this->error = "删除失败!";
return false;
}
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use think\Model;
/**
* 设置模型
*/
class AuthGroupAccess extends Model{
}
+55
View File
@@ -0,0 +1,55 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use think\Model;
/**
* 设置模型
*/
class AuthRule extends Model{
const rule_url = 1;
const rule_mian = 2;
protected $type = array(
'id' => 'integer',
);
public $keyList = array(
array('name'=>'module','title'=>'所属模块','type'=>'hidden'),
array('name'=>'title','title'=>'节点名称','type'=>'text','help'=>''),
array('name'=>'name','title'=>'节点标识','type'=>'text','help'=>''),
array('name'=>'group','title'=>'功能组','type'=>'text','help'=>'功能分组'),
array('name'=>'status','title'=>'状态','type'=>'select','option'=>array('1'=>'启用','0'=>'禁用'),'help'=>''),
array('name'=>'condition','title'=>'条件','type'=>'text','help'=>'')
);
public function uprule($data, $type){
foreach ($data as $value) {
$data = array(
'module' => $type,
'type' => 2,
'name' => $value['url'],
'title' => $value['title'],
'group' => $value['group'],
'status' => 1,
);
$id = $this->where(array('name' => $data['name']))->value('id');
if ($id) {
$data['id'] = $id;
$this->save($data, array('id' => $id));
} else {
self::create($data);
}
}
return true;
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 设置模型
*/
class Category {
protected $name = "Category";
protected $auto = array('update_time', 'status' => 1);
protected $type = array(
'icon' => 'integer',
);
public function change() {
$data = input('post.');
if ($data['id']) {
$result = $this->save($data, array('id' => $data['id']));
} else {
unset($data['id']);
$result = $this->save($data);
}
if (false !== $result) {
return true;
} else {
$this->error = "失败!";
return false;
}
}
public function info($id, $field = true) {
return $this->db()->where(array('id' => $id))->field($field)->find();
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 设置模型
*/
class Channel {
protected $type = array(
'id' => 'integer',
);
protected $auto = array('update_time', 'status' => 1);
protected $insert = array('create_time');
}
+19
View File
@@ -0,0 +1,19 @@
<?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;
/**
* Client模型
*/
class Client {
protected $auto = array('update_time');
protected $insert = array('create_time');
}
+82
View File
@@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use think\facade\Cache;
use think\Model;
class Config extends Model {
public function getValuesAttr($value, $data) {
return self::parse($data['type'], $data['value']);
}
public static function getConfigList($request) {
$map[] = ['status', '=', 1];
$data = self::where($map)->field('type,name,value')->select();
$config = array();
if ($data) {
foreach ($data->toArray() as $value) {
$config[$value['name']] = self::parse($value['type'], $value['value']);
}
}
return $config;
}
public function getConfig($request) {
$map[] = ['status', '=', 1];
$data = self::where($map)->select()->append(['values']);
return $data;
}
public function getConfigTree($request) {
$map[] = ['status', '=', 1];
$data = self::where($map)->select();
$group = Cache::get('config')['config_group_list'];
$config = [];
foreach ($data->toArray() as $value) {
if (isset($group[$value['group']])) {
$config[$group[$value['group']]][] = $value;
}
}
return $config;
}
/**
* 根据配置类型解析配置
* @param integer $type 配置类型
* @param string $value 配置值
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
private static function parse($type, $value) {
$data = [];
switch ($type) {
case 'textarea': //解析数组
$array = preg_split('/[,;\r\n]+/', trim($value, ",;\r\n"));
if (strpos($value, ':')) {
foreach ($array as $val) {
$list = explode(':', $val);
if (isset($list[2])) {
$data[] = ['key' => is_numeric($list[0]) ? (int) $list[0] : $list[0], 'value' => $list[1], 'label' => $list[1], 'other' => $list[2]];
} else {
$data[] = ['key' => is_numeric($list[0]) ? (int) $list[0] : $list[0], 'value' => $list[1], 'label' => $list[1]];
}
}
} else {
foreach ($array as $key => $val) {
$data[] = ['key' => $key, 'value' => $val, 'label' => $val];
}
}
break;
}
return $data;
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 设置模型
*/
class ContentModel {
protected $type = array(
'create_time' => 'integer',
'update_time' => 'integer',
);
}
+16
View File
@@ -0,0 +1,16 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use think\Model;
class Department extends Model {
protected $name = "member_department";
}
+43
View File
@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use think\Model;
use think\facade\Db;
class Dictionary extends Model {
protected $type = [
'pid' => 'integer',
'code' => 'integer'
];
public function getTitleAttr($value, $data){
return $data['name'];
}
public function getDictionList($request){
$param = $request->param();
$map = [];
$order = "id asc";
if (isset($param['title']) && $param['title'] != '') {
$map[] = ['title', 'LIKE', '%'.$param['title'].'%'];
}
if (isset($param['status']) && $param['status'] != '') {
$map[] = ['status', '=', $param['status']];
}
if (isset($param['type']) && $param['type'] != '') {
$map[] = ['model', '=', $param['type']];
}
return self::where($map)->field('id, name, pid, code, model')->order($order)->select();
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 自定义表单模型
*/
class DiyFormModel {
protected $attrDb = 'FormAttr';
}
+93
View File
@@ -0,0 +1,93 @@
<?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 Form {
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 $type = array(
'id' => 'integer',
'create_time' => 'integer',
'update_time' => 'integer',
);
public $addField = array(
array('name' => 'name', 'title' => '标识', 'type' => 'text', 'help' => ''),
array('name' => 'title', 'title' => '标题', 'type' => 'text', 'help' => ''),
);
public $editField = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => ''),
array('name' => 'name', 'title' => '标识', 'type' => 'text', 'help' => ''),
array('name' => 'title', 'title' => '标题', 'type' => 'text', 'help' => ''),
array('name' => 'list_grid', 'title' => '列表定义', 'type' => 'textarea', 'help' => ''),
);
protected static function init() {
self::beforeInsert(function ($event) {
$data = $event->toArray();
$tablename = 'form_' . 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 (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) {
$fields[$key]['form_id'] = $data['id'];
} else {
unset($fields[$key]);
}
}
model('FormAttr')->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('FormAttr')->where('id', 'IN', $value)->setField('group_id', $key);
// foreach ($value as $k => $v) {
// db('FormAttr')->where('id', $v)->setField('sort', $k);
// }
// }
// }
// }
// return true;
// });
}
public function getStatusTextAttr($value, $data) {
$status = array(
0 => '禁用',
1 => '启用',
);
return $status[$data['status']];
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 设置模型
*/
class FormAttr {
protected $type = array(
'id' => 'integer',
);
protected static function init() {
self::afterInsert(function ($data) {
if ($data['form_id']) {
$name = db('Form')->where('id', $data['form_id'])->value('name');
$db = new \com\Datatable();
$attr = $data->toArray();
$model_attr = array(
'form_id' => $data['form_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('FormAttr')->where('name', '<>', $data['name'])->where('form_id', $data['form_id'])->order('id desc')->value('name');
return $db->columField('form_' . strtolower($name), $attr)->query();
}
});
self::beforeUpdate(function ($data) {
$attr = $data->toArray();
$attr['action'] = 'CHANGE';
$attr['oldname'] = db('FormAttr')->where('id', $attr['id'])->value('name');
if ($attr['id']) {
$name = db('Form')->where('id', $attr['form_id'])->value('name');
$db = new \com\Datatable();
return $db->columField('form_' . strtolower($name), $attr)->query();
} else {
return false;
}
});
}
protected function getTypeTextAttr($value, $data) {
$type = config('config_type_list');
$type_text = explode(',', $type[$data['type']]);
return $type_text[0];
}
public function getFieldlist($map, $index = 'id') {
$list = array();
$row = $this->field('*,remark as help,type,extra as "option"')->where($map)->order('group_id asc, sort asc')->select();
foreach ($row as $key => $value) {
if (in_array($value['type'], array('checkbox', 'radio', 'select', 'bool'))) {
$value['option'] = parse_field_attr($value['extra']);
} elseif ($value['type'] == 'bind') {
$extra = parse_field_bind($value['extra']);
$option = array();
foreach ($extra as $k => $v) {
$option[$v['id']] = $v['title_show'];
}
$value['option'] = $option;
}
$list[$value['id']] = $value;
}
return $list;
}
public function del($id, $model_id) {
$map['id'] = $id;
$info = $this->find($id);
$tablename = db('Form')->where(array('id' => $model_id))->value('name');
//先删除字段表内的数据
$result = $this->where($map)->delete();
if ($result) {
$tablename = strtolower($tablename);
//删除模型表中字段
$db = new \com\Datatable();
if (!$db->CheckField($tablename, $info['name'])) {
return true;
}
$result = $db->delField($tablename, $info['name'])->query();
if ($result) {
return true;
} else {
$this->error = "删除失败!";
return false;
}
} else {
$this->error = "删除失败!";
return false;
}
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 友情链接类
* @author molong <molong@tensent.cn>
*/
class Link extends \app\common\model\Base {
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),
array('name' => 'title', 'title' => '友链标题', 'type' => 'text', 'help' => ''),
array('name' => 'url', 'title' => 'URL链接', 'type' => 'text', 'help' => ''),
array('name' => 'ftype', 'title' => '友链类别', 'type' => 'select', 'option' => array(
'1' => '常用链接',
'2' => '网站导读',
'3' => '对公服务',
'4' => '校内服务',
), 'help' => ''),
array('name' => 'cover_id', 'title' => '网站LOGO', 'type' => 'image', 'help' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => array('1' => '启用', '0' => '禁用'), 'help' => ''),
array('name' => 'sort', 'title' => '链接排序', 'type' => 'text', 'help' => ''),
array('name' => 'descrip', 'title' => '描述', 'type' => 'textarea', 'help' => ''),
);
protected $auto = array('update_time');
protected $type = array(
'cover_id' => 'integer',
'sort' => 'integer',
);
}
+192
View File
@@ -0,0 +1,192 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use sent\jwt\facade\JWTAuth;
use think\Model;
use xin\helper\Server;
class Member extends Model {
protected $pk = 'uid';
protected $createTime = 'reg_time';
protected $updateTime = 'last_login_time';
protected $insert = ['reg_ip'];
protected $status = [
1 => '正常',
0 => '禁用',
];
public $loginVisible = ['uid', 'username', 'nickname', 'access_token', 'department']; //用户登录成功返回的字段
protected function getStatusTextAttr($value, $data) {
return isset($this->status[$data['status']]) ? $this->status[$data['status']] : '未知';
}
protected function getAvatarAttr($value, $data) {
return avatar($data['uid']);
}
protected function setPasswordAttr($value, $data) {
return md5($value . $data['salt']);
}
protected function setRegIpAttr($value) {
return Server::getRemoteIp();
}
protected function getAccessTokenAttr($value, $data) {
$token = ['data' => ['uid' => $data['uid'], 'username' => $data['username'], 'password' => $data['password'], 'department' => $data['department']]];
return JWTAuth::builder($token); //参数为用户认证的信息,请自行添加
}
/**
* 用户登录
*/
public function login($request) {
$username = $request->param('username', '');
$password = $request->param('password', '');
$type = $request->param('type', 1);
$map = array();
switch ($type) {
case 1:
$map['username'] = $username;
break;
case 2:
$map['email'] = $username;
break;
case 3:
$map['mobile'] = $username;
break;
default:
$this->error = "参数错误";
return false; //参数错误
}
if (!$username) {
$this->error = "用户名不能为空";
return false;
}
$user = $this->where($map)->find();
if (isset($user['uid']) && $user['uid'] && $user['status']) {
/* 验证用户密码 */
if (md5($password . $user['salt']) === $user['password']) {
/* 更新登录信息 */
$this->record($user);
return $user->append(array('access_token', 'avatar'))->visible($this->loginVisible)->toArray(); //登录成功,返回用户信息
} else {
$this->error = "密码错误";
return false; //密码错误
}
} else {
$this->error = "用户不存在或被禁用";
return false;
}
}
/**
* @title: 注册
*/
public function register($request) {
$data = [];
$data['username'] = $request->param('username', '');
$data['password'] = $request->param('password', '');
$data['repassword'] = $request->param('repassword', '');
$data['email'] = $request->param('email', '');
$data['mobile'] = $request->param('mobile', '');
$data['salt'] = rand_string(6);
$result = self::create($data);
if (false !== $result) {
$user = $this->where('uid', $result->uid)->find();
} else {
$this->error = "注册失败!";
return false;
}
/* 更新登录信息 */
$this->record($user);
return $user->append(array('access_token', 'avatar'))->visible($this->loginVisible)->toArray(); //登录成功,返回用户信息
}
/**
* @title: 获取用户列表
*/
public function getUserList($request) {
$map = array();
$param = $request->param();
$order = "status desc, uid desc";
$map[] = ['status', '>=', 0];
if (isset($param['status']) && $param['status'] != '') {
$map[] = ['status', '=', $param['status']];
}
if (isset($param['department']) && $param['department'] != '') {
$map[] = ['department', '=', $param['department']];
}
if (isset($param['email']) && $param['email'] != '') {
$map[] = ['email', '=', $param['email']];
}
if (isset($param['name']) && $param['name'] != '') {
$map[] = ['username|nickname', 'LIKE', '%' . $param['name'] . '%'];
}
if (isset($param['task_id']) && $param['task_id']) {
$map[] = ['uid', 'IN', function ($query) use ($param) {
$query->name('task_user')->where('task_id', $param['task_id'])->field('user_id');
}];
}
$list = self::with(['depart', 'role'])->field('uid,username,nickname,status,email,mobile,department,reg_time')->where($map)->order($order)->paginate($request->pageConfig);
return $list->append(['avatar', 'status_text'])->toArray();
}
/**
* @title: 获取用户列表
*/
public function getUserDetail($request) {
$uid = $request->param('uid', $request->user['uid']);
if (!$uid) {
return false;
}
$info = $this->where('uid', $uid)->find();
return $info->append(['avatar', 'status_text'])->toArray();
}
/**
* 用户登录信息更新
* @param [type] $user [description]
* @return [type] [description]
*/
public function record($user) {
/* 更新登录信息 */
$data = array(
'uid' => $user['uid'],
'login' => array('inc', '1'),
'last_login_time' => time(),
'last_login_ip' => get_client_ip(1),
);
self::where(array('uid' => $user['uid']))->update($data);
}
public function depart() {
return $this->hasOne('Department', 'id', 'department');
}
public function role() {
return $this->hasOne('RoleAccess', 'uid', 'uid');
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use think\Model;
use xin\helper\Server;
/**
* @title: 用户日志模型
*/
class MemberLog extends Model {
protected $type = [
'param' => 'json',
'visite_time' => 'timestamp',
];
public static function record($request) {
$data = [
'uid' => $request->user['uid'],
'url' => $request->baseUrl(),
'param' => $request->param(),
'method' => $request->method(),
'visite_time' => $request->time(),
'client_ip' => Server::getRemoteIp(),
'create_time' => time(),
];
self::create($data);
}
public function getMemberLogList($request) {
$param = $request->param();
$map = [];
$order = "id desc";
return self::with(['user'])->where($map)->order($order)->paginate($request->pageConfig);
}
public function user() {
return $this->hasOne('Member', 'uid', 'uid')->field('uid,nickname,username');
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 菜单模型类
* @author molong <molong@tensent.cn>
*/
class Menu extends \app\common\model\Base {
protected $type = array(
'id' => 'integer',
);
public function getAuthNodes($type = 'admin') {
$map['type'] = $type;
$rows = $this->db()->field('id,pid,group,title,url')->where($map)->order('id asc')->select();
foreach ($rows as $key => $value) {
$data[$value['id']] = $value;
}
foreach ($data as $key => $value) {
if ($value['pid'] > 0) {
$value['group'] = $data[$value['pid']]['title'] . '管理';
$list[] = $value;
}
}
return $list;
}
}
+120
View File
@@ -0,0 +1,120 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 设置模型
*/
class Module {
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 $type = array(
'id' => 'integer',
'create_time' => 'integer',
'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();
$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;
});
}
protected function setAttributeSortAttr($value) {
return $value ? json_encode($value) : '';
}
public function setNameAttr($value) {
return strtolower($value);
}
public function getStatusTextAttr($value, $data) {
$status = array(
0 => '禁用',
1 => '启用',
);
return $status[$data['status']];
}
public function del() {
$id = input('id', '', 'trim,intval');
$tablename = $this->where('id', $id)->value('name');
//删除数据表
$db = new \com\Datatable();
if ($db->CheckTable($tablename)) {
//检测表是否存在
$result = $db->delTable($tablename)->query();
if (!$result) {
return false;
$this->error = "数据表删除失败!";
}
}
db('Attribute')->where('model_id', $id)->delete(); //删除字段信息
$result = $this->where('id', $id)->delete();
if ($result) {
return true;
} else {
$this->error = "模型删除失败!";
return false;
}
}
public function attribute() {
return $this->hasMany('Attribute');
}
}
+85
View File
@@ -0,0 +1,85 @@
<?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 Record extends \think\Model {
protected $type = [
'new_data' => 'json',
'old_data' => 'json',
'order_num' => 'float'
];
public function getDataList($request) {
$map = [];
$order = "id desc";
$param = $request->param();
if (isset($param['name']) && $param['name'] != '') {
$map[] = ['data_name', 'LIKE', '%' . $param['name'] . '%'];
}
if (isset($param['nickname']) && $param['nickname'] != '') {
$searchUser = db('Member')->where('nickname', $param['nickname'])->field('uid,department')->find();
if ($searchUser) {
$map[] = ['uid', '=', $searchUser['uid']];
}
}
if (isset($param['data']) && count($param['data']) == 2 && $param['data'][0] && $param['data'][1]) {
$data = [strtotime($param['data'][0]), strtotime($param['data'][1])];
$map[] = ['create_time', 'between time', $data];
}
//数据权限
if ($request->user['role']['data_auth'] == 1) {
// 部门数据...
$user = Db::name('Member')->field('uid')
->where('department', $request->user['department'])
->buildSql();
$map[] = ["uid", "EXP", "in " . $user];
} elseif ($request->user['role']['data_auth'] == 2) {
// 个人数据...
$map[] = ['uid', '=', $request->user['uid']];
}
$list = self::with(['member'])->where($map)
->order($order)->paginate($request->pageConfig);
return $list;
}
/**
* title : 添加记录
* param : old 旧数据,new 新数据 type 类型
*/
public function adds($old = array(), $new = array(), $type = 'customer') {
$edit = array(); //修改过的字段
foreach ($new as $key => $value) {
if (isset($old[$key]) && $value != $old[$key]) {
$edit[] = $key;
}
}
if (!empty($edit)) {
$data['data_id'] = $old['id'];
$data['data_name'] = $old['name'];
$data['type'] = $type;
$data['uid'] = session('user_auth.uid');
$data['old_data'] = json_encode($old);
$data['new_data'] = json_encode($new);
$data['fields'] = json_encode($edit);
$data['create_time'] = time();
return $this->insert($data);
}
}
public function member() {
return $this->hasOne('Member', 'uid', 'uid')->field('uid,username,nickname');
}
}
+37
View File
@@ -0,0 +1,37 @@
<?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 Rewrite {
protected $autoWriteTimestamp = true;
public $keyList = array(
array('name' => 'id', 'title' => '标识', 'type' => 'hidden'),
array('name' => 'rule', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'),
array('name' => 'url', 'title' => '规则地址', 'type' => 'text', 'option' => '', 'help' => '规则地址'),
);
/**
* 数据修改
* @return [bool] [是否成功]
*/
public function change() {
$data = \think\Request::instance()->post();
if (isset($data['id']) && $data['id']) {
return $this->validate(true)->save($data, array('id' => $data['id']));
} else {
return $this->validate(true)->save($data);
}
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 角色模型
*/
class Role extends \think\Model {
protected $name = "auth_group";
public $type = [
'api_auth' => 'json',
'component_auth' => 'json',
];
public function getStatusTextAttr($value, $data) {
$status = [1 => '开启', 0 => '禁用'];
return isset($status[$data['status']]) ? $status[$data['status']] : '未知';
}
public function getDataList($request) {
$map = [];
$list = self::where($map)->paginate($request->pageConfig);
return $list;
}
public function getUserAuthInfo($request){
$data = self::where('id', $request->user['role']['group_id'])->find();
return $data;
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 角色模型
*/
class RoleAccess extends \think\Model {
protected $name = "auth_group_access";
public function getStatusTextAttr($value, $data) {
$status = [1 => '开启', 0 => '禁用'];
return isset($status[$data['status']]) ? $status[$data['status']] : '未知';
}
public function getDataList($request) {
$map = [];
$list = self::where($map)->paginate($request->pageConfig);
return $list;
}
public static function getRoleByUid($uid) {
return self::where('uid', $uid)->alias('ra')->field('ra.group_id, r.data_auth,r.api_auth')
->join('auth_group r', 'r.id = ra.group_id')
->find();
}
}
+127
View File
@@ -0,0 +1,127 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 用户模型
*/
class SeoRule {
public $keyList = array(
array('name' => 'id', 'title' => '标识', 'type' => 'hidden'),
array('name' => 'title', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'),
array('name' => 'app', 'title' => '模块名', 'type' => 'select', 'option' => array('*' => '-所有模块-', 'index' => '前台模块', 'user' => '用户中心'), 'help' => '不选表示所有模块'),
array('name' => 'controller', 'title' => '控制器', 'type' => 'text', 'option' => '', 'help' => '不填表示所有控制器'),
array('name' => 'action', 'title' => '方法', 'type' => 'text', 'option' => '', 'help' => '不填表示所有方法'),
array('name' => 'seo_title', 'title' => 'SEO标题', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'),
array('name' => 'seo_keywords', 'title' => 'SEO关键字', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'),
array('name' => 'seo_description', 'title' => 'SEO描述', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => array('0' => '禁用', '1' => '启用'), 'help' => ''),
array('name' => 'sort', 'title' => '排序', 'type' => 'text', 'option' => '', 'help' => ''),
);
protected function setAppAttr($value) {
return $value ? $value : '*';
}
protected function setControllerAttr($value) {
return $value ? $value : '*';
}
protected function setActionAttr($value) {
return (isset($value) && $value) ? $value : '*';
}
protected function getAppAttr($value) {
return $value ? $value : '*';
}
protected function getControllerAttr($value) {
return $value ? $value : '*';
}
protected function getActionAttr($value) {
return (isset($value) && $value) ? $value : '*';
}
protected function getRuleNameAttr($value, $data) {
return $data['app'] . '/' . $data['controller'] . '/' . $data['action'];
}
public function getMetaOfCurrentPage($seo) {
$request = \think\Request::instance();
foreach ($seo as $key => $value) {
if (is_array($value)) {
$seo_to_str[$key] = implode(',', $value);
} else {
$seo_to_str[$key] = $value;
}
}
$result = $this->getMeta($request->module(), $request->controller(), $request->action(), $seo_to_str);
return $result;
}
private function getMeta($module, $controller, $action, $seo) {
//获取相关的规则
$rules = $this->getRelatedRules($module, $controller, $action);
//按照排序计算最终结果
$title = '';
$keywords = '';
$description = '';
$need_seo = 1;
foreach ($rules as $e) {
//如果存在完全匹配的seo配置,则不用程序设置的seo资料
if ($e['app'] && $e['controller'] && $e['action']) {
$need_seo = 0;
}
if (!$title && $e['seo_title']) {
$title = $e['seo_title'];
}
if (!$keywords && $e['seo_keywords']) {
$keywords = $e['seo_keywords'];
}
if (!$description && $e['seo_description']) {
$description = $e['seo_description'];
}
}
if ($need_seo) {
//默认让全站的seo规则优先级小于$this->setTitle等方式设置的规则。
if ($seo['title']) {
$title = $seo['title'];
}
if ($seo['keywords']) {
$keywords = $seo['keywords'];
}
if ($seo['description']) {
$description = $seo['description'];
}
}
//生成结果
$result = array('title' => $title, 'keywords' => $keywords, 'description' => $description);
//返回结果
return $result;
}
private function getRelatedRules($module, $controller, $action) {
//查询与当前页面相关的SEO规则
$rules = $this->where('app', ['=', '*'], ['=', $module], 'or')
->where('controller', ['=', '*'], ['=', $controller], 'or')
->where('action', ['=', '*'], ['=', $action], 'or')
->where('status', 1)
->order('sort asc')
->select();
//返回规则列表
return $rules;
}
}
+4 -1
View File
@@ -26,7 +26,10 @@
"topthink/think-trace": "^1.2", "topthink/think-trace": "^1.2",
"topthink/think-view": "^1.0", "topthink/think-view": "^1.0",
"liliuwei/thinkphp-jump": "^1.4", "liliuwei/thinkphp-jump": "^1.4",
"sent/think-auth": "^1.2" "sent/think-auth": "^1.2",
"topthink/think-captcha": "^3.0",
"sent/think-jwt": "^1.0",
"xin/helper": "^1.0"
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "^4.2" "symfony/var-dumper": "^4.2"
Generated
+198 -1
View File
@@ -4,8 +4,69 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "bc799912065c7abf43fc4d8bfb666e95", "content-hash": "0476987d328bafb722d7dd0d63579fa8",
"packages": [ "packages": [
{
"name": "lcobucci/jwt",
"version": "3.3.1",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/jwt.git",
"reference": "a11ec5f4b4d75d1fcd04e133dede4c317aac9e18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/a11ec5f4b4d75d1fcd04e133dede4c317aac9e18",
"reference": "a11ec5f4b4d75d1fcd04e133dede4c317aac9e18",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-mbstring": "*",
"ext-openssl": "*",
"php": "^5.6 || ^7.0"
},
"require-dev": {
"mikey179/vfsstream": "~1.5",
"phpmd/phpmd": "~2.2",
"phpunit/php-invoker": "~1.1",
"phpunit/phpunit": "^5.7 || ^7.3",
"squizlabs/php_codesniffer": "~2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Lcobucci\\JWT\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Luís Otávio Cobucci Oblonczyk",
"email": "lcobucci@gmail.com",
"role": "Developer"
}
],
"description": "A simple library to work with JSON Web Token and JSON Web Signature",
"keywords": [
"JWS",
"jwt"
],
"time": "2019-05-24T18:30:49+00:00"
},
{ {
"name": "league/flysystem", "name": "league/flysystem",
"version": "1.0.64", "version": "1.0.64",
@@ -530,6 +591,51 @@
"description": "thinkphp 权限类", "description": "thinkphp 权限类",
"time": "2020-02-17T11:17:11+00:00" "time": "2020-02-17T11:17:11+00:00"
}, },
{
"name": "sent/think-jwt",
"version": "v1.0.1",
"source": {
"type": "git",
"url": "https://gitee.com/sentcms/think-jwt",
"reference": "12c66c87b5009d632e2705352d0e032df8b052d8"
},
"require": {
"lcobucci/jwt": "^3.3",
"php": "^7.0",
"topthink/framework": "^5.1.10 || ^6.0.0"
},
"type": "library",
"extra": {
"think": {
"services": [
"sent\\jwt\\Service"
],
"config": {
"jwt": "config/config.php"
}
}
},
"autoload": {
"psr-4": {
"sent\\jwt\\": "src"
},
"files": [
"src/helper.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "molong",
"email": "molong@tensent.cn"
}
],
"description": "thinkphp jwt auth composer",
"time": "2019-11-19T07:11:50+00:00"
},
{ {
"name": "topthink/framework", "name": "topthink/framework",
"version": "v6.0.2", "version": "v6.0.2",
@@ -598,6 +704,61 @@
], ],
"time": "2020-01-13T05:48:05+00:00" "time": "2020-01-13T05:48:05+00:00"
}, },
{
"name": "topthink/think-captcha",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-captcha.git",
"reference": "0b4305da19e118cefd934007875a8112f9352f01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/0b4305da19e118cefd934007875a8112f9352f01",
"reference": "0b4305da19e118cefd934007875a8112f9352f01",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"topthink/framework": "^6.0.0"
},
"type": "library",
"extra": {
"think": {
"services": [
"think\\captcha\\CaptchaService"
],
"config": {
"captcha": "src/config.php"
}
}
},
"autoload": {
"psr-4": {
"think\\captcha\\": "src/"
},
"files": [
"src/helper.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "yunwuxin",
"email": "448901948@qq.com"
}
],
"description": "captcha package for thinkphp",
"time": "2019-10-03T07:45:11+00:00"
},
{ {
"name": "topthink/think-helper", "name": "topthink/think-helper",
"version": "v3.1.3", "version": "v3.1.3",
@@ -832,6 +993,42 @@
], ],
"description": "thinkphp template driver", "description": "thinkphp template driver",
"time": "2019-11-06T11:40:13+00:00" "time": "2019-11-06T11:40:13+00:00"
},
{
"name": "xin/helper",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://gitee.com/liuxiaojinla/php-helper",
"reference": "02a58132dae2aea2d1c0b8e66f55125969224747"
},
"require": {
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-simplexml": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"xin\\helper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "晋",
"email": "1540175452@qq.com"
}
],
"description": "PHP项目日常开发必备基础库,数组工具类、字符串工具类、数字工具类、函数工具类、服务器工具类、加密工具类",
"time": "2019-06-22T08:28:23+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
+39
View File
@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | Captcha配置文件
// +----------------------------------------------------------------------
return [
//验证码位数
'length' => 4,
// 验证码字符集合
'codeSet' => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',
// 验证码过期时间
'expire' => 1800,
// 是否使用中文验证码
'useZh' => false,
// 是否使用算术验证码
'math' => false,
// 是否使用背景图
'useImgBg' => false,
//验证码字符大小
'fontSize' => 25,
// 是否使用混淆曲线
'useCurve' => true,
//是否添加杂点
'useNoise' => true,
// 验证码字体 不设置则随机
'fontttf' => '',
//背景颜色
'bg' => [243, 251, 254],
// 验证码图片高度
'imageH' => 0,
// 验证码图片宽度
'imageW' => 0,
// 添加额外的验证码设置
// verify => [
// 'length'=>4,
// ...
//],
];
+17
View File
@@ -0,0 +1,17 @@
<?php
return [
'secret' => env('JWT_SECRET'),
//Asymmetric key
'public_key' => env('JWT_PUBLIC_KEY'),
'private_key' => env('JWT_PRIVATE_KEY'),
'password' => env('JWT_PASSWORD'),
//JWT time to live
'ttl' => env('JWT_TTL', 60),
//Refresh time to live
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
//JWT hashing algorithm
'algo' => env('JWT_ALGO', 'HS256'),
'blacklist_storage' => sent\jwt\provider\storage\Tp6::class,
];
+40
View File
@@ -0,0 +1,40 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SentCMS网站管理系统</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0;}
.full-height {height: 100vh;}
.flex-center {align-items: center;display: flex;justify-content: center;}
.position-ref {position: relative;}
.top-right {position: absolute;right: 10px;top: 18px;}
.content {text-align: center;}
.title {font-size: 84px;}
.links > a {color: #636b6f;padding: 0 25px; font-size: 12px;font-weight: 600;letter-spacing: .1rem;text-decoration: none;text-transform: uppercase;}
.m-b-md {margin-bottom: 30px;}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
SentCMS网站管理系统
</div>
<div class="links">
<a href="https://www.kancloud.cn/tensent/sentcms3/169624" target="_blank">文档</a>
<a href="https://www.tensent.cn" target="_blank">资讯</a>
<a href="https://gitee.com/sentcms/sentcms" target="_blank">Gitee</a>
<a href="{:url('admin.index/index')}" target="_blank">后台管理</a>
</div>
</div>
</div>
</body>
</html>
+39
View File
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SentCMS网站管理系统</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0;}
.full-height {height: 100vh;}
.flex-center {align-items: center;display: flex;justify-content: center;}
.position-ref {position: relative;}
.top-right {position: absolute;right: 10px;top: 18px;}
.content {text-align: center;}
.title {font-size: 84px;}
.links > a {color: #636b6f;padding: 0 25px; font-size: 12px;font-weight: 600;letter-spacing: .1rem;text-decoration: none;text-transform: uppercase;}
.m-b-md {margin-bottom: 30px;}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
404 Not Found!
</div>
<div class="links">
<a href="https://www.kancloud.cn/tensent/sentcms3/169624" target="_blank">文档</a>
<a href="https://www.tensent.cn" target="_blank">资讯</a>
<a href="https://gitee.com/sentcms/sentcms" target="_blank">Gitee</a>
</div>
</div>
</div>
</body>
</html>
+32
View File
@@ -0,0 +1,32 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
<header class="main-box-header clearfix">
<!-- 标题栏 -->
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<table class="table table-striped">
<thead>
<tr>
<th align="right">名称</th>
<th>信息</th>
</tr>
</thead>
<tbody>
{volist name="info" id="item"}
<tr>
<td align="right">{$key}</td>
<td>{$item}</td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
{/block}
+67
View File
@@ -0,0 +1,67 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
<header class="main-box-header clearfix">
<!-- 标题栏 -->
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" id="action_add" href="{:url('add')}">新 增</a>
<button class="btn btn-success ajax-post" target-form="ids" url="{:url('setstatus?status=1')}" >启 用</button>
<button class="btn btn-default ajax-post" target-form="ids" url="{:url('setstatus?status=0')}">禁 用</button>
<button class="btn btn-danger ajax-post confirm" target-form="ids" url="{:url('del')}">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<!-- 数据列表 -->
<table class="table table-striped">
<thead>
<tr>
<th class="row-selected row-selected">
<input class="check-all" type="checkbox"/>
</th>
<th class="">编号</th>
<th class="">标识</th>
<th class="">名称</th>
<th class="">类型</th>
<th class="">规则</th>
<th class="">状态</th>
<th class="">操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="vo"}
<tr>
<td>
<input class="ids" type="checkbox" name="id[]" value="{$vo['id']}" />
</td>
<td>{$vo.id}</td>
<td>{$vo.name}</td>
<td>
<a href="{:url('edit?id='.$vo['id'])}">{$vo.title}</a>
</td>
<td>
<span>{:get_action_type($vo['type'])}</span>
</td>
<td>{$vo.remark}</td>
<td>{$vo.status_text}</td>
<td>
<a href="{:url('edit?id='.$vo['id'])}">编辑</a>
{if $vo['status']}
<a href="{:url('setstatus',array('id'=> $vo['id'],'status'=>0))}" class="ajax-get">禁用</a>
{else/}
<a href="{:url('setstatus',array('id'=> $vo['id'],'status'=>1))}" class="ajax-get">启用</a>
{/if}
<a href="{:url('del' , array('id' => $vo['id']))}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
<!-- 分页 -->
{$page}
<!-- /分页 -->
</div>
</div>
{/block}
+49
View File
@@ -0,0 +1,49 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
<header class="main-box-header clearfix">
<!-- 标题栏 -->
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-warning ajax-get confirm" href="{:url('clear')}">清 空</a>
<button class="btn btn-danger ajax-post confirm" target-form="ids" url="{:url('dellog')}">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<!-- 数据列表 -->
<table class="table table-striped">
<thead>
<tr>
<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
<th class="">编号</th>
<th class="">行为名称</th>
<th class="">执行者</th>
<th class="">执行时间</th>
<th class="">操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="vo"}
<tr>
<td><input class="ids" type="checkbox" name="id[]" value="{$vo['id']}" /></td>
<td>{$vo['id']} </td>
<td>{:get_action($vo['action_id'],'title')}</td>
<td>{:get_nickname($vo['user_id'])}</td>
<td><span>{$vo.create_time|time_format}</span></td>
<td><a href="{:url('detail?id='.$vo['id'])}">详细</a>
<a class="confirm ajax-get" href="{:url('dellog?id='.$vo['id'])}">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
<!-- 分页 -->
{$page}
<!-- /分页 -->
</div>
</div>
{/block}
+80
View File
@@ -0,0 +1,80 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<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('del')}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th width="180">名称</th>
<th width="140">标识</th>
<th width="180">创建时间</th>
<th width="180">更新时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['name']}</td>
<td>{$item['create_time']|date='Y-m-d H:i',###}</td>
<td>{$item['update_time']|date='Y-m-d H:i',###}</td>
<td>
<a title="广告列表" href="{:url('lists?id='.$item['id'])}">广告列表</a>
<a title="移动" href="{:url('edit?id='.$item['id'])}">编辑</a>
<a title="删除" href="{:url('del?id='.$item['id'])}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function() {
//点击排序
$('.item_sort').click(function(){
var url = $(this).attr('url');
var ids = $('.ids:checked');
var param = '';
if(ids.length > 0){
var str = new Array();
ids.each(function(){
str.push($(this).val());
});
param = str.join(',');
}
if(url != undefined && url != ''){
window.location.href = url + '/ids/' + param;
}
});
$.fn.editable.defaults.mode = 'popup';
$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
$('.editable').editable();
});
</script>
{/block}
+50
View File
@@ -0,0 +1,50 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box no-header clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-success" href="{:url('addad?id='.$id)}"><i class="fa fa-plus-circle fa-lg"></i> 新 增</a>
<a class="btn btn-primary" href="{:url('index')}"><i class="fa fa-list fa-lg"></i> 广告位</a>
</div>
</header>
<div class="main-box-body clearfix">
<!-- 表格列表 -->
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th width="280">标题</th>
<th width="280">创建时间</th>
<th width="280">更新时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item.id}"></td>
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['create_time']|date='Y-m-d H:i',###}</td>
<td>{$item['update_time']|date='Y-m-d H:i',###}</td>
<td>
<a href="{:url('editad?id='.$item['id'])}">编辑</a>
<a href="{:url('delad?id='.$item['id'])}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
<!-- /表格列表 -->
</div>
</div>
{/block}
+78
View File
@@ -0,0 +1,78 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<form method="post" class="form form-horizontal">
<div class="form-group">
<label class="col-lg-2 control-label">插件名</label>
<div class="col-lg-8 col-sm-10">
{:widget('common/Form/show',array(array('name'=>'title','title'=>'插件名','type'=>'text'),''))}
<div class="help-block">请输入插件名</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">插件标识名</label>
<div class="col-lg-8 col-sm-10">
{:widget('common/Form/show',array(array('name'=>'name','title'=>'插件标识名','type'=>'text'),''))}
<div class="help-block">请输入插件标识</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">插件版本</label>
<div class="col-lg-8 col-sm-10">
{:widget('common/Form/show',array(array('name'=>'version','title'=>'插件版本','type'=>'text'),''))}
<div class="help-block">请输入插件版本</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">插件作者</label>
<div class="col-lg-8 col-sm-10">
{:widget('common/Form/show',array(array('name'=>'author','title'=>'插件作者','type'=>'text'),''))}
<div class="help-block">请输入插件作者</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">插件描述</label>
<div class="col-lg-8 col-sm-10">
{:widget('common/Form/show',array(array('name'=>'description','title'=>'插件描述','type'=>'textarea'),''))}
<div class="help-block">请输入插件描述</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">是否启用</label>
<div class="col-lg-8 col-sm-10">
{:widget('common/Form/show',array(array('name'=>'is_open','title'=>'是否启用','type'=>'radio','option'=>array('1'=>'启用','0'=>'禁用')),''))}
<div class="help-block">请输入插件描述</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">是否需要配置</label>
<div class="col-lg-8 col-sm-10">
{:widget('common/Form/show',array(array('name'=>'has_config','title'=>'是否需要配置','type'=>'radio','option'=>array('1'=>'启用','0'=>'禁用')),''))}
<div class="help-block">请输入插件描述</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$info['id']|default=''}">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-primary submit-btn" type="button">预 览</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
{block name="script"}
{/block}
+38
View File
@@ -0,0 +1,38 @@
<?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 addons\[name];
use common\controller\Addon;
/**
* [title]插件
* @author [author]
*/
class [name] extends Addon{
public $info = array(
'name'=>'[name]',
'title'=>'[title]',
'description'=>'[description]',
'status'=>[status],
'author'=>'[author]',
'version'=>'[version]'
);
//
public function install(){
return true;
}
public function uninstall(){
return true;
}
[hook]
}
+77
View File
@@ -0,0 +1,77 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{:url('addhook')}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('delhook')}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th><input class="checkbox check-all" type="checkbox"></th>
<th>ID</th>
<th>名称</th>
<th>描述</th>
<th>类型</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$item['id']}"></td>
<td>{$item['id']|default=0}</td>
<td>{$item['name']}</td>
<td>{$item['description']}</td>
<td>{$item['type_text']}</td>
<td>
<a href="{:url('edithook?id='.$item['id'])}">编辑</a>
<a href="{:url('delhook?id='.$item['id'])}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function() {
//点击排序
$('.item_sort').click(function(){
var url = $(this).attr('url');
var ids = $('.ids:checked');
var param = '';
if(ids.length > 0){
var str = new Array();
ids.each(function(){
str.push($(this).val());
});
param = str.join(',');
}
if(url != undefined && url != ''){
window.location.href = url + '/ids/' + param;
}
});
$.fn.editable.defaults.mode = 'popup';
$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
$('.editable').editable();
});
</script>
{/block}
+93
View File
@@ -0,0 +1,93 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-info" href="{:url('index?refresh=1')}">更 新</a>
<a class="btn btn-primary" href="{:url('add')}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th><input class="checkbox check-all" type="checkbox"></th>
<th>ID</th>
<th>名称</th>
<th>标识</th>
<th>描述</th>
<th>状态</th>
<th>作者</th>
<th>版本</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
<td>{$item['id']|default=0}</td>
<td>{$item['title']}</td>
<td>{$item['name']}</td>
<td>{$item['description']}</td>
<td>{$item['status_text']}</td>
<td>{$item['author']}</td>
<td>{$item['version']}</td>
<td>
{if !$item['isinstall']}
<a href="{:url('install?addon_name='.$item['name'])}" class="ajax-get">安装</a>
{else/}
<a href="{:url('uninstall?id='.$item['id'])}" class="confirm ajax-get">卸载</a>
{if $item['status']}
<a href="{:url('disable?id='.$item['id'])}" class="confirm ajax-get">禁用</a>
{else/}
<a href="{:url('enable?id='.$item['id'])}" class="confirm ajax-get">启用</a>
{/if}
<a href="{:url('config?id='.$item['id'])}">设置</a>
{/if}
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function() {
//点击排序
$('.item_sort').click(function(){
var url = $(this).attr('url');
var ids = $('.ids:checked');
var param = '';
if(ids.length > 0){
var str = new Array();
ids.each(function(){
str.push($(this).val());
});
param = str.join(',');
}
if(url != undefined && url != ''){
window.location.href = url + '/ids/' + param;
}
});
$.fn.editable.defaults.mode = 'popup';
$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
$('.editable').editable();
});
</script>
{/block}
+64
View File
@@ -0,0 +1,64 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-danger" href="{:url('add',array('model_id'=>$model_id))}"><i class="fa fa-plus"></i> 新 增</a>
<!-- <button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids"><i class="fa fa-remove"></i> 删 除</button> -->
<a class="btn btn-warning" href="{:url('Model/index')}"><i class="fa fa-reply"></i> 返回</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th><input class="checkbox check-all" type="checkbox"></th>
<th>表单标题</th>
<th>字段名</th>
<th>字段类型</th>
<th>字段长度</th>
<th>默认值</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
<td>{$item['title']}</td>
<td>{$item['name']}</td>
<td>{$item['type_text']}</td>
<td>{$item['length']}</td>
<td>{$item['value']}</td>
<td>
<a href="{:url('edit',array('id'=>$item['id'], 'model_id'=>$model_id))}">编辑</a>
<a href="{:url('del',array('id'=>$item['id'], 'model_id'=>$model_id))}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
<script type="text/javascript">
$(function(){
$('.openDilog').click(function(){
layer.open({
type: 2,
title: false,
area: ['900px', '560px'],
content: $('.openDilog').attr('url')
});
});
})
</script>
{/block}
+192
View File
@@ -0,0 +1,192 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{:isset($info['id'])?'编辑':'新增'}分类</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form action="{:url()}" method="post" class="form form-horizontal">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
<li class="active">
<a href="#tab-base" data-toggle="tab">基 础</a>
</li>
<li><a href="#tab-better" data-toggle="tab">高 级</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="tab-base">
<div class="form-group">
<label class="col-lg-2 control-label">上级分类</label>
<div class="col-lg-8">
<input type="hidden" name="pid" value="{$category['id']|default=0}">
<input type="text" class="form-control" disabled="disabled" value="{$category['title']|default='无'}"/>
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">分类名称</label>
<div class="col-lg-8">
<input type="text" name="title" class="form-control" value="{$info.title|default=''}">
<span class="help-block">(名称不能为空)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">分类标识</label>
<div class="col-lg-8">
<input type="text" name="name" class="form-control" value="{$info.name|default=''}">
<span class="help-block">(英文字母)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">分组定义</label>
<div class="col-lg-8">
<textarea name="groups" class="form-control">{$info.groups|default=''}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">绑定模型</label>
<div class="col-lg-8">
<select name="model_id" class="form-control" style="width: auto;">
<option value="">--请选择--</option>
{volist name="model_list" id="item"}
<option value="{$item['id']}" {if isset($info['model_id']) && $info['model_id'] == $item['id']}selected{/if}>{$item['title']}</option>
{/volist}
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">发布内容</label>
<div class="col-lg-8">
<label class="am-radio-inline"><input type="radio" name="allow_publish" value="0">不允许</label>
<label class="am-radio-inline"><input type="radio" name="allow_publish" value="1" checked>仅允许后台</label>
<label class="am-radio-inline"><input type="radio" name="allow_publish" value="2" >允许前后台</label>
<span class="help-block">(是否允许发布内容)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">
是否审核
</label>
<div class="col-lg-8">
<label class="am-radio-inline"><input type="radio" name="check" value="0" checked>不需要</label>
<label class="am-radio-inline"><input type="radio" name="check" value="1">需要</label>
<span class="help-block">(在该分类下发布的内容是否需要审核)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">分类图标</label>
<div class="col-lg-8">
{:widget('common/Form/show',array(array('name'=>'icon','type'=>'image'),$info))}
</div>
</div>
</div>
<div class="tab-pane fade" id="tab-better">
<div class="form-group">
<label class="col-lg-2 control-label">可见性</label>
<div class="col-lg-3">
<select name="display" class="form-control">
<option value="1">所有人可见</option>
<option value="0">不可见</option>
<option value="2">管理员可见</option>
</select>
<span class="help-block">(是否对用户可见,针对前台)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">排序</label>
<div class="col-lg-2">
<input type="text" name="sort" class="form-control" value="{$info.sort|default=0}">
<span class="help-block">(仅对当前层级分类有效)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">列表行数</label>
<div class="col-lg-5">
<input type="text" name="list_row" class="form-control" value="{$info.list_row|default=10}">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">网页标题</label>
<div class="col-lg-8">
<input type="text" name="meta_title" class="form-control" value="{$info.meta_title|default=''}">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">关键字</label>
<div class="col-lg-8">
<textarea class="form-control" name="keywords">{$info.keywords|default=''}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">描述</label>
<div class="col-lg-8">
<textarea class="form-control" name="description">{$info.description|default=''}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">频道模板</label>
<div class="col-lg-8">
<input type="text" name="template_index" class="form-control" value="{$info.template_index|default=''}">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">列表模板</label>
<div class="col-lg-8">
<input type="text" name="template_lists" class="form-control" value="{$info.template_lists|default=''}">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">详情模板</label>
<div class="col-lg-8">
<input type="text" name="template_detail" class="form-control" value="{$info.template_detail|default=''}">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">编辑模板</label>
<div class="col-lg-8">
<input type="text" name="template_edit" class="form-control" value="{$info.template_edit|default=''}">
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$info['id']|default=''}">
<button type="submit" class="btn btn-success submit-btn ajax-post" target-form="form">确认提交</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
{block name="script"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/webuploader/webuploader.css">
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.custom.js"></script>
<script type="text/javascript">
{present name="info['id']"}
Sent.setValue("allow_publish", {$info.allow_publish|default=1});
Sent.setValue("check", {$info.check|default=0});
Sent.setValue("model[]", {$info.model|json_encode} || [1]);
Sent.setValue("model_sub[]", {$info.model_sub|json_encode} || [1]);
Sent.setValue("type[]", {$info.type|json_encode} || [2]);
Sent.setValue("display", {$info.display|default=1});
Sent.setValue("reply", {$info.reply|default=0});
Sent.setValue("reply_model[]", {$info.reply_model|json_encode} || [1]);
{/present}
$(function(){
$("input[name=reply]").change(function(){
var $reply = $(".form-group.reply");
parseInt(this.value) ? $reply.show() : $reply.hide();
}).filter(":checked").change();
});
</script>
{/block}
+114
View File
@@ -0,0 +1,114 @@
{extend name="public/base"/}
{block name="body"}
<!-- datepicker end -->
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>
生成到导航
</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form method="post" class="form form-horizontal">
<div class="form-group">
<label class="col-lg-2 control-label">导航标题</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="title" value="{$info.title|default=''}">
<span class="help-block">(用于显示的文字)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">当前标识</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="active" value="{$info.active|default=''}">
<span class="help-block">(当前标识)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">导航连接</label>
<div class="col-lg-8">
<input type="text" class="form-control" name="url" value="{$info.url|default=''}">
<span class="help-block">(用于调转的URL,支持带http://的URL或U函数参数格式)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">导航类型</label>
<div class="col-lg-8">
<select name="type" id="type" class="form-control" style="width:auto;">
{volist name=":config('nav_type_list')" id="item"}
<option value="{$key}" {if isset($info['type']) && $info['type'] == $key}selected{/if}>{$item}</option>
{/volist}
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">父导航</label>
<div class="col-lg-5">
<select name="pid" class="form-control" style="width:auto;">
<option value="0">--一级导航--</option>
{volist name=":parse_field_bind('Channel',$data['pid'],'')" id="item"}
{if condition="$item['id'] neq $data['id']"}
<option value="{$item['id']}" {if condition="$pid eq $item['id']"}selected{/if}>{$item['title_show']}</option>
{/if}
{/volist}
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">新窗口打开</label>
<div class="col-lg-2">
<select name="target" class="form-control" style="width:auto;">
<option value="0" ></option>
<option value="1" {eq name="data.target" value="1"}selected{/eq}></option>
</select>
<span class="help-block">(是否新窗口打开链接)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">图标</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="icon" value="{$info.icon|default=''}">
<span class="help-block">输入图标英文</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">优先级</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="sort" value="{$info.sort|default='1'}">
<span class="help-block">(导航显示顺序)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">文字颜色</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="color" value="{$info['color']|default=''}">
<span class="help-block">(右上角的标志点颜色,支持各类css表示方式)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">标志点颜色</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="band_color" value="{$info['band_color']|default=''}">
<span class="help-block">(右上角的标志点颜色,支持各类css表示方式)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">标志点文字</label>
<div class="col-lg-3">
<input type="text" class="form-control" name="band_text" value="{$info['band_text']|default=''}">
<span class="help-block">(右上角的标志点文字,不要太长,没有自动隐藏)</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$data.id|default=''}">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+103
View File
@@ -0,0 +1,103 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box no-header clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{:url('add')}"><i class="fa fa-plus-circle fa-lg"></i> 新 增</a>
</div>
</header>
<div class="main-box-body clearfix">
<!-- 表格列表 -->
<div class="table-responsive clearfix">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
<li {if $model_id == ''}class="active"{/if}><a href="{:url('admin/category/index')}">全部</a></li>
{volist name="model_list" id="item"}
<li {if $item['id'] == $model_id}class="active"{/if}>
<a href="{:url('admin/category/index',array('model_id'=>$item['id']))}">{$item['title']}</a>
</li>
{/volist}
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="tab-home">
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th>名称</th>
<th width="120">排序</th>
<th width="120">发布</th>
<th width="120">状态</th>
<th width="120">生成导航</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="tree" id="list"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$list.id}"></td>
<td>{$list['id']}</td>
<td>
{$list['level_show']}
<a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="title" data-type="text" data-pk="{$list['id']}" data-url="{:url('editable')}">{$list['title']}</a>
<a class="add-sub-cate" title="添加子分类" href="{:url('add?pid='.$list['id'])}">
<i class="fa fa-plus-square"></i>
</a>
</td>
<td><a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="sort" data-type="text" data-pk="{$list['id']}" data-url="{:url('editable')}">{$list['sort']}</a></td>
<td>{$list['allow_publish']?'是':'否'}</td>
<td>
{if $list['status']}
<span class="label label-primary">启用</span>
{else/}
<span class="label label-danger">禁用</span>
{/if}
</td>
<td>
{if $list['ismenu']}
<a href="{:url('admin/channel/del?id='.$list['ismenu'])}" class="ajax-get"><span class="label label-primary">已生成</span></a>
{else/}
<a href="{:url('add_channel?title='.$list['title'].'&model_id='.$list['model_id'].'&active='.$list['name'].'&mid='.$list['id'])}" ><span class="label label-danger">未生成</span></a>
{/if}
</td>
<td>
<a title="编辑" href="{:url('edit?id='.$list['id'].'&pid='.$list['pid'])}">编辑</a>
{if $list['status']}
<a href="{:url('status?id='.$list['id'].'&status=0')}" class="ajax-get">禁用</a>
{else/}
<a href="{:url('status?id='.$list['id'].'&status=1')}" class="ajax-get">启用</a>
{/if}
<a title="删除" href="{:url('remove?id='.$list['id'])}" class="confirm ajax-get">删除</a>
<a title="移动" href="{:url('operate?type=move&from='.$list['id'])}">移动</a>
<a title="合并" href="{:url('operate?type=merge&from='.$list['id'])}">合并</a>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /表格列表 -->
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function(){
$.fn.editable.defaults.mode = 'popup';
$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
$('.editable').editable();
})
</script>
{/block}
+37
View File
@@ -0,0 +1,37 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$operate}分类</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form action="{:url($type)}" method="post" class="form form-horizontal">
<div id="tab1" class="tab-pane in tab1">
<div class="form-group">
<label class="col-lg-2 control-label">目标分类</label>
<div class="col-lg-5">
<select name="to" class="form-control">
{volist name="list" id="vo"}
<option value="{$vo.id}">{$vo.title}</option>
{/volist}
</select>
<span class="help-block">(将{$operate}至的分类)</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="from" value="{$from}">
<button type="submit" class="btn btn-success submit-btn ajax-post" target-form="form">确认提交</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+114
View File
@@ -0,0 +1,114 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>
{$info['id']?'编辑':'新增'}导航
</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form method="post" class="form form-horizontal">
<div class="form-group">
<label class="col-lg-2 control-label">导航标题</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="title" value="{$info.title|default=''}">
<span class="help-block">(用于显示的文字)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">当前标识</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="active" value="{$info.active|default=''}">
<span class="help-block">(当前标识)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">导航连接</label>
<div class="col-lg-8">
<input type="text" class="form-control" name="url" value="{$info.url|default=''}">
<span class="help-block">(用于调转的URL,支持带http://的URL或U函数参数格式)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">导航类型</label>
<div class="col-lg-8">
<select name="type" id="type" class="form-control" style="width:auto;">
{volist name=":config('nav_type_list')" id="item"}
<option value="{$key}" {if isset($info['type']) && $info['type'] == $key}selected{/if}>{$item}</option>
{/volist}
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">父导航</label>
<div class="col-lg-5">
<select name="pid" class="form-control" style="width:auto;">
<option value="0">--一级导航--</option>
{volist name=":parse_field_bind('Channel',$info['pid'], 0)" id="item"}
{if condition="$item['id'] neq $info['id']"}
<option value="{$item['id']}" {if condition="$pid eq $item['id']"}selected{/if}>{$item['title_show']}</option>
{/if}
{/volist}
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">新窗口打开</label>
<div class="col-lg-2">
<select name="target" class="form-control" style="width:auto;">
<option value="0" ></option>
<option value="1" {eq name="info.target" value="1"}selected{/eq}>
</option>
</select>
<span class="help-block">(是否新窗口打开链接)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">图标</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="icon" value="{$info.icon|default=''}">
<span class="help-block">输入图标英文</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">优先级</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="sort" value="{$info.sort|default='1'}">
<span class="help-block">(导航显示顺序)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">文字颜色</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="color" value="{$info['color']|default=''}">
<span class="help-block">(右上角的标志点颜色,支持各类css表示方式)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">标志点颜色</label>
<div class="col-lg-2">
<input type="text" class="form-control" name="band_color" value="{$info['band_color']|default=''}">
<span class="help-block">(右上角的标志点颜色,支持各类css表示方式)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">标志点文字</label>
<div class="col-lg-3">
<input type="text" class="form-control" name="band_text" value="{$info['band_text']|default=''}">
<span class="help-block">(右上角的标志点文字,不要太长,没有自动隐藏)</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$info.id|default=''}">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+106
View File
@@ -0,0 +1,106 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<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('del')}" target-form="ids">删 除</button>
<button class="btn btn-success list_sort" url="{:url('sort')}">排序</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
<li {if 0 eq $type}class="active"{/if}><a href="{:url('admin/channel/index',array('type'=>0))}">全部</a></li>
{volist name=":config('nav_type_list')" id="item"}
<li {if $key eq $type}class="active"{/if}>
<a href="{:url('admin/channel/index',array('type'=>$key))}">{$item}</a>
</li>
{/volist}
</ul>
<div class="tab-content">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th>名称</th>
<th>URL</th>
<th width="120">排序</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="tree" id="list"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$list.id}"></td>
<td>{$list['id']}</td>
<td>
{$list['level_show']}
<a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="title" data-type="text" data-pk="{$list['id']}" data-url="{:url('editable')}">{$list['title']} </a>
<a class="add-sub-cate" title="添加子分类" href="{:url('add?pid='.$list['id'])}">
<i class="fa fa-plus-square"></i>
</a>
</td>
<td>{$list['url']}</td>
<td><a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="sort" data-type="text" data-pk="{$list['id']}" data-url="{:url('editable')}">{$list['sort']}</a></td>
<td>
{if $list['status']}
<span class="label label-primary">{$list.status|get_status_title}</span>
{else/}
<span class="label label-danger">{$list.status|get_status_title}</span>
{/if}
</td>
<td>
<a title="编辑" href="{:url('edit?id='.$list['id'].'&pid='.$list['pid'])}">编辑</a>
<a title="{$list.status|show_status_op}" href="{:url('setStatus?ids='.$list['id'].'&status='.abs(1-$list['status']))}" class="ajax-get">{$list.status|show_status_op}</a>
<a title="删除" href="{:url('del?id='.$list['id'])}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function() {
//点击排序
$('.list_sort').click(function(){
var url = $(this).attr('url');
var ids = $('.ids:checked');
var param = '';
if(ids.length > 0){
var str = new Array();
ids.each(function(){
str.push($(this).val());
});
param = str.join(',');
}
if(url != undefined && url != ''){
window.location.href = url + '/ids/' + param;
}
});
$.fn.editable.defaults.mode = 'popup';
$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
$('.editable').editable();
});
</script>
{/block}
+112
View File
@@ -0,0 +1,112 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>菜单排序 [ <a href="{:url('index',array('pid'=>input('pid')))}">返回列表</a> ]</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form action="{:url('sort')}" method="post" class="form form-horizontal">
<div class="form-group">
<div class="col-lg-2">
<select value="" size="8" class="form-control">
{volist name="list" id="vo"}
<option class="ids" title="{$vo.title}" value="{$vo.id}">{$vo.title}</option>
{/volist}
</select>
</div>
<div class="col-lg-2">
<button class="top btn btn-primary btn-block" type="button"><i class="fa fa-arrow-up"></i> 第 一</button>
<button class="up btn btn-primary btn-block" type="button"><i class="fa fa-chevron-up"></i> 上 移</button>
<button class="down btn btn-primary btn-block" type="button"><i class="fa fa-chevron-down"></i> 下 移</button>
<button class="bottom btn btn-primary btn-block" type="button"><i class="fa fa-arrow-down"></i> 最 后</button>
</div>
</div>
<div class="sort_bottom form-group">
<div class="col-lg-12">
<input type="hidden" name="ids">
<button class="sort_confirm btn btn-primary submit-btn" type="button">确 定</button>&nbsp;
<button class="sort_cancel btn btn-dafault btn-return" type="button" url="{$Think.cookie.__forward__}">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
$(function(){
sort();
$(".top").click(function(){
rest();
$("option:selected").prependTo("select");
sort();
})
$(".bottom").click(function(){
rest();
$("option:selected").appendTo("select");
sort();
})
$(".up").click(function(){
rest();
$("option:selected").after($("option:selected").prev());
sort();
})
$(".down").click(function(){
rest();
$("option:selected").before($("option:selected").next());
sort();
})
$(".search").click(function(){
var v = $("input").val();
$("option:contains("+v+")").attr('selected','selected');
})
function sort(){
$('option').text(function(){return ($(this).index()+1)+'.'+$(this).text()});
}
//重置所有option文字。
function rest(){
$('option').text(function(){
return $(this).text().split('.')[1]
});
}
//获取排序并提交
$('.sort_confirm').click(function(){
var arr = new Array();
$('.ids').each(function(){
arr.push($(this).val());
});
$('input[name=ids]').val(arr.join(','));
$.post(
$('form').attr('action'),
{
'ids' : arr.join(',')
},
function(data){
if (data.code) {
updateAlert(data.msg + ' 页面即将自动跳转~','alert-success');
}else{
updateAlert(data.msg,'alert-success');
}
setTimeout(function(){
if (data.code) {
$('.sort_cancel').click();
}
},1500);
},
'json'
);
});
//点击取消按钮
$('.sort_cancel').click(function(){
window.location.href = $(this).attr('url');
});
})
</script>
{/block}
+44
View File
@@ -0,0 +1,44 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<form method="post" class="form form-horizontal">
<div class="form-group">
<label class="col-md-2 control-label">客户端名称</label>
<div class="col-md-10">
<input type="text" class="form-control" style="width:400px;" name="title" value="{$info['title']|default=''}">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">APPID</label>
<div class="col-md-10">
<input type="text" class="form-control" style="width:400px;" name="appid" value="{$info['appid']|default=''}">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">APPSECRET</label>
<div class="col-md-10">
<input type="text" class="form-control" style="width:400px;" name="appsecret" value="{$info['appsecret']|default=''}">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="hidden" name="id" value="{$info['id']|default=''}">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+48
View File
@@ -0,0 +1,48 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<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('del')}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>名称</th>
<th>APPID</th>
<th>APPSECRET</th>
<th>创建时间</th>
<th>更新时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['appid']}</td>
<td>{$item['appsecret']}</td>
<td>{$item['create_time']}</td>
<td>{$item['update_time']}</td>
<td>
<a href="{:url('client/edit?id='.$item['id'])}">编辑</a>
<a href="{:url('client/del?id='.$item['id'])}" class="ajax-post confirm">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
+88
View File
@@ -0,0 +1,88 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>配置管理</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form method="post" class="form form-horizontal">
<div class="form-group">
<label class="col-lg-2 control-label">配置标识</label>
<div class="col-lg-10">
<input type="text" class="form-control" style="width: 400px" name="name" value="{$info.name|default=''}">
<span class="help-block">(用于config函数调用,只能使用英文且不能重复)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">配置标题</label>
<div class="col-lg-10">
<input type="text" class="form-control" style="width:400px;" name="title" value="{$info.title|default=''}">
<span class="help-block">(用于后台显示的配置标题)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">排序</label>
<div class="col-lg-10">
<input type="text" class="form-control" style="width: 400px" name="sort" value="{$info.sort|default=0}">
<span class="help-block">(用于分组显示的顺序)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">配置类型</label>
<div class="col-lg-10">
<select name="type" class="form-control" style="width:auto;">
{volist name=":config('config_type_list')" id="type"}
<option value="{$key}" {eq name="key" value="$info['type']"}selected{/eq}>{$type}</option>
{/volist}
</select>
<span class="help-block">(系统会根据不同类型解析配置值)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">配置分组</label>
<div class="col-lg-10">
<select name="group" class="form-control" style="width: auto">
<option value="0">不分组</option>
{volist name=":config('config_group_list')" id="group"}
<option value="{$key}" {eq name="key" value="$info['group']"}selected{/eq}>{$group}</option>
{/volist}
</select>
<span class="help-block">(配置分组 用于批量设置 不分组则不会显示在系统设置中)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">配置值</label>
<div class="col-lg-10">
<textarea name="value" class="form-control" style="width: 80%;height: 120px">{$info.value|default=''}</textarea>
<span class="help-block">(配置值)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">配置项</label>
<div class="col-lg-10">
<textarea name="extra" class="form-control" style="width: 80%;height: 120px">{$info.extra|default=''}</textarea>
<span class="help-block">(如果是枚举型 需要配置该项)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">说明</label>
<div class="col-lg-10">
<textarea name="remark" class="form-control" style="width: 80%;height: 120px">{$info.remark|default=''}</textarea>
<span class="help-block">(配置详细说明)</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$info.id|default=''}">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+86
View File
@@ -0,0 +1,86 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>配置管理</h2>
</div>
<div class="pull-right">
<a href="{:url('Config/index')}" class="btn btn-primary">
<i class="fa fa-list"></i>
配置列表
</a>
<a href="{:url('Config/add')}" class="btn btn-danger">
<i class="fa fa-list"></i>
添加配置
</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
{volist name=":config('config_group_list')" id="item"}
<li {if condition="$key eq $id"}class="active"{/if}>
<a href="{:url('Config/group',array('id'=>$key))}">{$item}</a>
</li>
{/volist}
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="tab-home">
<form method="post" class="form form-horizontal" role="form">
{volist name="list" id="item"}
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">{$item['title']}</label>
<div class="col-lg-10">
{switch name="item['type']"}
{case value="text"}
<input type="text" class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" value="{$item['value']}" placeholder="{$item['title']}" style="width:50%;">
{/case}
{case value="num"}
<input type="text" class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" value="{$item['value']}" placeholder="{$item['title']}" style="width:30%;">
{/case}
{case value="string"}
<input type="text" class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" value="{$item['value']}" placeholder="{$item['title']}" style="width:80%;">
{/case}
{case value="textarea"}
<textarea class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:80%; height:120px;">{$item['value']}</textarea>
{/case}
{case value="select"}
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:auto;">
{volist name=":parse_config_attr($item['extra'])" id="vo"}
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
{/volist}
</select>
{/case}
{case value="bool"}
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:auto;">
{volist name=":parse_config_attr($item['extra'])" id="vo"}
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
{/volist}
</select>
{/case}
{case value="image"}
{:widget('common/Form/showConfig',array($item,$item))}
{/case}
{/switch}
{if condition="$item['remark']"}
<span class="help-block">{$item['remark']}</span>
{/if}
</div>
</div>
{/volist}
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-success submit-btn ajax-post" target-form="form">确认提交</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{/block}
+118
View File
@@ -0,0 +1,118 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>网站设置</h2>
</div>
<div class="pull-right">
<a href="{:url('Config/group')}" class="btn btn-danger">
<i class="fa fa-list"></i>
配置管理
</a>
<a href="{:url('Config/add')}" class="btn btn-danger">
<i class="fa fa-plus"></i>
添加配置
</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
<li {if condition="!$group_id"}class="active"{/if}><a href="{:url('index')}">全部</a></li>
{volist name="group" id="item"}
<li {if condition="$group_id eq $key"}class="active"{/if}>
<a href="{:url('index?group='.$key)}">{$item}</a>
</li>
{/volist}
</ul>
<div class="tab-content">
<div class="tab-pane fade in active">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th class="row-selected">
<input class="checkbox check-all" type="checkbox">
</th>
<th>ID</th>
<th>名称</th>
<th>标题</th>
<th>分组</th>
<th>类型</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{notempty name="list"}
{volist name="list" id="config"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$config.id}"></td>
<td>{$config.id}</td>
<td><a href="{:url('edit?id='.$config['id'])}">{$config.name}</a></td>
<td>{$config.title}</td>
<td>{$group[$config['group']]|default=''}</td>
<td>{$config['type_text']}</td>
<td>
<a title="编辑" href="{:url('edit?id='.$config['id'])}">编辑</a>
<a class="confirm ajax-get" title="删除" href="{:url('del?id='.$config['id'])}">删除</a>
</td>
</tr>
{/volist}
{else/}
<td colspan="7" class="text-center"> aOh! 暂时还没有内容!</td>
{/notempty}
</tbody>
</table>
</div>
{$page}
</div>
</div>
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
$(function () {
//搜索功能
$("#search").click(function () {
var url = $(this).attr('url');
var query = $('.search-form').find('input').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
query = query.replace(/^&/g, '');
if (url.indexOf('?') > 0) {
url += '&' + query;
} else {
url += '?' + query;
}
window.location.href = url;
});
//回车搜索
$(".search-input").keyup(function (e) {
if (e.keyCode === 13) {
$("#search").click();
return false;
}
});
//点击排序
$('.list_sort').click(function () {
var url = $(this).attr('url');
var ids = $('.ids:checked');
var param = '';
if (ids.length > 0) {
var str = new Array();
ids.each(function () {
str.push($(this).val());
});
param = str.join(',');
}
if (url != undefined && url != '') {
window.location.href = url + '/ids/' + param;
}
});
});
</script>
{/block}
+67
View File
@@ -0,0 +1,67 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<form method="post" class="form form-horizontal" action="edit">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
<li class="active"><a href="#pc" data-toggle="tab">PC端模板</a></li>
<li><a href="#mobile" data-toggle="tab">移动端模板</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="pc">
<div class="row">
{volist name="list['pc']" id="item"}
<div class="col-sm-4 col-md-3">
<div class="thumbnail">
<img src="{$item['img']}" alt="{$item['name']}" class="img-rounded">
<div class="caption">
<h4>{$item['name']}</h4>
<p class="text-right">
{if $pc == $item['id']}
<button class="btn btn-danger btn-block" disabled>已启用</button>
{else/}
<a href="{:url('admin/config/setthemes?name=pc&id='.$item['id'])}" class="btn btn-primary btn-block ajax-get">启用</a>
{/if}
</p>
</div>
</div>
</div>
{/volist}
</div>
</div>
<div class="tab-pane fade" id="mobile">
<div class="row">
{volist name="list['mobile']" id="item"}
<div class="col-sm-4 col-md-3">
<div class="thumbnail">
<img src="{$item['img']}" alt="{$item['name']}" class="img-rounded">
<div class="caption">
<h4>{$item['name']}</h4>
<p class="text-right">
{if $mobile == $item['id']}
<button class="btn btn-danger btn-block" disabled>已启用</button>
{else/}
<a href="{:url('admin/config/setthemes?name=mobile&id='.$item['id'])}" class="btn btn-primary btn-block ajax-get">启用</a>
{/if}
</p>
</div>
</div>
</div>
{/volist}
</div>
</div>
</div>
</div>
</form>
</div>
</div>
{/block}
+94
View File
@@ -0,0 +1,94 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{:url('admin/content/add?model_id='.$model_id)}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('admin/content/del?model_id='.$model_id)}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="row">
<form method="get">
<div class="col-sm-12 col-md-4 col-lg-3">
<input type="text" class="form-control" name="keyword" value="{$keyword|default=''}" placeholder="请输入关键字">
</div>
{if isset($cate_list)}
<div class="col-sm-12 col-md-4 col-lg-3">
<select name="category" id="category" class="form-control">
<option value="">请选择栏目</option>
{volist name="cate_list" id="item"}
<option value="{$item['id']}" {if isset($category) && $item['id'] == $category}selected{/if}>{$item['title_show']}</option>
{/volist}
</select>
</div>
{/if}
<div class="col-sm-12 col-md-4">
<button class="btn btn-primary" type="submit">搜索</button>
</div>
</form>
</div>
<div class="table-responsive clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
{volist name="grid['grids']" id="item"}
<th>{$item['title']}</th>
{/volist}
<th>操作</th>
</tr>
</thead>
<tbody>
{if condition="empty($list)"}
{php}
$cow = count($grid['grids'])+2;
{/php}
<tr>
<td colspan="{$cow}" align="center">暂无数据!</td>
</tr>
{else/}
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
{volist name="grid['grids']" id="vo"}
{if isset($vo['format'])}
<td>{$item[$vo['field'][0]]|$vo['format']}</td>
{else/}
<td>{$item[$vo['field'][0]]}</td>
{/if}
{/volist}
<td>
{if isset($item['is_top'])}
{if $item['is_top']}
<a href="{:url('admin/content/settop?model_id='.$model_id,array('id'=>$item['id'],'is_top'=>'0'))}" class="ajax-get">取消置顶</a>
{else/}
<a href="{:url('admin/content/settop?model_id='.$model_id,array('id'=>$item['id'],'is_top'=>'1'))}" class="ajax-get">置顶</a>
{/if}
{/if}
{if isset($item['status'])}
{if $item['status']}
<a href="{:url('admin/content/status?model_id='.$model_id,array('id'=>$item['id'],'status'=>'0'))}" class="ajax-get">取消审核</a>
{else/}
<a href="{:url('admin/content/status?model_id='.$model_id,array('id'=>$item['id'],'status'=>'1'))}" class="ajax-get">审核</a>
{/if}
{/if}
<a href="{:url('admin/content/edit?model_id='.$model_id,array('id'=>$item['id']))}" >编辑</a>
<a href="{:url('admin/content/del?model_id='.$model_id,array('id'=>$item['id']))}" class="ajax-get confirm">删除</a>
</td>
</tr>
{/volist}
{/if}
</tbody>
</table>
</div>
{$page}
</div>
</div>
</div>
{/block}
+136
View File
@@ -0,0 +1,136 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<!-- 标题栏 -->
<div class="pull-left">
<h2>数据备份</h2>
</div>
<div class="pull-right">
<a id="export" class="btn btn-primary" href="javascript:;" autocomplete="off">立即备份</a>
<a id="optimize" class="btn btn-success" href="{:url('optimize')}">优化表</a>
<a id="repair" class="btn btn-warning" href="{:url('repair')}">修复表</a>
</div>
</header>
<div class="main-box-body clearfix">
<form id="export-form" method="post" action="{:url('export')}">
<div class="table-responsive clearfix">
<table class="table table-striped">
<thead>
<tr>
<th width="48">
<input class="check-all" checked="chedked" type="checkbox" value=""></th>
<th>表名</th>
<th width="120">数据量</th>
<th width="120">数据大小</th>
<th width="180">创建时间</th>
<th width="160">备份状态</th>
<th width="120">操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="table"}
<tr>
<td class="num">
<input class="ids" checked="chedked" type="checkbox" name="tables[]" value="{$table.name}"></td>
<td>{$table.name}</td>
<td>{$table.rows}</td>
<td>{$table.data_length|format_bytes}</td>
<td>{$table.create_time}</td>
<td class="info">未备份</td>
<td class="action">
<a class="ajax-get no-refresh" href="{:url('optimize?tables='.$table['name'])}">优化表</a>
&nbsp;
<a class="ajax-get no-refresh" href="{:url('repair?tables='.$table['name'])}">修复表</a>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
</form>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
(function($){
var $form = $("#export-form"), $export = $("#export"), tables
$optimize = $("#optimize"), $repair = $("#repair");
$optimize.add($repair).click(function(){
$.post(this.href, $form.serialize(), function(data){
if(data.code){
updateAlert(data.msg,'alert-success');
} else {
updateAlert(data.msg,'alert-error');
}
setTimeout(function(){
$('#top-alert').find('button').click();
$(that).removeClass('disabled').prop('disabled',false);
},1500);
}, "json");
return false;
});
$export.click(function(){
$export.parent().children().addClass("disabled");
$export.html("正在发送备份请求...");
$.post(
$form.attr("action"),
$form.serialize(),
function(data){
if(data.code){
tables = data.data.tables;
$export.html(data.msg + "开始备份,请不要关闭本页面!");
backup(data.data.tab);
window.onbeforeunload = function(){ return "正在备份数据库,请不要关闭!" }
} else {
updateAlert(data.msg,'alert-error');
$export.parent().children().removeClass("disabled");
$export.html("立即备份");
setTimeout(function(){
$('#top-alert').find('button').click();
$(that).removeClass('disabled').prop('disabled',false);
},1500);
}
},
"json"
);
return false;
});
function backup(tab, status){
status && showmsg(tab.id, "开始备份...(0%)");
$.get($form.attr("action"), tab, function(data){
if(data.code){
var info = data.data;
showmsg(tab.id, data.msg);
if(!$.isPlainObject(info.tab)){
$export.parent().children().removeClass("disabled");
$export.html("备份完成,点击重新备份");
window.onbeforeunload = function(){ return null }
return;
}
backup(info.tab, tab.id != info.tab.id);
} else {
updateAlert(data.msg,'alert-error');
$export.parent().children().removeClass("disabled");
$export.html("立即备份");
setTimeout(function(){
$('#top-alert').find('button').click();
$(that).removeClass('disabled').prop('disabled',false);
},1500);
}
}, "json");
}
function showmsg(id, msg){
$form.find("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg);
}
})(jQuery);
</script>
{/block}
+87
View File
@@ -0,0 +1,87 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<!-- 标题栏 -->
<div class="pull-left">
<h2>数据恢复</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<!-- 应用列表 -->
<table class="table table-striped">
<thead>
<tr>
<th width="200">备份名称</th>
<th width="80">卷数</th>
<th width="80">压缩</th>
<th width="80">数据大小</th>
<th width="200">备份时间</th>
<th>状态</th>
<th width="120">操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="data"}
<tr>
<td>{$data.time|date='Ymd-His',###}</td>
<td>{$data.part}</td>
<td>{$data.compress}</td>
<td>{$data.size|format_bytes}</td>
<td>{$key}</td>
<td>-</td>
<td class="action">
<a class="db-import" href="{:url('import?time='.$data['time'])}">还原</a>
&nbsp;
<a class="ajax-get confirm" href="{:url('del?time='.$data['time'])}">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
<!-- /应用列表 -->
</div>
{/block}
{block name="script"}
<script type="text/javascript">
$(".db-import").click(function(){
var self = this, status = ".";
$.get(self.href, success, "json");
window.onbeforeunload = function(){ return "正在还原数据库,请不要关闭!" }
return false;
function success(data){
if(data.code){
if(data.data.gz){
data.msg += status;
if(status.length === 5){
status = ".";
} else {
status += ".";
}
}
$(self).parent().prev().text(data.msg);
if(data.data.part){
$.get(self.href,
{"part" : data.data.part, "start" : data.data.start},
success,
"json"
);
} else {
window.onbeforeunload = function(){ return null; }
}
} else {
updateAlert(data.msg,'alert-error');
}
}
});
</script>
{/block}
+64
View File
@@ -0,0 +1,64 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-danger" href="{:url('addattr',array('form_id'=>$form_id))}"><i class="fa fa-plus"></i> 新 增</a>
<!-- <button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids"><i class="fa fa-remove"></i> 删 除</button> -->
<a class="btn btn-warning" href="{:url('Form/index')}"><i class="fa fa-reply"></i> 返回</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th><input class="checkbox check-all" type="checkbox"></th>
<th>表单标题</th>
<th>字段名</th>
<th>字段类型</th>
<th>字段长度</th>
<th>默认值</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
<td>{$item['title']}</td>
<td>{$item['name']}</td>
<td>{$item['type_text']}</td>
<td>{$item['length']}</td>
<td>{$item['value']}</td>
<td>
<a href="{:url('editattr',array('id'=>$item['id'], 'form_id'=>$form_id))}">编辑</a>
<a href="{:url('delattr',array('id'=>$item['id'], 'form_id'=>$form_id))}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
<script type="text/javascript">
$(function(){
$('.openDilog').click(function(){
layer.open({
type: 2,
title: false,
area: ['900px', '560px'],
content: $('.openDilog').attr('url')
});
});
})
</script>
{/block}
+62
View File
@@ -0,0 +1,62 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover table-bordered">
<tr>
<th width="120" style="text-align: right;">姓名</th>
<td>{$info['name']}</td>
<th width="120" style="text-align: right;">性别</th>
<td>{if $info['sex'] == 0}保密{elseif $info['sex'] == 1}男{elseif $info['sex'] == 2}女{/if}</td>
<th width="120" style="text-align: right;">出生年月</th>
<td>{$info['birthday']|date='Y-m-d',###}</td>
</tr>
<tr>
<th width="120" style="text-align: right;">从事行业</th>
<td>{$info['industry']}</td>
<th width="120" style="text-align: right;">所在单位</th>
<td colspan="3">{$info['company']}</td>
</tr>
<tr>
<th width="120" style="text-align: right;">单位职务</th>
<td>{$info['duties']}</td>
<th width="120" style="text-align: right;">入学年份</th>
<td>{$info['en_year']}</td>
<th width="120" style="text-align: right;">所学专业</th>
<td>{$info['major']}</td>
</tr>
<tr>
<th width="120" style="text-align: right;">联系电话</th>
<td>{$info['mobile']}</td>
<th width="120" style="text-align: right;">QQ</th>
<td>{$info['qq']}</td>
<th width="120" style="text-align: right;">微信</th>
<td>{$info['wechat']}</td>
</tr>
<tr>
<th width="120" style="text-align: right;">个人简历</th>
<td colspan="5">
{$info['profile']}
</td>
</tr>
<tr>
<td colspan="6">
说明:个人简历中,您可以添加任何您愿意提供的信息,例如您可以为校友提供何种帮助,有何特长,获得的主要荣誉,是否参加其他社团组织等等。
</td>
</tr>
</table>
</div>
</div>
</div>
{/block}
{block name="script"}
{/block}
+69
View File
@@ -0,0 +1,69 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<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('del')}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th>名称</th>
<th>排序</th>
<th>时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{notempty name="list"}
{volist name="list" id="item"}
<tr>
<td>
<input class="ids" type="checkbox" name="ids[]" value="{$item['id']}" />
</td>
<td>{$item['id']}</td>
<td>{$item['name']}</td>
<td>
<a data-id="{$item.id}" href="{:url('form/edit?id='.$item['id'])}">{$item['title']}</a>
</td>
<td>
<span>{$item.create_time|time_format}</span>
</td>
<td>
{if $item['status']}
<span class="label label-primary">{$item['status_text']}</span>
{else/}
<span class="label label-danger">{$item['status_text']}</span>
{/if}
</td>
<td>
<a href="{:url('admin/form/attr?form_id='.$item['id'])}">字段</a>
<a href="{:url('admin/form/status?id='.$item['id'].'&status='.abs(1-$item['status']))}" class="ajax-get">{$item['status']|show_status_op}</a>
<a href="{:url('admin/form/edit?id='.$item['id'])}">编辑</a>
<a href="{:url('admin/form/del?id='.$item['id'])}" class="confirm ajax-get">删除</a>
<a href="{:url('admin/form/lists?form_id='.$item['id'])}">数据</a>
</td>
</tr>
{/volist}
{else/}
<td colspan="7" class="text-center">aOh! 暂时还没有创建模型!</td>
{/notempty}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
+62
View File
@@ -0,0 +1,62 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{:url('admin/form/outxls?form_id='.$form_id)}" target="_blank">导出</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th><input class="checkbox check-all" type="checkbox"></th>
<th>姓名</th>
<th>性别</th>
<th>生日</th>
<th>从事行业</th>
<th>所在单位</th>
<th>职务</th>
<th>入学年份</th>
<th>所学专业</th>
<th>电话</th>
<th>QQ</th>
<th>微信</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
<td>{$item['name']}</td>
<td>{if $item['sex'] == 0}保密{elseif $item['sex'] == 1}男{elseif $item['sex'] == 2}女{/if}</td>
<td>{$item['birthday']|date='Y-m-d',###}</td>
<td>{$item['industry']}</td>
<td>{$item['company']}</td>
<td>{$item['duties']}</td>
<td>{$item['en_year']}</td>
<td>{$item['major']}</td>
<td>{$item['mobile']}</td>
<td>{$item['qq']}</td>
<td>{$item['wechat']}</td>
<td>
<a href="{:url('detail',array('id'=>$item['id'], 'form_id'=>$form_id))}">详情</a>
<a href="{:url('deldata',array('id'=>$item['id'], 'form_id'=>$form_id))}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
{block name="script"}
{/block}
+77
View File
@@ -0,0 +1,77 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a href="{:url('Group/addnode',array('type'=>$type))}" class="btn btn-danger">
<i class="fa fa-plus"></i>
添加节点
</a>
<a href="{:url('Group/upnode',array('type'=>$type))}" class="btn btn-danger ajax-get">
<i class="fa fa-plus"></i>
更新节点
</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
{volist name=":config('user_group_type')" id="item"}
<li {if condition="$key eq $type"}class="active"{/if}>
<a href="{:url('Group/access',array('type'=>$key))}">{$item}</a>
</li>
{/volist}
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="tab-home">
{if condition="empty($list)"}
<p>暂无数据!</p>
{else/}
<div class="table-responsive clearfix">
<table class="table table-striped table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th>组名</th>
<th>标识</th>
<th>分组</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<th width="30"><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></th>
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['name']}</td>
<td>{$item['group']}</td>
<td>
{if condition="$item['status'] eq '0'"}
<span class="label label-danger">禁用</span>
{elseif condition="$item['status'] eq '1'"/}
<span class="label label-primary">启用</span>
{/if}
</td>
<td>
<a href="{:url('Group/editnode',array('id'=>$item['id']))}">编辑</a>
<a href="{:url('Group/delnode',array('id'=>$item['id']))}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
{/if}
</div>
</div>
</div>
</div>
</div>
{/block}
+63
View File
@@ -0,0 +1,63 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a href="{:url('Group/index')}" class="btn btn-danger">
<i class="glyphicon glyphicon-menu-left"></i>
返回
</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<form action="" class="form" method="post">
<table class="table table-striped">
<thead>
<tr>
<th class="col-lg-2 text-right">分组</th>
<th>权限</th>
</tr>
</thead>
<tbody>
{volist name="list" id="node"}
<tr>
<td class="info col-lg-2 text-right">{$key}</td>
<td class="col-lg-10 text-left">
{volist name="node" id="item"}
<div class="checkbox-nice checkbox-inline">
<input type="checkbox" name="rule[]" value="{$item['id']}" id="{$item['name']}" {if in_array($item['id'],$auth_list)}checked{/if} />
<label for="{$item['name']}">{$item['title']}</label>
</div>
{/volist}
</td>
</tr>
{/volist}
<tr>
<td class="info col-lg-2 text-right">模块</td>
<td class="col-lg-10 text-left">
{volist name="model" id="item"}
<div class="checkbox-nice checkbox-inline">
<input type="checkbox" name="extend_rule[2][]" value="{$item['id']}" id="{$item['name']}" {if in_array($item['id'],$extend_auth)}checked{/if} />
<label for="{$item['name']}">{$item['title']}</label>
</div>
{/volist}
</td>
</tr>
</tbody>
</table>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$id}">
<button type="submit" class="btn btn-success submit-btn ajax-post" target-form="form">确认提交</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
</div>
{/block}
+83
View File
@@ -0,0 +1,83 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a href="{:url('Group/add',array('type'=>$type))}" class="btn btn-danger"><i class="fa fa-plus"></i> 添加用户组</a>
</div>
</header>
<div class="main-box-body clearfix">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
{volist name=":config('USER_GROUP_TYPE')" id="item"}
<li {if condition="$key eq $type"}class="active"{/if}>
<a href="{:url('Group/index',array('type'=>$key))}">{$item}</a>
</li>
{/volist}
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="tab-home">
{if condition="empty($list)"}
<p>暂无数据!</p>
{else/}
<div class="table-responsive clearfix">
<table class="table table-striped table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th>组名</th>
<th>描述</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$item['id']}"></td>
<td>{$item['id']}</td>
<td><a href="#" class="editable editable-click" data-id="{$item['id']}" data-name="title" data-type="text" data-pk="{$item['id']}" data-url="{:url('editable')}">{$item['title']}</a></td>
<td>{$item['description']}</td>
<td>
{if condition="$item['status'] eq '0'"}
<span class="label label-danger">禁用</span>
{elseif condition="$item['status'] eq '1'"/}
<span class="label label-primary">启用</span>
{/if}
</td>
<td>
<a href="{:url('Group/edit',array('id'=>$item['id']))}">编辑</a>
<a href="{:url('Group/auth',array('id'=>$item['id']))}">授权</a>
<a href="{:url('Group/del',array('id'=>$item['id']))}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
{/if}
</div>
</div>
</div>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function(){
$.fn.editable.defaults.mode = 'popup';
$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
$('.editable').editable();
})
</script>
{/block}
+6
View File
@@ -0,0 +1,6 @@
{extend name="admin/public/base" /}
{block name="body"}
<div class="row">
{:hook('AdminIndex')}
</div>
{/block}
+132
View File
@@ -0,0 +1,132 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<META content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>欢迎您登录SentCMS管理平台</title>
<link rel="stylesheet" type="text/css" href="__static__/plugins/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="__static__/common/css/font-awesome.css"/>
<link rel="stylesheet" type="text/css" href="__static__/common/css/animate.min.css"/>
<link rel="stylesheet" type="text/css" href="__static__/plugins/layui/css/layui.css"/>
<link rel="stylesheet" type="text/css" href="__css__/login.css"/>
<script type="text/javascript" src="__static__/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="__static__/plugins/layui/layui.all.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="__static__/common/js/html5shiv.min.js"></script>
<script src="__static__/common/js/ie8polyfill.min.js"></script>
<![endif]-->
</head>
<body id="login-page-full">
<div class="login-container">
<!-- 动态云层动画 开始 -->
<div class="clouds-container">
<div class="clouds clouds-footer"></div>
<div class="clouds"></div>
<div class="clouds clouds-fast"></div>
</div>
<!-- 动态云层动画 结束 -->
<!-- 顶部导航条 开始 -->
<div class="header notselect">
<span class="title notselect">SentCMS <sup>v{$Think.SENTCMS_VERSION}</sup></span>
<ul>
<li><a href="javascript:void(0)" target="_blank">帮助</a></li>
<li>
<a href="https://www.google.cn/intl/zh-CN/chrome/">推荐使用谷歌浏览器</a>
</li>
</ul>
</div>
<!-- 顶部导航条 结束 -->
<!-- 页面表单主体 开始 -->
<div class="container">
<form onsubmit="return false;" method="post" class="content layui-form animated fadeInDown">
<div class="people">
<div class="tou"></div>
<div id="left-hander" class="initial_left_hand transition"></div>
<div id="right-hander" class="initial_right_hand transition"></div>
</div>
<ul>
<li class="username">
<i class="fa fa-user"></i>
<input required pattern="^\S{4,}$" name="username" value="" type="text" autofocus="autofocus" autocomplete="off" title="请输入4位及以上的字符" placeholder="请输入用户名/手机号码">
</li>
<li class="password">
<i class="fa fa-shield"></i>
<input required pattern="^\S{4,}$" name="password" value="" type="password" autocomplete="off" title="请输入4位及以上的字符" placeholder="请输入密码">
</li>
<li class="verify">
<i class="fa fa-qrcode"></i>
<input required pattern="^\S{3,}$" name="verify" value="" type="text" autocomplete="off" title="请输入3位及以上的字符" placeholder="请输入验证码">
<span class="reloadverify"><img src="{:captcha_src()}" alt="验证码" height="38" class="verifyimg"></span>
</li>
<li class="text-center">
<button type="submit" class="btn btn-primary btn-block">登录</button>
</li>
</ul>
</form>
</div>
<!-- 页面表单主体 结束 -->
<!-- 底部版权信息 开始 -->
<div class="footer notselect">
腾速科技 &copy; TenSent.Icn
</div>
<!-- 底部版本信息 结束 -->
</div>
<script>
$(function () {
$('[name="password"]').on('focus', function () {
$('#left-hander').removeClass('initial_left_hand').addClass('left_hand');
$('#right-hander').removeClass('initial_right_hand').addClass('right_hand')
}).on('blur', function () {
$('#left-hander').addClass('initial_left_hand').removeClass('left_hand');
$('#right-hander').addClass('initial_right_hand').removeClass('right_hand')
});
//表单提交
$(document).ajaxStart(function(){
$("button:submit").addClass("log-in").attr("disabled", true);
}).ajaxStop(function(){
$("button:submit").removeClass("log-in").attr("disabled", false);
});
$("form").submit(function(){
var self = $(this);
$.post(self.attr("action"), self.serialize(), success, "json");
return false;
function success(data){
if(data.code){
layer.msg(data.msg, {time:3000, end:function(){
window.location.href = data.url;
}});
} else {
layer.msg(data.msg, {time:3000, end:function(){
//刷新验证码
$(".reloadverify").click();
}});
}
}
});
//初始化选中用户名输入框
$("#itemBox").find("input[name=username]").focus();
//刷新验证码
var verifyimg = $(".verifyimg").attr("src");
$(".reloadverify").click(function(){
if( verifyimg.indexOf('?')>0){
$(".verifyimg").attr("src", verifyimg+'&random='+Math.random());
}else{
$(".verifyimg").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
}
});
});
</script>
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<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>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th width="60">ID</th>
<th>名称</th>
<th>排序</th>
<th>时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['sort']}</td>
<td>{$item['update_time']|date='Y-m-d',###}</td>
<td>
<a href="{:url('edit?id='.$item['id'])}">编辑</a>
<a href="{:url('delete?id='.$item['id'])}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
{$page}
</div>
</div>
</div>
{/block}
+96
View File
@@ -0,0 +1,96 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{:isset($info['id'])?'编辑':'新增'}后台菜单</h2>
</div>
<div class="pull-right"></div>
</header>
<div class="main-box-body clearfix">
<form method="post" class="form form-horizontal">
<div class="form-group">
<label class="col-lg-2 control-label">标题</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="title" value="{$info.title|default=''}" style="width: 80%">
<span class="help-block">(用于后台显示的配置标题)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">小图标</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="icon" value="{$info.icon|default=''}" style="width: 80%">
<span class="help-block">(用于显示在菜单左侧,不填则不显示)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">排序</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="sort" value="{$info.sort|default=0}" style="width: 60%">
<span class="help-block">(用于分组显示的顺序)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">链接</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="url" value="{$info['url']|default=''}" style="width: 80%">
<span class="help-block">U函数解析的URL或者外链)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">上级菜单</label>
<div class="col-lg-10">
<select name="pid" class="form-control" style="width: 50%">
{volist name="Menus" id="menu"}
<option value="{$menu['id']}" {if $info['pid'] == $menu['id']}selected{/if}>{$menu.title_show}</option>
{/volist}
</select>
<span class="help-block">(所属的上级菜单)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">分组</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="group" value="{$info['group']|default=''}" style="width: 50%">
<span class="help-block">(用于左侧分组二级菜单)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">是否隐藏</label>
<div class="col-lg-1">
<select name="hide" class="form-control">
<option value="0" ></option>
<option value="1" {if isset($info['hide']) && $info['hide']==1}selected{/if}>
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">仅开发者模式可见</label>
<div class="col-lg-1">
<select name="is_dev" class="form-control">
<option value="0" ></option>
<option value="1" {if isset($info['is_dev']) && $info['is_dev']==1}selected{/if}>
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">说明</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="tip" value="{$info.tip|default=''}" style="width: 60%;">
<span class="help-block">(菜单详细说明)</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$info['id']|default=''}">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+29
View File
@@ -0,0 +1,29 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>批量导入 [{$data['title']|default='顶级菜单'}]</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form id="form" action="{:url('import')}" method="post" class="form form-horizontal">
<!-- 基础文档模型 -->
<div class="form-group">
<label class="col-lg-2 control-label">导入的内容</label>
<div class="col-lg-10">
<textarea name="tree" class="form-control" style="width:80%; height:160px;"></textarea>
<span class="help-block"><b>导入格式:</b><br/>首页|Index/index|0|分组名称<br/>更新缓存|Index/clear|0|分组名称<br/>(请按照导入格式输入)</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$info.id|default=''}">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+120
View File
@@ -0,0 +1,120 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{present name="data"}[ {$data['title']} ] 子{/present}菜单管理</h2>
</div>
<div class="pull-right">
<!-- <div class="search-form pull-left">
<div class="form-group">
<input type="text" name="title" class="form-control" value="{:input('title')}"
placeholder="请输入菜单名称">
<span class="input-group-btn"><a class="btn btn-default" href="javascript:;" id="search" url="__SELF__"><i class="icon-search"></i></a></span>
</div>
</div> -->
<a class="btn btn-primary" href="{:url('add',array('pid'=>input('get.pid',0)))}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
<a class="btn btn-success" href="{:url('import',array('pid'=>input('get.pid',0)))}">导 入</a>
</div>
</header>
<div class="main-box-body clearfix">
<form class="ids">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th class="row-selected">
<input class="checkbox check-all" type="checkbox">
</th>
<th>ID</th>
<th>名称</th>
<th>上级菜单</th>
<th>分组</th>
<th>URL</th>
<th>排序</th>
<th>仅开发者模式显示</th>
<th>隐藏</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{notempty name="list"}
{volist name="list" id="menu"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$menu.id}"></td>
<td>{$menu.id}</td>
<td>
{$menu['level_show']}
<a href="#" class="editable editable-click" data-id="{$menu['id']}" data-name="title" data-type="text" data-pk="{$menu['id']}" data-url="{:url('editable')}">{$menu['title']}</a>
<a class="add-sub-cate" title="添加子分类" href="{:url('add?pid='.$menu['id'])}">
<i class="fa fa-plus-square"></i>
</a>
</td>
<td>{$menu.up_title|default='无'}</td>
<td>{$menu.group}</td>
<td>{$menu.url}</td>
<td><a href="#" class="editable editable-click" data-id="{$menu['id']}" data-name="sort" data-type="text" data-pk="{$menu['id']}" data-url="{:url('editable')}">{$menu['sort']}</a></td>
<td>
<a href="{:url('toogleDev',array('id'=>$menu['id'],'value'=>abs($menu['is_dev']-1)))}"
class="ajax-get">
{$menu.is_dev_text}
</a>
</td>
<td>
<a href="{:url('toogleHide',array('id'=>$menu['id'],'value'=>abs($menu['hide']-1)))}"
class="ajax-get">
{$menu.hide_text}
</a>
</td>
<td>
<a title="编辑" href="{:url('edit?id='.$menu['id'])}">编辑</a>
<a class="confirm ajax-get" title="删除" href="{:url('del?id='.$menu['id'])}">删除</a>
</td>
</tr>
{/volist}
{else/}
<td colspan="10" class="text-center"> aOh! 暂时还没有内容!</td>
{/notempty}
</tbody>
</table>
</div>
</form>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function () {
$.fn.editable.defaults.mode = 'popup';
$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
$('.editable').editable();
//搜索功能
$("#search").click(function () {
var url = $(this).attr('url');
var query = $('.search-form').find('input').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
query = query.replace(/^&/g, '');
if (url.indexOf('?') > 0) {
url += '&' + query;
} else {
url += '?' + query;
}
window.location.href = url;
});
//回车搜索
$(".search-input").keyup(function (e) {
if (e.keyCode === 13) {
$("#search").click();
return false;
}
});
});
</script>
{/block}
+111
View File
@@ -0,0 +1,111 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>菜单排序 [ <a href="{:url('index',array('pid'=>I('pid')))}">返回列表</a> ]</h2>
</div>
</header>
<div class="main-box-body clearfix">
<form action="{:url('sort')}" method="post" class="form form-horizontal">
<div class="form-group">
<div class="col-lg-2">
<select value="" size="8" class="form-control">
{volist name="list" id="vo"}
<option class="ids" title="{$vo.title}" value="{$vo.id}">{$vo.title}</option>
{/volist}
</select>
</div>
<div class="col-lg-2">
<button class="top btn btn-primary btn-block" type="button"><i class="fa fa-arrow-up"></i> 第 一</button>
<button class="up btn btn-primary btn-block" type="button"><i class="fa fa-chevron-up"></i> 上 移</button>
<button class="down btn btn-primary btn-block" type="button"><i class="fa fa-chevron-down"></i> 下 移</button>
<button class="bottom btn btn-primary btn-block" type="button"><i class="fa fa-arrow-down"></i> 最 后</button>
</div>
</div>
<div class="sort_bottom form-group">
<div class="col-lg-12">
<input type="hidden" name="ids">
<button class="sort_confirm btn btn-primary submit-btn" type="button">确 定</button>&nbsp;
<button class="sort_cancel btn btn-dafault btn-return" type="button" url="{$Think.cookie.__forward__}">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
$(function(){
sort();
$(".top").click(function(){
rest();
$("option:selected").prependTo("select");
sort();
})
$(".bottom").click(function(){
rest();
$("option:selected").appendTo("select");
sort();
})
$(".up").click(function(){
rest();
$("option:selected").after($("option:selected").prev());
sort();
})
$(".down").click(function(){
rest();
$("option:selected").before($("option:selected").next());
sort();
})
$(".search").click(function(){
var v = $("input").val();
$("option:contains("+v+")").attr('selected','selected');
})
function sort(){
$('option').text(function(){return ($(this).index()+1)+'.'+$(this).text()});
}
//重置所有option文字。
function rest(){
$('option').text(function(){
return $(this).text().split('.')[1]
});
}
//获取排序并提交
$('.sort_confirm').click(function(){
var arr = new Array();
$('.ids').each(function(){
arr.push($(this).val());
});
$('input[name=ids]').val(arr.join(','));
$.post(
$('form').attr('action'),
{
'ids' : arr.join(',')
},
function(data){
if (data.status) {
updateAlert(data.info + ' 页面即将自动跳转~','alert-success');
}else{
updateAlert(data.info,'alert-success');
}
setTimeout(function(){
if (data.status) {
$('.sort_cancel').click();
}
},1500);
},
'json'
);
});
//点击取消按钮
$('.sort_cancel').click(function(){
window.location.href = $(this).attr('url');
});
})
</script>
{/block}
+62
View File
@@ -0,0 +1,62 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>新增模型</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<!-- 表单 -->
<form id="form" method="post" class="form-horizontal form">
<!-- 基础 -->
<div id="tab1" class="tab-pane in tab1">
<div class="form-group">
<label class="col-lg-2 control-label">模型标识</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control " name="name" value="">
<span class="help-block">(请输入文档模型标识)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">模型名称</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control " name="title" value="">
<span class="help-block">(请输入模型的名称)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">文档模型</label>
<div class="col-lg-6 col-sm-10">
<select class="form-control" name="is_doc">
<option value="1"></option>
<option value="0"></option>
</select>
<span class="help-block">(文档模型默认导入部分必要字段)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">模型图标</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control " name="icon" value="">
<span class="help-block">(模型图标)</span>
</div>
</div>
</div>
<!-- 按钮 -->
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
+156
View File
@@ -0,0 +1,156 @@
{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/board/board.min.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>编辑模型</h2>
</div>
<div class="pull-right">
</div>
</header>
<div class="main-box-body clearfix">
<form id="form" method="post" class="form form-horizontal">
<div class="tabs-wrapper">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">基 础</a></li>
<li><a href="#tab2" data-toggle="tab">设 计</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="tab1">
<!-- 基础 -->
<div class="form-group">
<label class="col-lg-2 control-label">模型标识</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control disabled" name="name" value="{$info['name']}" disabled>
<span class="help-block">(请输入文档模型标识)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">模型名称</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control " name="title" value="{$info['title']}">
<span class="help-block">(请输入模型的名称)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">模型图标</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control " name="icon" value="{$info['icon']}">
<span class="help-block">(模型图标)</span>
</div>
</div>
</div>
<div class="tab-pane fade" id="tab2">
<div class="form-group">
<label class="col-lg-2 control-label">表单显示分组</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control" name="attribute_group" value="{$info['attribute_group']}">
<span class="help-block">(用于表单显示的分组,以及设置该模型表单排序的显示)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">表单显示排序</label>
<div class="col-lg-10 boards" id="attribute_group_sort">
{volist name="fields" id="field"}
<div class="board panel panel-info">
<div class="panel-heading">{$field_group[$key]}</div>
<div class="panel-body">
<div class="board-list" data-group="{$key}">
{foreach name="field" item="item" key="k"}
<div class="board-item">
<span data="{$item['id']}">{$item['title']} [{$item['name']}]</span>
<input type="hidden" name="attribute_sort[{$key}][]" value="{$item['id']}"/>
</div>
{/foreach}
</div>
</div>
</div>
{/volist}
<span class="help-block">(直接拖动进行排序)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">列表定义</label>
<div class="col-lg-6 col-sm-10">
<textarea name="list_grid" class="form-control">{$info['list_grid']}</textarea>
<span class="help-block">(默认列表模板的展示规则)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">默认搜索字段</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control" name="search_key" value="{$info['search_key']}">
<span class="help-block">(默认列表模板的默认搜索项)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">高级搜索字段</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control" name="search_list" value="{$info['search_list']}">
<span class="help-block">(默认列表模板的高级搜索项)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">列表模板</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control" name="template_list" value="{$info['template_list']|default=''}">
<span class="help-block">(自定义的列表模板,放在application\admin\view\content下,不写则使用默认模板)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">新增模板</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control" name="template_add" value="{$info['template_add']|default=''}">
<span class="help-block">(自定义的新增模板,放在application\admin\view\content下,不写则使用默认模板)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">编辑模板</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control" name="template_edit" value="{$info['template_edit']|default=''}">
<span class="help-block">(自定义的编辑模板,放在application\admin\view\content下,不写则使用默认模板)</span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">列表数据大小</label>
<div class="col-lg-6 col-sm-10">
<input type="text" class="form-control" name="list_row" value="{$info['list_row']|default=''}">
<span class="help-block">(默认列表模板的分页属性)</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<input type="hidden" name="id" value="{$info['id']}">
<button type="submit" class="btn btn-success submit-btn ajax-post" target-form="form">确认提交</button>
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</div>
</form>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/droppable.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/board/board.min.js"></script>
<script type="text/javascript">
$(function(){
$('.form-group #attribute_sort').boards();
$('.form-group #attribute_group_sort').boards({
drop: function(e){
var group = e.target.closest('.board').find('.board-list').attr('data-group');
e.element.find('input').attr('name','attribute_sort[' + group + '][]')
}
})
})
</script>
{/block}
+89
View File
@@ -0,0 +1,89 @@
{extend name="public/base"/}
{block name="body"}
<div class="main-box clearfix">
<header class="main-box-header clearfix">
<div class="pull-left">
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-success" href="{:url('Model/add')}">新 增</a>
<button class="btn ajax-post" target-form="ids" url="{:url('Model/status',array('status'=>0))}">禁 用</button>
</div>
</header>
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-striped">
<thead>
<tr>
<th class="row-selected row-selected">
<input class="check-all" type="checkbox"/>
</th>
<th class="">编号</th>
<th class="">标识</th>
<th class="">名称</th>
<th class="">创建时间</th>
<th class="">状态</th>
<th class="">操作</th>
</tr>
</thead>
<tbody>
{notempty name="list"}
{volist name="list" id="item"}
<tr>
<td>
<input class="ids" type="checkbox" name="ids[]" value="{$item['id']}" />
</td>
<td>{$item['id']}</td>
<td><i class="fa fa-{$item['icon']}"></i> {$item['name']}</td>
<td>
<a data-id="{$item.id}" href="{:url('model/edit?id='.$item['id'])}">{$item.title}</a>
</td>
<td>
<span>{$item.create_time|time_format}</span>
</td>
<td>
{if $item['status']}
<span class="label label-primary">{$item['status_text']}</span>
{else/}
<span class="label label-danger">{$item['status_text']}</span>
{/if}
</td>
<td>
<a href="{:url('admin/attribute/index?model_id='.$item['id'])}">字段</a>
<a href="{:url('model/status?id='.$item['id'].'&status='.abs(1-$item['status']))}" class="ajax-get">{$item['status']|show_status_op}</a>
<a href="{:url('model/edit?id='.$item['id'])}">编辑</a>
<a href="{:url('model/del?id='.$item['id'])}" class="confirm ajax-get">删除</a>
<a href="{:url('admin/content/index?model_id='.$item['id'])}">数据</a>
</td>
</tr>
{/volist}
{else/}
<td colspan="7" class="text-center">aOh! 暂时还没有创建模型!</td>
{/notempty}
</tbody>
</table>
</div>
{$page}
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
$(function(){
$("#search").click(function(){
var url = $(this).attr('url');
var status = $('select[name=status]').val();
var search = $('input[name=search]').val();
if(status != ''){
url += '/status/' + status;
}
if(search != ''){
url += '/search/' + search;
}
window.location.href = url;
});
})
</script>
{/block}
+213
View File
@@ -0,0 +1,213 @@
{include file="admin/public/header" /}
{block name="style"}{/block}
<div id="theme-wrapper">
<header class="navbar" id="header-navbar">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#header-nav">
<span class="sr-only">菜单</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="{:url('Index/index')}" id="logo" class="navbar-brand">
<img src="__STATIC__/images/logo.png" alt="" class="normal-logo logo-white"/>
</a>
<ul class="nav navbar-nav pull-right visible-xs">
<li class="dropdown profile-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="__STATIC__/images/samples/scarlet-159.png" alt=""/>
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<a href="{:url('admin/User/edit')}">
<i class="fa fa-user"></i>
修改资料
</a>
</li>
<li>
<a href="{:url('admin/User/editpwd')}">
<i class="fa fa-cog"></i>
修改密码
</a>
</li>
<li>
<a href="{:url('admin/index/logout')}">
<i class="fa fa-power-off"></i>
退出后台
</a>
</li>
<li>
<a href="{:config('WEB_SITE_URL')}" target="_blank">
<i class="fa fa-home"></i>
前台首页
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="nav-no-collapse navbar-left pull-left hidden-sm hidden-xs">
<ul class="nav navbar-nav pull-left">
<li>
<a class="btn" id="make-small-nav"> <i class="fa fa-bars"></i>
</a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse" id="header-nav">
<ul class="nav navbar-nav">
{volist name="__menu__['main']" id="item"}
<li class="{$item['style']}">
<a href="{$item['url']|url}">
<i class="fa fa-{$item['icon']|default='file'}"></i>
<span>{$item['title']}</span>
</a>
</li>
{/volist}
</ul>
<ul class="nav navbar-nav pull-right">
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="__STATIC__/images/samples/scarlet-159.png" alt=""/>
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<a href="{:url('admin/User/edit')}">
<i class="fa fa-user"></i>
修改资料
</a>
</li>
<li>
<a href="{:url('admin/User/editpwd')}">
<i class="fa fa-cog"></i>
修改密码
</a>
</li>
<li>
<a href="{:url('admin/index/logout')}">
<i class="fa fa-power-off"></i>
退出后台
</a>
</li>
<li>
<a href="{:config('WEB_SITE_URL')}" target="_blank">
<i class="fa fa-home"></i>
前台首页
</a>
</li>
</ul>
</li>
<li class="visible-lg">
<a href="#" class="btn" onclick="helpIntro();">
<i class="fa fa-question-circle"></i>
操作指南
</a>
</li>
</ul>
</div>
</div>
</header>
<div id="page-wrapper" class="container nav-small">
<div class="row">
<div id="nav-col">
<section id="col-left" class="col-left-nano">
<div id="col-left-inner" class="col-left-nano-content">
<div id="sidebar-nav">
<ul class="nav nav-pills nav-stacked">
{volist name="__menu__['child']" id="nav"}
<li class="nav-header hidden-sm hidden-xs">{$key}</li>
{volist name="nav" id="item"}
{if isset($item['_child'])}
<li class="{$item['style']}">
<a href="#" class="dropdown-toggle">
<i class="fa fa-{$item['icon']|default='file'}"></i>
<span>{$item['title']}</span>
<i class="fa fa-angle-right drop-icon"></i>
</a>
<ul class="submenu">
{volist name="item['_child']" id="vo" key="k"}
<li class="{$vo['style']}">
<a href="{$vo['url']|url}">
<i class="fa fa-{$vo['icon']|default='file'}"></i>
<span>{$vo['title']}</span>
</a>
</li>
{/volist}
</ul>
</li>
{else/}
<li class="{$item['style']}">
<a href="{$item['url']|url}">
<i class="fa fa-{$item['icon']|default='file'}"></i>
<span>{$item['title']}</span>
</a>
</li>
{/if}
{/volist}
{/volist}
{if isset($extend_menu)}
{volist name="extend_menu" id="sub"}
{if is_string($key)}<li class="nav-header hidden-sm hidden-xs">{$key}</li>{/if}
{volist name="sub" id="item"}
<li class="{$item['style']}">
<a href="{$item['url']|url}">
<i class="fa fa-{$item['icon']|default='file'}"></i>
<span>{$item['title']}</span>
</a>
</li>
{/volist}
{/volist}
{/if}
</ul>
</div>
</div>
</section>
<div id="nav-col-submenu"></div>
</div>
<div id="content-wrapper">
<div class="row">
<div class="col-lg-12">
<div class="row">
<div class="col-lg-12">
<div id="content-header" class="clearfix">
<div class="pull-left">
<ol class="breadcrumb">
<li>
<a href="{:url('Admin/Index/index')}">后台首页</a>
</li>
<li class="active">
{if $meta_title}
<span>{$meta_title}</span>
{else/}
<span>{:lang(request()->controller().'_'.request()->action())}</span>
{/if}
</li>
</ol>
</div>
<div class="pull-right hidden-xs">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
{block name="body"}{/block}
</div>
</div>
</div>
</div>
<footer id="footer-bar" class="row">
<p id="footer-copyright" class="col-xs-12">Powered by <a href="http://www.tensent.cn" target="_blank">TenSent,Inc.</a></p>
</footer>
</div>
</div>
</div>
</div>
{include file="admin/public/tool" /}
{include file="admin/public/footer" /}
{block name="script"}{/block}

Some files were not shown because too many files have changed in this diff Show More