更新
This commit is contained in:
@@ -23,9 +23,13 @@ function is_administrator() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function hook() {}
|
||||
function form($field = [], $data = []) {
|
||||
return \app\http\form\Form::render($field, $data);
|
||||
}
|
||||
|
||||
function widget() {}
|
||||
function parse_field_bind(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端IP地址
|
||||
|
||||
@@ -8,8 +8,32 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller;
|
||||
|
||||
use \app\model\Form;
|
||||
|
||||
|
||||
class Front extends Base {
|
||||
public function index() {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function form(){
|
||||
if($this->request->isAjax()){
|
||||
|
||||
}else{
|
||||
$id = $this->request->param('id');
|
||||
$name = $this->request->param('name');
|
||||
|
||||
$map = [];
|
||||
|
||||
$map[] = ['id', '=', $id];
|
||||
|
||||
$info = Form::where($map)->find();
|
||||
|
||||
|
||||
$this->data = [
|
||||
'info' => $info
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
app/controller/Upload.php
Normal file
24
app/controller/Upload.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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\controller;
|
||||
|
||||
use think\facade\Session;
|
||||
|
||||
class Upload extends Base {
|
||||
|
||||
public $data = ['data' => [], 'code' => 0, 'msg' => ''];
|
||||
|
||||
protected function initialize() {
|
||||
}
|
||||
|
||||
public function ueditor(){
|
||||
$data = new \com\Ueditor(Session::get('userInfo.uid'));
|
||||
echo $data->output();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class Channel extends Admin {
|
||||
*/
|
||||
public function editable($name = null, $value = null, $pk = null) {
|
||||
if ($name && ($value != null || $value != '') && $pk) {
|
||||
model('Channel')->where(array('id' => $pk))->setField($name, $value);
|
||||
ChannelM::where(array('id' => $pk))->update([$name => $value]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,9 @@ class Channel extends Admin {
|
||||
*/
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$id = $Channel->save($data);
|
||||
$id = ChannelM::save($data);
|
||||
if ($id) {
|
||||
return $this->success('新增成功', url('index'));
|
||||
//记录行为
|
||||
@@ -70,21 +69,23 @@ class Channel extends Admin {
|
||||
return $this->error('新增失败');
|
||||
}
|
||||
} else {
|
||||
$this->error($Channel->getError());
|
||||
$this->error('新增失败');
|
||||
}
|
||||
} else {
|
||||
$pid = input('pid', 0);
|
||||
//获取父导航
|
||||
if (!empty($pid)) {
|
||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||
$parent = ChannelM::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('新增导航');
|
||||
$pnav = ChannelM::where(array('pid' => '0'))->select();
|
||||
|
||||
$this->data = [
|
||||
'pnav' => $pnav,
|
||||
'pid' => $pid,
|
||||
'info' => ['pid' => $pid]
|
||||
];
|
||||
return $this->fetch('edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Form as FormM;
|
||||
use app\model\FormAttr;
|
||||
|
||||
/**
|
||||
* @title 自定义表单
|
||||
@@ -37,44 +38,40 @@ class Form extends Admin {
|
||||
/**
|
||||
* @title 添加表单
|
||||
*/
|
||||
public function add(\think\Request $request) {
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Form')->save($request->post());
|
||||
$result = FormM::create($this->request->post());
|
||||
if (false !== $result) {
|
||||
return $this->success('添加成功!', url('admin/form/index'));
|
||||
return $this->success('添加成功!', url('/admin/form/index'));
|
||||
} else {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'keyList' => $this->model->addField,
|
||||
$this->data = array(
|
||||
'keyList' => (new FormM())->addField,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('添加表单');
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑表单
|
||||
*/
|
||||
public function edit(\think\Request $request) {
|
||||
public function edit() {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Form')->save($request->post(), array('id' => $request->post('id')));
|
||||
$result = FormM::update($this->request->post(), array('id' => $this->request->param('id')));
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功!', url('admin/form/index'));
|
||||
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 = FormM::where('id', $this->request->param('id'))->find();
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $this->model->editField,
|
||||
'keyList' => (new FormM())->editField,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('编辑表单');
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,17 +152,18 @@ class Form extends Admin {
|
||||
* @title 表单字段
|
||||
*/
|
||||
public function attr($form_id = '') {
|
||||
$map = array();
|
||||
$map = [];
|
||||
$order = "id desc";
|
||||
$list = $this->Fattr->where($map)->order($order)->paginate(25);
|
||||
|
||||
$data = array(
|
||||
$map[] = ['form_id', '=', $form_id];
|
||||
|
||||
$list = FormAttr::where($map)->order($order)->paginate(25);
|
||||
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'form_id' => $form_id,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->setMeta('表单字段');
|
||||
$this->assign($data);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -179,23 +177,18 @@ class Form extends Admin {
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = $this->Fattr->save($data);
|
||||
$result = FormAttr::create($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
|
||||
$this->data = array(
|
||||
'info' => ['form_id' => $form_id],
|
||||
'keyList' => $this->getField()
|
||||
);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $this->field
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('添加字段');
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,18 +240,19 @@ class Form extends Admin {
|
||||
}
|
||||
|
||||
protected function getField(){
|
||||
$config = \think\facade\Cache::get('system_config_data');
|
||||
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' => 'type', 'title' => '字段类型', 'help' => '用于表单中的展示方式', 'type' => 'select', 'option' => $config['config_type_list'], '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('name' => 'is_show', 'title' => '是否显示', 'help' => '是否显示在表单中', 'type' => 'select', 'option' => [['key'=>'1', 'label' => '始终显示'], ['key' => '2', 'label' => '新增显示'], ['key' => '3', 'label' => '编辑显示'], ['key' => '0', 'label' => '不显示']], 'value' => 1),
|
||||
array('name' => 'is_must', 'title' => '是否必填', 'help' => '用于自动验证', 'type' => 'select', 'option' => array(['key'=>'0', 'label' => '否'], ['key'=>'1', 'label' => '是'])),
|
||||
);
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -72,9 +72,9 @@ class Index extends Admin {
|
||||
$clear = input('post.clear/a', array());
|
||||
foreach ($clear as $key => $value) {
|
||||
if ($value == 'cache') {
|
||||
\think\Cache::clear(); // 清空缓存数据
|
||||
\think\facade\Cache::clear(); // 清空缓存数据
|
||||
} elseif ($value == 'log') {
|
||||
\think\Log::clear();
|
||||
\think\facade\Log::clear();
|
||||
}
|
||||
}
|
||||
return $this->success("更新成功!", url('/admin/index/index'));
|
||||
|
||||
@@ -67,12 +67,10 @@ class User extends Admin {
|
||||
} else {
|
||||
$info = $this->getUserinfo();
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $model->editfield,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑用户");
|
||||
return $this->fetch('public/edit');
|
||||
}
|
||||
}
|
||||
@@ -216,7 +214,6 @@ class User extends Admin {
|
||||
return $this->error($user->getError());
|
||||
}
|
||||
} else {
|
||||
$this->setMeta('修改密码');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
42
app/http/form/Factory.php
Normal file
42
app/http/form/Factory.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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\http\form;
|
||||
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* @title 后台中间件
|
||||
*/
|
||||
class Factory {
|
||||
|
||||
protected $field = [];
|
||||
protected $data = [];
|
||||
|
||||
public function __construct($field, $data){
|
||||
$this->field = $field;
|
||||
$this->data = $data;
|
||||
$this->parseValue();
|
||||
}
|
||||
|
||||
public function display($template = 'show', $data = []){
|
||||
View::config([
|
||||
'view_path' => dirname(__file__) . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR
|
||||
]);
|
||||
View::assign($data);
|
||||
return View::fetch('/' . $template, $this->field);
|
||||
}
|
||||
|
||||
protected function parseValue(){
|
||||
$this->field['value'] = isset($this->data[$this->field['name']]) ? $this->data[$this->field['name']] : '';
|
||||
}
|
||||
|
||||
public function show(){
|
||||
return $this->display($this->field['type']);
|
||||
}
|
||||
}
|
||||
33
app/http/form/Form.php
Normal file
33
app/http/form/Form.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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\http\form;
|
||||
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* @title 后台中间件
|
||||
*/
|
||||
class Form {
|
||||
|
||||
public static function render($field, $data){
|
||||
if (in_array($field['type'], ['string', 'text'])) {
|
||||
$field['type'] = 'text';
|
||||
}
|
||||
|
||||
$class = "app\\http\\form\\factory\\" . ucfirst($field['type']);
|
||||
|
||||
if (class_exists($class)) {
|
||||
$elem = new $class($field, $data);
|
||||
}else{
|
||||
$elem = new \app\http\form\Factory($field, $data);
|
||||
}
|
||||
|
||||
return $elem->show();
|
||||
}
|
||||
}
|
||||
26
app/http/form/factory/Checkbox.php
Normal file
26
app/http/form/factory/Checkbox.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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\http\form\factory;
|
||||
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* @title 后台中间件
|
||||
*/
|
||||
class Checkbox extends \app\http\form\Factory {
|
||||
|
||||
public function show(){
|
||||
return $this->display('checkbox');
|
||||
}
|
||||
|
||||
protected function parseValue(){
|
||||
$this->field['value'] = isset($this->data[$this->field['name']]) ? $this->data[$this->field['name']] : [];
|
||||
}
|
||||
|
||||
}
|
||||
22
app/http/form/factory/Text.php
Normal file
22
app/http/form/factory/Text.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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\http\form\factory;
|
||||
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* @title 后台中间件
|
||||
*/
|
||||
class Text extends \app\http\form\Factory {
|
||||
|
||||
public function show(){
|
||||
return $this->display('text');
|
||||
}
|
||||
|
||||
}
|
||||
6
app/http/form/template/checkbox.html
Normal file
6
app/http/form/template/checkbox.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{volist name="option" id="item"}
|
||||
<div class="checkbox-nice checkbox-inline">
|
||||
<input type="checkbox" name="{$name}[]" id="{$name}-{$key}" value="{$key}" {if in_array($key, $value)}checked{/if}/>
|
||||
<label for="{$name}-{$key}">{$item}</label>
|
||||
</div>
|
||||
{/volist}
|
||||
7
app/http/form/template/editor.html
Normal file
7
app/http/form/template/editor.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<textarea name="{$name}" id="{$name}" style="width: 100%;">{$value}</textarea>
|
||||
<!-- 实例化编辑器代码 -->
|
||||
<script type="text/javascript">
|
||||
var ue = UE.getEditor('{$name}', {
|
||||
serverUrl : "{:url('/upload/ueditor')}"
|
||||
});
|
||||
</script>
|
||||
47
app/http/form/template/images.html
Normal file
47
app/http/form/template/images.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<div class="picker-box">
|
||||
<div id="picker_{$name}" class="picker_button">上传图片</div>
|
||||
{if isset($value) && $value}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="{$value}">
|
||||
{else/}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="">
|
||||
{/if}
|
||||
<div id="fileList_{$name}" class="upload-file-list-info" style="width:280px;">
|
||||
{if $value}
|
||||
{php}
|
||||
$images = get_cover($value);
|
||||
{/php}
|
||||
<li class="affix-list-item" id="WU_FILE_0">
|
||||
<div class="upload-file-info">
|
||||
<span class="webuploader-pick-file-close" data-queued-id="WU_FILE_0" data-id="{$value}" data-fileurl="{$images['path']}"><i class="close"></i></span>
|
||||
<span class="fname"></span>
|
||||
<span class="fsize">上传时间:{$images['create_time']}</span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="filebox image">
|
||||
<img src="{:config('base_url')}{$images['path']}" class="img-responsive">
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
uploadsize = 2;
|
||||
$(function(){
|
||||
$("#picker_{$name}").SentUploader({
|
||||
compress:false,
|
||||
fileNumLimit:1,
|
||||
uploadEvents: {
|
||||
uploadComplete:function(file){}
|
||||
},
|
||||
listName : 'fileList_{$name}',
|
||||
hiddenName: 'field_{$name}',
|
||||
hiddenValType:1,
|
||||
fileSingleSizeLimit:uploadsize*1024*1024,
|
||||
closeX:true
|
||||
},
|
||||
{
|
||||
fileType: 'service',
|
||||
filename : 'images',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
5
app/http/form/template/select.html
Normal file
5
app/http/form/template/select.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<select class="form-control" name="{$name}" id="{$name}" style="width:auto;">
|
||||
{volist name="option" id="item"}
|
||||
<option value="{$item['key']}" {if $item['key'] == $value}selected{/if}>{$item['label']}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
1
app/http/form/template/text.html
Normal file
1
app/http/form/template/text.html
Normal file
@@ -0,0 +1 @@
|
||||
<input type="text" class="form-control" name="{$name}" id="{$name}" autocomplete="false" value="{$value}">
|
||||
1
app/http/form/template/textarea.html
Normal file
1
app/http/form/template/textarea.html
Normal file
@@ -0,0 +1 @@
|
||||
<textarea class="form-control" name="{$name}" id="{$name}">{$value}</textarea>
|
||||
@@ -9,6 +9,11 @@
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use think\facade\Config;
|
||||
use phpspirit\dbskeleton\mysql\TableModel;
|
||||
use phpspirit\dbskeleton\mysql\ColumnModel;
|
||||
use phpspirit\dbskeleton\Factory;
|
||||
|
||||
/**
|
||||
* 表单
|
||||
*/
|
||||
@@ -22,17 +27,40 @@ class Form extends \think\Model {
|
||||
'update_time' => 'integer',
|
||||
);
|
||||
|
||||
public $addField = array(
|
||||
array('name' => 'name', 'title' => '标识', 'type' => 'text', 'help' => ''),
|
||||
array('name' => 'title', 'title' => '标题', 'type' => 'text', 'help' => ''),
|
||||
);
|
||||
public $addField = [
|
||||
['name' => 'name', 'title' => '标识', 'type' => 'text', 'help' => ''],
|
||||
['name' => 'title', 'title' => '标题', 'type' => 'text', 'help' => ''],
|
||||
['name' => 'logo', 'title' => '显示Logo', 'type' => 'images', 'help' => ''],
|
||||
['name' => 'cover', 'title' => 'banner图片', 'type' => 'images', 'help' => ''],
|
||||
['name' => 'content', 'title' => '内容', 'type' => 'editor', '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' => ''),
|
||||
);
|
||||
public $editField = [
|
||||
['name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => ''],
|
||||
// ['name' => 'name', 'title' => '标识', 'type' => 'text', 'help' => ''],
|
||||
['name' => 'title', 'title' => '标题', 'type' => 'text', 'help' => ''],
|
||||
['name' => 'logo', 'title' => '显示Logo', 'type' => 'images', 'help' => ''],
|
||||
['name' => 'cover', 'title' => 'banner图片', 'type' => 'images', 'help' => ''],
|
||||
['name' => 'content', 'title' => '内容', 'type' => 'editor', 'help' => ''],
|
||||
['name' => 'list_grid', 'title' => '列表定义', 'type' => 'textarea', 'help' => ''],
|
||||
];
|
||||
|
||||
public static function onAfterInsert($model){
|
||||
$data = $model->getData();
|
||||
$mysql = Config::get('database.connections.mysql');
|
||||
$tablemodel = (new TableModel())->setCharset('utf8mb4') //设置编码
|
||||
->setEngine('MyISAM') //设置引擎
|
||||
->setTablename($mysql['prefix'] . 'form_' . $data['name']) //设置表名
|
||||
->setComment($data['title']); //表备注
|
||||
|
||||
$id = (new ColumnModel())->setType('int')->setLen(11)->setName('id')->setIsPk(true)->setIncrement(true)->setComment('自增长');
|
||||
|
||||
$dbskeleton = Factory::instance('mysql', $mysql['hostname'] . ':' . $mysql['hostport'], $mysql['database'], $mysql['username'], $mysql['password']);
|
||||
$dbskeleton->createTable($tablemodel, [$id]);
|
||||
|
||||
$dbskeleton->addColumn($tablemodel, (new ColumnModel())->setType('int')->setLen(11)->setName('create_time')->setIsPk(false)->setIncrement(false)->setComment('创建时间'));
|
||||
$dbskeleton->addColumn($tablemodel, (new ColumnModel())->setType('int')->setLen(11)->setName('update_time')->setIsPk(false)->setIncrement(false)->setComment('更新时间'));
|
||||
}
|
||||
|
||||
// protected static function init() {
|
||||
// self::beforeInsert(function ($event) {
|
||||
|
||||
@@ -6,51 +6,75 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use think\facade\Config;
|
||||
use phpspirit\dbskeleton\mysql\TableModel;
|
||||
use phpspirit\dbskeleton\mysql\ColumnModel;
|
||||
use phpspirit\dbskeleton\Factory;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class FormAttr {
|
||||
class FormAttr extends \think\Model{
|
||||
|
||||
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 static function onAfterInsert($model){
|
||||
$data = $model->getData();
|
||||
$mysql = Config::get('database.connections.mysql');
|
||||
|
||||
$dbskeleton = Factory::instance('mysql', $mysql['hostname'] . ':' . $mysql['hostport'], $mysql['database'], $mysql['username'], $mysql['password']);
|
||||
$field = (new ColumnModel())->setType('int')
|
||||
->setLen($data['length'])
|
||||
->setName($data['name'])
|
||||
->setComment($data['title']);
|
||||
$dbskeleton->addColumn($tablemodel, );
|
||||
|
||||
}
|
||||
|
||||
protected static function onBeforeUpdate($model){
|
||||
$data = $model->getData();
|
||||
$mysql = Config::get('database.connections.mysql');
|
||||
|
||||
$dbskeleton = Factory::instance('mysql', $mysql['hostname'] . ':' . $mysql['hostport'], $mysql['database'], $mysql['username'], $mysql['password']);
|
||||
}
|
||||
|
||||
// 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']]);
|
||||
|
||||
@@ -45,7 +45,7 @@ class Member extends Model {
|
||||
}
|
||||
|
||||
protected function getAccessTokenAttr($value, $data) {
|
||||
$token = ['data' => ['uid' => $data['uid'], 'username' => $data['username'], 'password' => $data['password'], 'department' => $data['department']]];
|
||||
$token = ['data' => ['uid' => $data['uid'], 'username' => $data['username'], 'password' => $data['password']]];
|
||||
return JWTAuth::builder($token); //参数为用户认证的信息,请自行添加
|
||||
}
|
||||
|
||||
|
||||
94
app/ueditor.json
Normal file
94
app/ueditor.json
Normal file
@@ -0,0 +1,94 @@
|
||||
/* 前后端通信相关的配置,注释只允许使用多行方式 */
|
||||
{
|
||||
/* 上传图片配置项 */
|
||||
"imageActionName": "uploadimage", /* 执行上传图片的action名称 */
|
||||
"imageFieldName": "upfile", /* 提交的图片表单名称 */
|
||||
"imageMaxSize": 2048000, /* 上传大小限制,单位B */
|
||||
"imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
|
||||
"imageCompressEnable": true, /* 是否压缩图片,默认是true */
|
||||
"imageCompressBorder": 1600, /* 图片压缩最长边限制 */
|
||||
"imageInsertAlign": "none", /* 插入的图片浮动方式 */
|
||||
"imageUrlPrefix": "", /* 图片访问路径前缀 */
|
||||
"imagePathFormat": "./uploads/editor/image", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
/* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */
|
||||
/* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */
|
||||
/* {time} 会替换成时间戳 */
|
||||
/* {yyyy} 会替换成四位年份 */
|
||||
/* {yy} 会替换成两位年份 */
|
||||
/* {mm} 会替换成两位月份 */
|
||||
/* {dd} 会替换成两位日期 */
|
||||
/* {hh} 会替换成两位小时 */
|
||||
/* {ii} 会替换成两位分钟 */
|
||||
/* {ss} 会替换成两位秒 */
|
||||
/* 非法字符 \ : * ? " < > | */
|
||||
/* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */
|
||||
|
||||
/* 涂鸦图片上传配置项 */
|
||||
"scrawlActionName": "uploadscrawl", /* 执行上传涂鸦的action名称 */
|
||||
"scrawlFieldName": "upfile", /* 提交的图片表单名称 */
|
||||
"scrawlPathFormat": "./uploads/editor/image", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
"scrawlMaxSize": 2048000, /* 上传大小限制,单位B */
|
||||
"scrawlUrlPrefix": "", /* 图片访问路径前缀 */
|
||||
"scrawlInsertAlign": "none",
|
||||
|
||||
/* 截图工具上传 */
|
||||
"snapscreenActionName": "uploadimage", /* 执行上传截图的action名称 */
|
||||
"snapscreenPathFormat": "./uploads/editor/image", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
"snapscreenUrlPrefix": "", /* 图片访问路径前缀 */
|
||||
"snapscreenInsertAlign": "none", /* 插入的图片浮动方式 */
|
||||
|
||||
/* 抓取远程图片配置 */
|
||||
"catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
|
||||
"catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */
|
||||
"catcherFieldName": "source", /* 提交的图片列表表单名称 */
|
||||
"catcherPathFormat": "./uploads/editor/image", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
"catcherUrlPrefix": "", /* 图片访问路径前缀 */
|
||||
"catcherMaxSize": 2048000, /* 上传大小限制,单位B */
|
||||
"catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 抓取图片格式显示 */
|
||||
|
||||
/* 上传视频配置 */
|
||||
"videoActionName": "uploadvideo", /* 执行上传视频的action名称 */
|
||||
"videoFieldName": "upfile", /* 提交的视频表单名称 */
|
||||
"videoPathFormat": "./uploads/editor/video", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
"videoUrlPrefix": "", /* 视频访问路径前缀 */
|
||||
"videoMaxSize": 102400000, /* 上传大小限制,单位B,默认100MB */
|
||||
"videoAllowFiles": [
|
||||
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
|
||||
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], /* 上传视频格式显示 */
|
||||
|
||||
/* 上传文件配置 */
|
||||
"fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */
|
||||
"fileFieldName": "upfile", /* 提交的文件表单名称 */
|
||||
"filePathFormat": "./uploads/editor/file", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
"fileUrlPrefix": "", /* 文件访问路径前缀 */
|
||||
"fileMaxSize": 51200000, /* 上传大小限制,单位B,默认50MB */
|
||||
"fileAllowFiles": [
|
||||
".png", ".jpg", ".jpeg", ".gif", ".bmp",
|
||||
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
|
||||
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
|
||||
".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
|
||||
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
|
||||
], /* 上传文件格式显示 */
|
||||
|
||||
/* 列出指定目录下的图片 */
|
||||
"imageManagerActionName": "listimage", /* 执行图片管理的action名称 */
|
||||
"imageManagerListPath": "./uploads/editor/image/", /* 指定要列出图片的目录 */
|
||||
"imageManagerListSize": 20, /* 每次列出文件数量 */
|
||||
"imageManagerUrlPrefix": "", /* 图片访问路径前缀 */
|
||||
"imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */
|
||||
"imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 列出的文件类型 */
|
||||
|
||||
/* 列出指定目录下的文件 */
|
||||
"fileManagerActionName": "listfile", /* 执行文件管理的action名称 */
|
||||
"fileManagerListPath": "./uploads/editor/file/", /* 指定要列出文件的目录 */
|
||||
"fileManagerUrlPrefix": "", /* 文件访问路径前缀 */
|
||||
"fileManagerListSize": 20, /* 每次列出文件数量 */
|
||||
"fileManagerAllowFiles": [
|
||||
".png", ".jpg", ".jpeg", ".gif", ".bmp",
|
||||
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
|
||||
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
|
||||
".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
|
||||
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
|
||||
] /* 列出的文件类型 */
|
||||
|
||||
}
|
||||
@@ -30,7 +30,9 @@
|
||||
"topthink/think-captcha": "^3.0",
|
||||
"sent/think-jwt": "^1.0",
|
||||
"xin/helper": "^1.0",
|
||||
"sent/tree": "^1.0"
|
||||
"sent/tree": "^1.0",
|
||||
"lotofbadcode/phpspirit_dbskeleton": "^1.0",
|
||||
"sent/think-addons": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/var-dumper": "^4.2"
|
||||
|
||||
17
config/addons.php
Normal file
17
config/addons.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | thinkphp5 Addons [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016 http://www.zzstudio.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Byron Sampson <xiaobo.sun@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
'autoload' => true,
|
||||
'hooks' => [],
|
||||
'route' => [],
|
||||
'service' => [],
|
||||
];
|
||||
@@ -27,7 +27,7 @@ return [
|
||||
// 独立日志级别
|
||||
'apart_level' => [],
|
||||
// 最大日志文件数量
|
||||
'max_files' => 0,
|
||||
'max_files' => 30,
|
||||
// 使用JSON格式记录
|
||||
'json' => false,
|
||||
// 日志处理
|
||||
|
||||
275
extend/com/Datatable.php
Normal file
275
extend/com/Datatable.php
Normal file
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: colin <colin@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace com;
|
||||
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 数据库管理类
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
class Datatable {
|
||||
|
||||
protected $table; /*数据库操作的表*/
|
||||
protected $fields = array(); /*数据库操作字段*/
|
||||
protected $charset = 'utf8'; /*数据库操作字符集*/
|
||||
public $prefix = ''; /*数据库操作表前缀*/
|
||||
protected $model_table_prefix = ''; /*模型默认创建的表前缀*/
|
||||
protected $engine_type = 'MyISAM'; /*数据库引擎*/
|
||||
protected $key = 'id'; /*数据库主键*/
|
||||
public $sql = ''; /*最后生成的sql语句*/
|
||||
protected $typeAlist = array(
|
||||
"text" => "VARCHAR",
|
||||
"string" => "VARCHAR",
|
||||
"password" => "VARCHAR",
|
||||
"textarea" => "TEXT",
|
||||
"bool" => "INT",
|
||||
"select" => "INT",
|
||||
"num" => "INT",
|
||||
"decimal" => "DECIMAL",
|
||||
"tags" => "VARCHAR",
|
||||
"datetime" => "INT",
|
||||
"date" => "INT",
|
||||
"editor" => "TEXT",
|
||||
"bind" => "INT",
|
||||
"image" => "INT",
|
||||
"images" => "VARCHAR",
|
||||
"attach" => "VARCHAR",
|
||||
);
|
||||
|
||||
/**
|
||||
* 初始化数据库信息
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function __construct() {
|
||||
//创建DB对象
|
||||
$this->prefix = Config::get('database.prefix');
|
||||
$this->model_table_prefix = Config::get('model_table_prefix');
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 初始化表
|
||||
* @description 初始化创建表
|
||||
* @Author molong
|
||||
* @DateTime 2017-06-11
|
||||
* @param string $table 表名
|
||||
* @return void 空
|
||||
*/
|
||||
public function initTable($table = '', $comment = '', $pk = 'id') {
|
||||
$this->table = $this->getTablename($table, true);
|
||||
|
||||
$sql = $this->generateField($pk, 'int', 11, '', '主键', true);
|
||||
|
||||
$primary = $pk ? "PRIMARY KEY (`" . $pk . "`)" : '';
|
||||
$generatesql = $sql . ',';
|
||||
|
||||
$create = "CREATE TABLE IF NOT EXISTS `" . $this->table . "`("
|
||||
. $generatesql
|
||||
. $primary
|
||||
. ") ENGINE=" . $this->engine_type . " AUTO_INCREMENT=1 DEFAULT CHARSET=" . $this->charset . " ROW_FORMAT=DYNAMIC COMMENT='" . $comment . "';";
|
||||
$this->sql = $create;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速创建ID字段
|
||||
* @var length 字段的长度
|
||||
* @var comment 字段的描述
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function generateField($key = '', $type = '', $length = 11, $default = '', $comment = '主键', $is_auto_increment = false) {
|
||||
if ($key && $type) {
|
||||
$auto_increment = $is_auto_increment ? 'AUTO_INCREMENT' : '';
|
||||
$field_type = $length ? $type . '(' . $length . ')' : $type;
|
||||
$signed = in_array($type, array('int', 'float', 'double')) ? 'signed' : '';
|
||||
$comment = $comment ? "COMMENT '" . $comment . "'" : "";
|
||||
$default = $default ? "DEFAULT '" . $default . "'" : "";
|
||||
$sql = "`{$key}` {$field_type} {$signed} NOT NULL {$default} $auto_increment {$comment}";
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加字段
|
||||
* @var $table 追加字段的表名
|
||||
* @var $attr 属性列表
|
||||
* @var $is_more 是否为多条同时插入
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function columField($table, $attr = array()) {
|
||||
$field_attr['table'] = $table ? $this->getTablename($table, true) : $this->table;
|
||||
$field_attr['name'] = $attr['name'];
|
||||
$field_attr['type'] = $attr['type'] ? $this->typeAlist[$attr['type']] : 'varchar';
|
||||
if (intval($attr['length']) && $attr['length']) {
|
||||
$field_attr['length'] = "(" . $attr['length'] . ")";
|
||||
} else {
|
||||
$field_attr['length'] = "";
|
||||
}
|
||||
$field_attr['is_null'] = $attr['is_must'] ? 'NOT NULL' : 'NULL';
|
||||
$field_attr['default'] = $attr['value'] != '' ? 'DEFAULT "' . $attr['value'] . '"' : '';
|
||||
|
||||
$field_attr['comment'] = (isset($attr['remark']) && $attr['remark']) ? $attr['remark'] : $attr['title'];
|
||||
$field_attr['after'] = (isset($attr['after']) && $attr['after']) ? ' AFTER `' . $attr['after'] . '`' : ' AFTER `id`';
|
||||
$field_attr['action'] = (isset($attr['action']) && $attr['action']) ? $attr['action'] : 'ADD';
|
||||
//确认表是否存在
|
||||
|
||||
if ($field_attr['action'] == 'ADD') {
|
||||
$this->sql = "ALTER TABLE `{$field_attr['table']}` ADD `{$field_attr['name']}` {$field_attr['type']}{$field_attr['length']} {$field_attr['is_null']} {$field_attr['default']} COMMENT '{$field_attr['comment']}' {$field_attr['after']}";
|
||||
} elseif ($field_attr['action'] == 'CHANGE') {
|
||||
$field_attr['oldname'] = (isset($attr['oldname']) && $attr['oldname']) ? $attr['oldname'] : '';
|
||||
|
||||
$this->sql = "ALTER TABLE `{$field_attr['table']}` CHANGE `{$field_attr['oldname']}` `{$field_attr['name']}` {$field_attr['type']}{$field_attr['length']} {$field_attr['is_null']} {$field_attr['default']} COMMENT '{$field_attr['comment']}'";
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字段
|
||||
* @var $table 追加字段的表名
|
||||
* @var $field 字段名
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function delField($table, $field) {
|
||||
$table = $table ? $this->getTablename($table, true) : $this->table;
|
||||
$this->sql = "ALTER TABLE `$table` DROP `$field`";
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据表
|
||||
* @var $table 追加字段的表名
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function delTable($table) {
|
||||
$table = $table ? $this->getTablename($table, true) : $this->table;
|
||||
$this->sql = "DROP TABLE `$table`";
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束表
|
||||
* @var $engine_type 数据库引擎
|
||||
* @var $comment 表注释
|
||||
* @var $charset 数据库编码
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function endTable($comment, $engine_type = null, $charset = null) {
|
||||
if (null != $charset) {
|
||||
$this->charset = $charset;
|
||||
}
|
||||
if (null != $engine_type) {
|
||||
$this->engine_type = $engine_type;
|
||||
}
|
||||
$end = "ENGINE=" . $this->engine_type . " AUTO_INCREMENT=1 DEFAULT CHARSET=" . $this->charset . " ROW_FORMAT=DYNAMIC COMMENT='" . $comment . "';";
|
||||
$this->sql .= ")" . $end;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建动作
|
||||
* @return int 0
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function create() {
|
||||
$res = Db::execute($this->sql);
|
||||
return $res !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* create的别名
|
||||
* @return int 0
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function query() {
|
||||
return $this->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最后生成的sql语句
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function getLastSql() {
|
||||
return $this->sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定的表名
|
||||
* @var $table 要获取名字的表名
|
||||
* @var $prefix 获取表前缀? 默认为不获取 false
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function getTablename($table, $prefix = false) {
|
||||
if (false == $prefix) {
|
||||
$this->table = $this->model_table_prefix . $table;
|
||||
} else {
|
||||
$this->table = $this->prefix . $this->model_table_prefix . $table;
|
||||
}
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定表名的所有字段及详细信息
|
||||
* @var $table 要获取名字的表名 可以为sent_tengsu_photo、tengsu_photo、photo
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function getFields($table) {
|
||||
if (false == $table) {
|
||||
$table = $this->table; //为空调用当前table
|
||||
} else {
|
||||
$table = $table;
|
||||
}
|
||||
$patten = "/\./";
|
||||
if (!preg_match_all($patten, $table)) {
|
||||
//匹配_
|
||||
$patten = "/_+/";
|
||||
if (!preg_match_all($patten, $table)) {
|
||||
$table = $this->prefix . $this->model_table_prefix . $table;
|
||||
} else {
|
||||
//匹配是否包含表前缀,如果是 那么就是手动输入
|
||||
$patten = "/$this->prefix/";
|
||||
if (!preg_match_all($patten, $table)) {
|
||||
$table = $this->prefix . $table;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = "SHOW FULL FIELDS FROM $table";
|
||||
return Db::query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认表是否存在
|
||||
* @var $table 表名 可以为sent_tengsu_photo、tengsu_photo、photo
|
||||
* @author colin <colin@tensent.cn>
|
||||
* @return boolen
|
||||
*/
|
||||
public function CheckTable($table) {
|
||||
//获取表名
|
||||
$this->table = $this->getTablename($table, true);
|
||||
$result = Db::execute("SHOW TABLES LIKE '%$this->table%'");
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认字段是否存在
|
||||
* @var $table 表名 可以为sent_tengsu_photo、tengsu_photo、photo
|
||||
* @var $field 字段名 要检查的字段名
|
||||
* @author colin <colin@tensent.cn>
|
||||
* @return boolen
|
||||
*/
|
||||
public function CheckField($table, $field) {
|
||||
//检查字段是否存在
|
||||
$table = $this->getTablename($table, true);
|
||||
if (!Db::query("Describe $table $field")) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
354
extend/com/Ueditor.php
Normal file
354
extend/com/Ueditor.php
Normal file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
/**
|
||||
* Ueditor插件
|
||||
* @author Nintendov
|
||||
*/
|
||||
|
||||
namespace com;
|
||||
|
||||
class Ueditor {
|
||||
|
||||
public $uid; //要操作的用户id 如有登录需要则去掉注释
|
||||
private $output; //要输出的数据
|
||||
private $st;
|
||||
private $rootpath = '/uploads';
|
||||
private $config = '';
|
||||
|
||||
public function __construct($uid = '') {
|
||||
//uid 为空则导入当前会话uid
|
||||
if ('' === $uid) {
|
||||
$this->uid = session('user_auth.uid');
|
||||
}
|
||||
|
||||
//导入设置
|
||||
$this->config = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents(app()->getAppPath() . "ueditor.json")), true);
|
||||
|
||||
$action = htmlspecialchars($_GET['action']);
|
||||
|
||||
switch ($action) {
|
||||
case 'config':
|
||||
$result = json_encode($this->config);
|
||||
break;
|
||||
|
||||
case 'uploadimage':
|
||||
$config = array(
|
||||
"pathFormat" => $this->config['imagePathFormat'],
|
||||
"maxSize" => $this->config['imageMaxSize'],
|
||||
"allowFiles" => $this->config['imageAllowFiles'],
|
||||
);
|
||||
$fieldName = $this->config['imageFieldName'];
|
||||
$result = $this->uploadFile($config, $fieldName);
|
||||
break;
|
||||
|
||||
case 'uploadscrawl':
|
||||
$config = array(
|
||||
"pathFormat" => $this->config['scrawlPathFormat'],
|
||||
"maxSize" => $this->config['scrawlMaxSize'],
|
||||
"allowFiles" => $this->config['scrawlAllowFiles'],
|
||||
"oriName" => "scrawl.png",
|
||||
);
|
||||
$fieldName = $this->config['scrawlFieldName'];
|
||||
$result = $this->uploadBase64($config, $fieldName);
|
||||
break;
|
||||
|
||||
case 'uploadvideo':
|
||||
$config = array(
|
||||
"pathFormat" => $this->config['videoPathFormat'],
|
||||
"maxSize" => $this->config['videoMaxSize'],
|
||||
"allowFiles" => $this->config['videoAllowFiles'],
|
||||
);
|
||||
$fieldName = $this->config['videoFieldName'];
|
||||
$result = $this->uploadFile($config, $fieldName);
|
||||
break;
|
||||
|
||||
case 'uploadfile':
|
||||
// default:
|
||||
$config = array(
|
||||
"pathFormat" => $this->config['filePathFormat'],
|
||||
"maxSize" => $this->config['fileMaxSize'],
|
||||
"allowFiles" => $this->config['fileAllowFiles'],
|
||||
);
|
||||
$fieldName = $this->config['fileFieldName'];
|
||||
$result = $this->uploadFile($config, $fieldName);
|
||||
break;
|
||||
|
||||
case 'listfile':
|
||||
$config = array(
|
||||
'allowFiles' => $this->config['fileManagerAllowFiles'],
|
||||
'listSize' => $this->config['fileManagerListSize'],
|
||||
'path' => $this->config['fileManagerListPath'],
|
||||
);
|
||||
$result = $this->listFile($config);
|
||||
break;
|
||||
|
||||
case 'listimage':
|
||||
$config = array(
|
||||
'allowFiles' => $this->config['imageManagerAllowFiles'],
|
||||
'listSize' => $this->config['imageManagerListSize'],
|
||||
'path' => $this->config['imageManagerListPath'],
|
||||
);
|
||||
$result = $this->listFile($config);
|
||||
break;
|
||||
|
||||
case 'catchimage':
|
||||
$config = array(
|
||||
"pathFormat" => $this->config['catcherPathFormat'],
|
||||
"maxSize" => $this->config['catcherMaxSize'],
|
||||
"allowFiles" => $this->config['catcherAllowFiles'],
|
||||
"oriName" => "remote.png",
|
||||
);
|
||||
$fieldName = $this->config['catcherFieldName'];
|
||||
$result = $this->saveRemote($config, $fieldName);
|
||||
break;
|
||||
|
||||
default:
|
||||
$result = json_encode(array(
|
||||
'state' => 'wrong require',
|
||||
));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET["callback"])) {
|
||||
if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
|
||||
$this->output = htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
|
||||
} else {
|
||||
$this->output = json_encode(array(
|
||||
'state' => 'callback参数不合法',
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$this->output = $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 输出结果
|
||||
* @param data 数组数据
|
||||
* @return 组合后json格式的结果
|
||||
*/
|
||||
public function output() {
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件方法
|
||||
*
|
||||
*/
|
||||
private function uploadFile($config, $fieldName) {
|
||||
$file = request()->file('upfile');
|
||||
if (is_array($config['allowFiles'])) {
|
||||
$config['allowFiles'] = str_replace('.', '', implode(',', $config['allowFiles']));
|
||||
}else{
|
||||
$config['allowFiles'] = '';
|
||||
}
|
||||
$info = $file->validate(array('size'=>$config['maxSize'], 'ext'=>$config['allowFiles']))->move($config['pathFormat'], true, false);
|
||||
|
||||
if ($info) {
|
||||
$data = array(
|
||||
'state' => "SUCCESS",
|
||||
'url' => str_replace("\\", '/', substr($info->getPathname(), 1)),
|
||||
'title' => $info->getSaveName(),
|
||||
'original' => $info->getFilename(),
|
||||
'type' => '.' . $info->getExtension(),
|
||||
'size' => $info->getSize(),
|
||||
);
|
||||
} else {
|
||||
$data = array(
|
||||
"state" => $file->getError(),
|
||||
);
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
*/
|
||||
private function uploadBase64($config, $fieldName) {
|
||||
$data = array();
|
||||
|
||||
$base64Data = $_POST[$fieldName];
|
||||
$img = base64_decode($base64Data);
|
||||
$path = $this->getFullPath($config['pathFormat']);
|
||||
|
||||
if (strlen($img) > $config['maxSize']) {
|
||||
$data['states'] = 'too large';
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
$rootpath = $this->rootpath;
|
||||
|
||||
//替换随机字符串
|
||||
$imgname = uniqid() . '.png';
|
||||
$filename = $path . $imgname;
|
||||
|
||||
if (\Think\Storage::put($rootpath, $filename, $img)) {
|
||||
$data = array(
|
||||
'state' => 'SUCCESS',
|
||||
'url' => $rootpath . $filename,
|
||||
'title' => $imgname,
|
||||
'original' => 'scrawl.png',
|
||||
'type' => '.png',
|
||||
'size' => strlen($img),
|
||||
|
||||
);
|
||||
} else {
|
||||
$data = array(
|
||||
'state' => 'cant write',
|
||||
);
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出文件夹下所有文件,如果是目录则向下
|
||||
*/
|
||||
private function listFile($config) {
|
||||
$allowFiles = substr(str_replace(".", "|", join("", $config['allowFiles'])), 1);
|
||||
$size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $config['listSize'];
|
||||
$start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0;
|
||||
$end = $start + $size;
|
||||
|
||||
$rootpath = $this->rootpath;
|
||||
|
||||
$path = $config['path'];
|
||||
$files = \Think\Storage::listFile($rootpath, $path, $allowFiles);
|
||||
//return $files;
|
||||
if (!count($files)) {
|
||||
return json_encode(array(
|
||||
"state" => "no match file",
|
||||
"list" => array(),
|
||||
"start" => $start,
|
||||
"total" => count($files),
|
||||
));
|
||||
}
|
||||
|
||||
/* 获取指定范围的列表 */
|
||||
$len = count($files);
|
||||
for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--) {
|
||||
$list[] = $files[$i];
|
||||
}
|
||||
//倒序
|
||||
//for ($i = $end, $list = array(); $i < $len && $i < $end; $i++){
|
||||
// $list[] = $files[$i];
|
||||
//}
|
||||
|
||||
/* 返回数据 */
|
||||
$result = json_encode(array(
|
||||
"state" => "SUCCESS",
|
||||
"list" => $list,
|
||||
"start" => $start,
|
||||
"total" => count($files),
|
||||
));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
*/
|
||||
private function saveRemote($config, $fieldName) {
|
||||
$list = array();
|
||||
if (isset($_POST[$fieldName])) {
|
||||
$source = $_POST[$fieldName];
|
||||
} else {
|
||||
$source = $_GET[$fieldName];
|
||||
}
|
||||
foreach ($source as $imgUrl) {
|
||||
$upload = new \org\Upload();
|
||||
|
||||
$imgUrl = htmlspecialchars($imgUrl);
|
||||
$imgUrl = str_replace("&", "&", $imgUrl);
|
||||
|
||||
//http开头验证
|
||||
if (strpos($imgUrl, "http") !== 0) {
|
||||
$data = array('state' => '不是http链接');
|
||||
return json_encode($data);
|
||||
}
|
||||
//格式验证(扩展名验证和Content-Type验证)
|
||||
$fileType = strtolower(strrchr($imgUrl, '.'));
|
||||
if (!in_array($fileType, $config['allowFiles']) || stristr($heads['Content-Type'], "image")) {
|
||||
$data = array("state" => "错误文件格式");
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
//打开输出缓冲区并获取远程图片
|
||||
ob_start();
|
||||
$context = stream_context_create(
|
||||
array('http' => array(
|
||||
'follow_location' => false, // don't follow redirects
|
||||
))
|
||||
);
|
||||
readfile($imgUrl, false, $context);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
preg_match("/[\/]([^\/]*)[\.]?[^\.\/]*$/", $imgUrl, $m);
|
||||
|
||||
$path = $this->getFullPath($config['pathFormat']);
|
||||
if (strlen($img) > $config['maxSize']) {
|
||||
$data['states'] = 'too large';
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
$rootpath = $this->rootpath;
|
||||
|
||||
$imgname = uniqid() . '.png';
|
||||
$filename = $path . $imgname;
|
||||
|
||||
$oriName = $m ? $m[1] : "";
|
||||
|
||||
if (\Think\Storage::put($rootpath, $filename, $img)) {
|
||||
array_push($list, array(
|
||||
"state" => 'SUCCESS',
|
||||
"url" => \Think\Storage::getPath($rootpath, $filename),
|
||||
"size" => strlen($img),
|
||||
"title" => $imgname,
|
||||
"original" => $oriName,
|
||||
"source" => htmlspecialchars($imgUrl),
|
||||
));
|
||||
} else {
|
||||
array_push($list, array('state' => '文件写入失败'));
|
||||
}
|
||||
}
|
||||
|
||||
/* 返回抓取数据 */
|
||||
return json_encode(array(
|
||||
'state' => count($list) ? 'SUCCESS' : 'ERROR',
|
||||
'list' => $list,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则替换命名文件
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
private function getFullPath($path) {
|
||||
//替换日期事件
|
||||
$t = time();
|
||||
$d = explode('-', date("Y-y-m-d-H-i-s"));
|
||||
$format = $path;
|
||||
$format = str_replace("{yyyy}", $d[0], $format);
|
||||
$format = str_replace("{yy}", $d[1], $format);
|
||||
$format = str_replace("{mm}", $d[2], $format);
|
||||
$format = str_replace("{dd}", $d[3], $format);
|
||||
$format = str_replace("{hh}", $d[4], $format);
|
||||
$format = str_replace("{ii}", $d[5], $format);
|
||||
$format = str_replace("{ss}", $d[6], $format);
|
||||
$format = str_replace("{uid}", $this->uid, $format);
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
private function format_exts($exts) {
|
||||
$data = array();
|
||||
foreach ($exts as $key => $value) {
|
||||
$data[] = ltrim($value, '.');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
50
public/template/front/form.html
Normal file
50
public/template/front/form.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{$info['title']}</title>
|
||||
<style type="text/css">
|
||||
body{background: #e6e7e8; color: #555555; margin: 0; padding: 0; font-size: 12px;}
|
||||
.form-box{width: 1020px; margin: auto; box-shadow: 0px 8px 8px #a1a1a1;min-height: 1000px; background: #ffffff; position: relative;}
|
||||
.logo{padding: 20px;}
|
||||
.banner{position: relative;}
|
||||
|
||||
.form-body{display: flex;}
|
||||
.form-body .content{padding: 10px; font-size: 14px;}
|
||||
.form-body .item{width: 50%;}
|
||||
|
||||
.form{padding-bottom: 20px;}
|
||||
.form .title, .relation .title{font-size: 18px; line-height: 45px;}
|
||||
.form .c, .relation .c{background: #f1f1f1; padding: 10px;}
|
||||
|
||||
.footer{background: #e6e7e8; position: absolute; left: 0; right: 0; bottom: 0; text-align: center; line-height: 30px; padding: 10px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="form-box">
|
||||
<div class="logo"><img src="https://na-ab25.marketo.com/rs/informaticacorp/images/logo.png" alt=""></div>
|
||||
|
||||
<div class="banner"><img src="https://now.informatica.com/rs/867-MAO-634/images/lp01-SpringLaunch20.jpg"></div>
|
||||
|
||||
<div class="form-body">
|
||||
<div class="content item">
|
||||
{$info['content']|raw}
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="form">
|
||||
<div class="title">立即注册</div>
|
||||
<div class="c"></div>
|
||||
</div>
|
||||
<div class="relation">
|
||||
<div class="title">教师</div>
|
||||
<div class="c"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
© 2020 Informatica LLC. All Rights Reserved.www.informatica.comContact Us|Terms of Use|Privacy Policy
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,7 +16,9 @@ Route::rule('lists', 'Front/lists');
|
||||
Route::rule('detail-:id', 'Front/detail');
|
||||
Route::rule('category', 'Front/category');
|
||||
Route::rule('topic-:id', 'Front/topic');
|
||||
Route::rule('form/:id/:name', 'Front/form');
|
||||
Route::rule('front/:function', 'Front/:function');
|
||||
Route::rule('upload/:function', 'Upload/:function');
|
||||
|
||||
Route::group('admin', function () {
|
||||
Route::rule('/', 'admin.Index/index');
|
||||
|
||||
1
view/admin/channel/add.html
Normal file
1
view/admin/channel/add.html
Normal file
@@ -0,0 +1 @@
|
||||
{$formHtml|raw}
|
||||
@@ -47,8 +47,8 @@
|
||||
<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 $item['id'] != $info['id']}
|
||||
<option value="{$item['id']}" {if $pid == $item['id']}selected{/if}>{$item['title_show']}</option>
|
||||
{/if}
|
||||
{/volist}
|
||||
</select>
|
||||
@@ -59,7 +59,7 @@
|
||||
<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 value="1" {if isset($info['target']) && $info['target'] == 1}selected{/if}>是
|
||||
</option>
|
||||
</select>
|
||||
<span class="help-block">(是否新窗口打开链接)</span>
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
<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>
|
||||
<a class="btn btn-primary" href="{:url('/admin/channel/add')}">新 增</a>
|
||||
<button class="btn btn-danger ajax-post confirm" url="{:url('/admin/channel/del')}" target-form="ids">删 除</button>
|
||||
<button class="btn btn-success list_sort" url="{:url('/admin/channel/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>
|
||||
<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>
|
||||
<a href="{:url('/admin/channel/index',array('type'=>$key))}">{$item}</a>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
@@ -46,13 +46,13 @@
|
||||
<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'])}">
|
||||
<a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="title" data-type="text" data-pk="{$list['id']}" data-url="{:url('/admin/channel/editable')}">{$list['title']} </a>
|
||||
<a class="add-sub-cate" title="添加子分类" href="{:url('/admin/channel/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><a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="sort" data-type="text" data-pk="{$list['id']}" data-url="{:url('/admin/channel/editable')}">{$list['sort']}</a></td>
|
||||
<td>
|
||||
{if $list['status']}
|
||||
<span class="label label-primary">{$list.status|get_status_title}</span>
|
||||
@@ -61,9 +61,9 @@
|
||||
{/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>
|
||||
<a title="编辑" href="{:url('/admin/channel/edit?id='.$list['id'].'&pid='.$list['pid'])}">编辑</a>
|
||||
<a title="{$list.status|show_status_op}" href="{:url('/admin/channel/setStatus', ['ids'=>$list['id'], 'status'=>abs(1-$list['status'])])}" class="ajax-get">{$list.status|show_status_op}</a>
|
||||
<a title="删除" href="{:url('/admin/channel/del', ['id' =>$list['id']])}" class="confirm ajax-get">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
@@ -94,7 +94,7 @@ $(function() {
|
||||
}
|
||||
|
||||
if(url != undefined && url != ''){
|
||||
window.location.href = url + '/ids/' + param;
|
||||
window.location.href = url + '?ids=' + param;
|
||||
}
|
||||
});
|
||||
$.fn.editable.defaults.mode = 'popup';
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<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>
|
||||
<a class="btn btn-danger" href="{:url('/admin/form/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>
|
||||
<a class="btn btn-warning" href="{:url('/admin/form/index')}"><i class="fa fa-reply"></i> 返回</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="main-box-body clearfix">
|
||||
@@ -35,8 +35,8 @@
|
||||
<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>
|
||||
<a href="{:url('/admin/form/editattr',array('id'=>$item['id'], 'form_id'=>$form_id))}">编辑</a>
|
||||
<a href="{:url('/admin/form/delattr',array('id'=>$item['id'], 'form_id'=>$form_id))}" class="confirm ajax-get">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<h2>{$meta_title}</h2>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-primary" href="{:url('add')}">新 增</a>
|
||||
<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
|
||||
<a class="btn btn-primary" href="{:url('/admin/form/add')}">新 增</a>
|
||||
<button class="btn btn-danger ajax-post confirm" url="{:url('/admin/form/del')}" target-form="ids">删 除</button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="main-box-body clearfix">
|
||||
@@ -36,10 +36,10 @@
|
||||
<td>{$item['id']}</td>
|
||||
<td>{$item['name']}</td>
|
||||
<td>
|
||||
<a data-id="{$item.id}" href="{:url('form/edit?id='.$item['id'])}">{$item['title']}</a>
|
||||
<a data-id="{$item.id}" href="{:url('/admin/form/edit?id='.$item['id'])}">{$item['title']}</a>
|
||||
</td>
|
||||
<td>
|
||||
<span>{$item.create_time|time_format}</span>
|
||||
<span>{$item['create_time']}</span>
|
||||
</td>
|
||||
<td>
|
||||
{if $item['status']}
|
||||
@@ -49,11 +49,12 @@
|
||||
{/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>
|
||||
<a href="{:url('/admin/form/attr', ['form_id' => $item['id']])}">字段</a>
|
||||
<a href="{:url('/admin/form/status', ['form_id' => $item['id'], 'status' => abs(1-$item['status'])])}" class="ajax-get">{$item['status_text']}</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>
|
||||
<a href="{:url('front/form', ['id'=>$item['id'], 'name'=>$item['name']])}" target="_blank">浏览</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">{$field['title']|htmlspecialchars}</label>
|
||||
<div class="col-lg-10 col-sm-10">
|
||||
{:widget('common/Form/show',array($field,$info))}
|
||||
{:form($field, $info)}
|
||||
<div class="help-block">{$field['help']|default=''}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -62,7 +62,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">{$field['title']|htmlspecialchars}</label>
|
||||
<div class="col-lg-10 col-sm-10">
|
||||
{:widget('common/Form/show',array($field,$info))}
|
||||
{:form($field, $info)}
|
||||
<div class="help-block">{$field['help']|default=''}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<script type="text/javascript" src="__static__/plugins/jquery/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="__static__/plugins/layui/layui.all.js"></script>
|
||||
<script type="text/javascript">
|
||||
//var BASE_URL = "/"; //根目录地址
|
||||
var BASE_URL = "/"; //根目录地址
|
||||
$(function(){
|
||||
var height = $(window).height();
|
||||
if ($('#content-wrapper').height() < height) {
|
||||
|
||||
Reference in New Issue
Block a user