update
This commit is contained in:
parent
b023a1dafd
commit
ba9ef6f88d
|
@ -1,105 +1,105 @@
|
|||
.form-horizontal .checkbox-inline,
|
||||
.form-horizontal .radio-inline {
|
||||
padding-top: 0;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
form.search-form .form-group {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.checkbox-div,
|
||||
.radio-div {
|
||||
min-height: 33px;
|
||||
}
|
||||
|
||||
.tabl .checkbox-div,
|
||||
.tabl .radio-div {
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.vertical-middle,
|
||||
.table>tbody>tr>td.vertical-middle {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.vertical-top,
|
||||
.table>tbody>tr>td.vertical-top {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.vertical-bottom,
|
||||
.table>tbody>tr>td.vertical-bottom {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.field-raw,
|
||||
.field-show {
|
||||
min-height: 33px;
|
||||
line-height: 33px;
|
||||
}
|
||||
|
||||
.table .field-raw,
|
||||
.table .field-show {
|
||||
min-height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.field-required {
|
||||
color: red;
|
||||
}
|
||||
|
||||
span.select2-container {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
form .form-control {
|
||||
height: 33px;
|
||||
}
|
||||
|
||||
.table .form-control {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
form textarea.form-control,
|
||||
.table textarea.form-control {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.table>tbody>tr>td {
|
||||
padding: 5px;
|
||||
line-height: 1.42857143;
|
||||
}
|
||||
|
||||
.table .table-checkbox label.lyear-checkbox {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.table .table-checkbox {
|
||||
width: 30px;
|
||||
margin-left: 10px;
|
||||
padding: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.has-error .select2 span.select2-selection {
|
||||
border-color: #f96868 !important;
|
||||
}
|
||||
|
||||
.select2-container .select2-selection {
|
||||
height: 33px;
|
||||
}
|
||||
|
||||
.select2-container .select2-selection .select2-selection__rendered {
|
||||
line-height: 33px;
|
||||
}
|
||||
|
||||
.table .select2-container .select2-selection {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.table .select2-container .select2-selection .select2-selection__rendered {
|
||||
line-height: 33px;
|
||||
.form-horizontal .checkbox-inline,
|
||||
.form-horizontal .radio-inline {
|
||||
padding-top: 0;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
form.search-form .form-group {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.checkbox-div,
|
||||
.radio-div {
|
||||
min-height: 33px;
|
||||
}
|
||||
|
||||
.tabl .checkbox-div,
|
||||
.tabl .radio-div {
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.vertical-middle,
|
||||
.table>tbody>tr>td.vertical-middle {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.vertical-top,
|
||||
.table>tbody>tr>td.vertical-top {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.vertical-bottom,
|
||||
.table>tbody>tr>td.vertical-bottom {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.field-raw,
|
||||
.field-show {
|
||||
min-height: 33px;
|
||||
line-height: 33px;
|
||||
}
|
||||
|
||||
.table .field-raw,
|
||||
.table .field-show {
|
||||
min-height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.field-required {
|
||||
color: red;
|
||||
}
|
||||
|
||||
span.select2-container {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
form .form-control {
|
||||
height: 33px;
|
||||
}
|
||||
|
||||
.table .form-control {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
form textarea.form-control,
|
||||
.table textarea.form-control {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.table>tbody>tr>td {
|
||||
padding: 5px;
|
||||
line-height: 1.42857143;
|
||||
}
|
||||
|
||||
.table .table-checkbox label.lyear-checkbox {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.table .table-checkbox {
|
||||
width: 30px;
|
||||
margin-left: 10px;
|
||||
padding: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.has-error .select2 span.select2-selection {
|
||||
border-color: #f96868 !important;
|
||||
}
|
||||
|
||||
.select2-container .select2-selection {
|
||||
height: 33px;
|
||||
}
|
||||
|
||||
.select2-container .select2-selection .select2-selection__rendered {
|
||||
line-height: 33px;
|
||||
}
|
||||
|
||||
.table .select2-container .select2-selection {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.table .select2-container .select2-selection .select2-selection__rendered {
|
||||
line-height: 33px;
|
||||
}
|
|
@ -1,43 +1,43 @@
|
|||
.lyear-uploads-pic {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic>li.pic-item {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic li.pic-item .progress {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
margin-bottom: 0px;
|
||||
left: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic .success,
|
||||
.lyear-uploads-pic .error {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
background-color: rgba(0, 0, 0, .125);
|
||||
right: 5px;
|
||||
left: 5px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic figure img {
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
max-height: 110px;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic figure {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.webuploader-container label {
|
||||
margin-bottom: 0px;
|
||||
.lyear-uploads-pic {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic>li.pic-item {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic li.pic-item .progress {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
margin-bottom: 0px;
|
||||
left: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic .success,
|
||||
.lyear-uploads-pic .error {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
background-color: rgba(0, 0, 0, .125);
|
||||
right: 5px;
|
||||
left: 5px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic figure img {
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
max-height: 110px;
|
||||
}
|
||||
|
||||
.lyear-uploads-pic figure {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.webuploader-container label {
|
||||
margin-bottom: 0px;
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,2 +1,2 @@
|
|||
/*! layer mobile-v2.0.0 Web弹层组件 MIT License http://layer.layui.com/mobile By 贤心 */
|
||||
/*! layer mobile-v2.0.0 Web弹层组件 MIT License http://layer.layui.com/mobile By 贤心 */
|
||||
;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'<h3 style="'+(e?n.title[1]:"")+'">'+(e?n.title[0]:n.title)+"</h3>":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e='<span yes type="1">'+n.btn[0]+"</span>",2===t&&(e='<span no type="0">'+n.btn[1]+"</span>"+e),'<div class="layui-m-layerbtn">'+e+"</div>"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='<i></i><i class="layui-m-layerload"></i><i></i><p>'+(n.content||"")+"</p>"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"<div "+("string"==typeof n.shade?'style="'+n.shade+'"':"")+' class="layui-m-layershade"></div>':"")+'<div class="layui-m-layermain" '+(n.fixed?"":'style="position:static;"')+'><div class="layui-m-layersection"><div class="layui-m-layerchild '+(n.skin?"layui-m-layer-"+n.skin+" ":"")+(n.className?n.className:"")+" "+(n.anim?"layui-m-anim-"+n.anim:"")+'" '+(n.style?'style="'+n.style+'"':"")+">"+l+'<div class="layui-m-layercont">'+n.content+"</div>"+c+"</div></div></div>",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;o<r;o++)l.touch(s[o],a);if(e.shade&&e.shadeClose){var c=t[i]("layui-m-layershade")[0];l.touch(c,function(){layer.close(n.index,e.end)})}e.end&&(l.end[n.index]=e.end)},e.layer={v:"2.0",index:r,open:function(e){var t=new c(e||{});return t.index},close:function(e){var n=a("#"+o[0]+e)[0];n&&(n.innerHTML="",t.body.removeChild(n),clearTimeout(l.timer[e]),delete l.timer[e],"function"==typeof l.end[e]&&l.end[e](),delete l.end[e])},closeAll:function(){for(var e=t[i](o[0]),n=0,a=e.length;n<a;n++)layer.close(0|e[0].getAttribute("index"))}},"function"==typeof define?define(function(){return layer}):function(){var e=document.scripts,n=e[e.length-1],i=n.src,a=i.substring(0,i.lastIndexOf("/")+1);n.getAttribute("merge")||document.head.appendChild(function(){var e=t.createElement("link");return e.href=a+"need/layer.css?2.0",e.type="text/css",e.rel="styleSheet",e.id="layermcss",e}())}()}(window);
|
File diff suppressed because it is too large
Load Diff
|
@ -1,28 +1,28 @@
|
|||
{
|
||||
"name": "ichynul/tpextbuilder",
|
||||
"description": "thinkphp extension",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"thinkphp"
|
||||
],
|
||||
"homepage": "http://www.ynyysc.com/",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "ichynul",
|
||||
"email": "ichynul@outlook.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"ichynul/tpext": "^1.0.1",
|
||||
"ichynul/lightyearadmin": "^1.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"tpext\\builder\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helper.php"
|
||||
]
|
||||
}
|
||||
{
|
||||
"name": "ichynul/tpextbuilder",
|
||||
"description": "thinkphp extension",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"thinkphp"
|
||||
],
|
||||
"homepage": "http://www.ynyysc.com/",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "ichynul",
|
||||
"email": "ichynul@outlook.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"ichynul/tpext": "^1.0.1",
|
||||
"ichynul/lightyearadmin": "^1.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"tpext\\builder\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helper.php"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,57 +1,57 @@
|
|||
<?php
|
||||
namespace tpext\builder\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use tpext\builder\common\Builder;
|
||||
|
||||
class Import extends Controller
|
||||
{
|
||||
public function page()
|
||||
{
|
||||
$acceptedExts = input('acceptedExts');
|
||||
$fileSize = input('fileSize');
|
||||
$pageToken = input('pageToken');
|
||||
$successUrl = input('successUrl');
|
||||
|
||||
if (empty($acceptedExts) || empty($fileSize) || empty($pageToken) || empty($successUrl)) {
|
||||
$this->error('参数有误');
|
||||
}
|
||||
|
||||
$importpagetoken = session('importpagetoken');
|
||||
|
||||
$_pageToken = md5($importpagetoken . $acceptedExts . $fileSize);
|
||||
|
||||
if ($_pageToken != $pageToken) {
|
||||
$this->error('验证失败');
|
||||
}
|
||||
|
||||
$acceptedExts = explode(',', $acceptedExts);
|
||||
|
||||
$acceptedExts = '.' . implode(',.', $acceptedExts);
|
||||
|
||||
$successUrl = urldecode($successUrl);
|
||||
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$uploadUrl = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'dropzone', 'token' => $token]);
|
||||
|
||||
$this->assign('admin_copyright', '');
|
||||
$this->assign('uploadUrl', $uploadUrl);
|
||||
$this->assign('acceptedExts', $acceptedExts);
|
||||
$this->assign('fileSize', $fileSize);
|
||||
$this->assign('successUrl', $successUrl);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function afterSuccess()
|
||||
{
|
||||
$builder = Builder::getInstance();
|
||||
|
||||
$fileurl = input('fileurl');
|
||||
|
||||
return $builder->layer()->closeRefresh(1, '导入成功:' . $fileurl);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
namespace tpext\builder\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use tpext\builder\common\Builder;
|
||||
|
||||
class Import extends Controller
|
||||
{
|
||||
public function page()
|
||||
{
|
||||
$acceptedExts = input('acceptedExts');
|
||||
$fileSize = input('fileSize');
|
||||
$pageToken = input('pageToken');
|
||||
$successUrl = input('successUrl');
|
||||
|
||||
if (empty($acceptedExts) || empty($fileSize) || empty($pageToken) || empty($successUrl)) {
|
||||
$this->error('参数有误');
|
||||
}
|
||||
|
||||
$importpagetoken = session('importpagetoken');
|
||||
|
||||
$_pageToken = md5($importpagetoken . $acceptedExts . $fileSize);
|
||||
|
||||
if ($_pageToken != $pageToken) {
|
||||
$this->error('验证失败');
|
||||
}
|
||||
|
||||
$acceptedExts = explode(',', $acceptedExts);
|
||||
|
||||
$acceptedExts = '.' . implode(',.', $acceptedExts);
|
||||
|
||||
$successUrl = urldecode($successUrl);
|
||||
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$uploadUrl = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'dropzone', 'token' => $token]);
|
||||
|
||||
$this->assign('admin_copyright', '');
|
||||
$this->assign('uploadUrl', $uploadUrl);
|
||||
$this->assign('acceptedExts', $acceptedExts);
|
||||
$this->assign('fileSize', $fileSize);
|
||||
$this->assign('successUrl', $successUrl);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function afterSuccess()
|
||||
{
|
||||
$builder = Builder::getInstance();
|
||||
|
||||
$fileurl = input('fileurl');
|
||||
|
||||
return $builder->layer()->closeRefresh(1, '导入成功:' . $fileurl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,309 +1,320 @@
|
|||
<?php
|
||||
namespace tpext\builder\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use tpext\builder\common\Upload as UploadTool;
|
||||
|
||||
/* 参照 Light-Year-Example 相关上传处理方式*/
|
||||
|
||||
class Upload extends Controller
|
||||
{
|
||||
public function upfiles($type = '', $token = '')
|
||||
{
|
||||
if (empty($token)) {
|
||||
echo json_encode(['info' => 'no token', 'picurl' => '']);
|
||||
return;
|
||||
}
|
||||
|
||||
if (session('uploadtoken') != $token) {
|
||||
echo json_encode(['info' => 'token error', 'picurl' => '']);
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'editormd':
|
||||
$file_input_name = 'editormd-image-file';
|
||||
break;
|
||||
case 'ckeditor':
|
||||
$file_input_name = 'upload';
|
||||
break;
|
||||
default:
|
||||
$file_input_name = 'file';
|
||||
}
|
||||
|
||||
$up = new UploadTool();
|
||||
|
||||
$newPath = $up->uploadFile($file_input_name);
|
||||
if ($newPath === false) {
|
||||
//var_dump($up->errorNumber);
|
||||
//echo json_encode(['status' => 500, 'info' => '上传失败,没有权限', 'class' => 'error']);
|
||||
// 失败跟成功同样的方式返回
|
||||
} else {
|
||||
$newPath = preg_replace('/^.+?public(\/.+)$/i', '$1', $newPath);
|
||||
switch ($type) {
|
||||
case 'wangeditor':
|
||||
echo json_encode(['url' => $newPath]);
|
||||
break;
|
||||
case 'editormd':
|
||||
echo json_encode([
|
||||
"success" => 1,
|
||||
"message" => '上传成功',
|
||||
"url" => $newPath,
|
||||
]);
|
||||
break;
|
||||
case 'dropzone':
|
||||
echo json_encode(['status' => 200, 'info' => '上传成功', 'picurl' => $newPath]);
|
||||
break;
|
||||
case 'webuploader':
|
||||
echo json_encode(['status' => 200, 'info' => '上传成功', 'class' => 'success', 'id' => rand(1, 9999), 'picurl' => $newPath]);
|
||||
break;
|
||||
case 'tinymce':
|
||||
echo json_encode([
|
||||
"location" => $newPath,
|
||||
]);
|
||||
break;
|
||||
case 'ckeditor':
|
||||
echo json_encode([
|
||||
"uploaded" => 1,
|
||||
"fileName" => pathinfo($newPath)['filename'],
|
||||
"url" => $newPath,
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
echo json_encode([
|
||||
"status" => 1,
|
||||
"info" => '上传成功',
|
||||
"url" => $newPath,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ueditor($token = '')
|
||||
{
|
||||
if (empty($token)) {
|
||||
exit('no token');
|
||||
}
|
||||
|
||||
if (session('uploadtoken') != $token) {
|
||||
exit('token error');
|
||||
}
|
||||
|
||||
$action = $_GET['action'];
|
||||
$config_file = app()->getRootPath() . 'public/assets/tpextbuilder/js/ueditor/config.json';
|
||||
$config = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents($config_file)), true);
|
||||
switch ($action) {
|
||||
/* 获取配置信息 */
|
||||
case 'config':
|
||||
$result = $config;
|
||||
break;
|
||||
|
||||
/* 上传图片 */
|
||||
case 'uploadimage':
|
||||
/* 上传涂鸦 */
|
||||
case 'uploadscrawl':
|
||||
echo $this->saveFile('images');exit;
|
||||
break;
|
||||
|
||||
/* 上传视频 */
|
||||
case 'uploadvideo':
|
||||
echo $this->saveFile('videos');exit;
|
||||
break;
|
||||
|
||||
/* 上传附件 */
|
||||
case 'uploadfile':
|
||||
echo $this->saveFile('files');exit;
|
||||
break;
|
||||
|
||||
/* 列出图片 */
|
||||
case 'listimage':
|
||||
echo $this->showFile('listimage', $config);exit;
|
||||
break;
|
||||
|
||||
/* 列出附件 */
|
||||
case 'listfile':
|
||||
echo $this->showFile('listfile', $config);exit;
|
||||
break;
|
||||
|
||||
/* 抓取远程附件 */
|
||||
case 'catchimage':
|
||||
$result = $this->catchFile();
|
||||
break;
|
||||
|
||||
default:
|
||||
$result = ['state' => '请求地址出错'];
|
||||
break;
|
||||
}
|
||||
|
||||
/* 输出结果 */
|
||||
if (isset($_GET["callback"])) {
|
||||
if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
|
||||
echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
|
||||
} else {
|
||||
echo json_encode(['state' => 'callback参数不合法']);
|
||||
}
|
||||
} else {
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function base64()
|
||||
{
|
||||
$picdata = $_POST['picdata'];
|
||||
|
||||
if (empty($picdata)) {
|
||||
echo json_encode(['state' => 400, 'message' => '上传数据为空']);exit;
|
||||
}
|
||||
$picurl = $this->base64_image_content($picdata, app()->getRootPath() . 'public/upload/images/' . date('Ym') . '/');
|
||||
if ($picurl) {
|
||||
echo json_encode(['state' => 200, 'picurl' => $picurl]);exit;
|
||||
} else {
|
||||
echo json_encode(['state' => 500, 'message' => '上传失败']);exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function base64_image_content($base64_image_content, $path)
|
||||
{
|
||||
//匹配出图片的格式
|
||||
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)) {
|
||||
$type = $result[2];
|
||||
if (!preg_match('/^(png|jpg|jpeg|bmp|gif|webpg)$/i', $type)) {
|
||||
return false;
|
||||
}
|
||||
$new_file = $path . "/" . date('Ymd', time()) . "/";
|
||||
|
||||
if (!file_exists($new_file)) {
|
||||
//检查是否有该文件夹,如果没有就创建,并给予最高权限
|
||||
mkdir($new_file, 0755, true);
|
||||
}
|
||||
|
||||
$new_file = $new_file . md5(microtime(true)) . ".{$type}";
|
||||
if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))) {
|
||||
return '/' . $new_file;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function saveFile($type = '')
|
||||
{
|
||||
$file_input_name = 'upfile';
|
||||
|
||||
$up = new UploadTool(['path' => app()->getRootPath() . "/public/upload/{$type}/" . date('Ym') . '/']);
|
||||
|
||||
$newPath = $up->uploadFile($file_input_name);
|
||||
if ($newPath === false) {
|
||||
//var_dump($up->errorNumber);
|
||||
//echo json_encode(['status' => 500, 'info' => '上传失败,没有权限', 'class' => 'error']);
|
||||
// 失败跟成功同样的方式返回
|
||||
return json_encode([
|
||||
"state" => "", // 上传状态,上传成功时必须返回"SUCCESS"
|
||||
"url" => '', // 返回的地址
|
||||
"title" => $up->errorInfo,
|
||||
]);
|
||||
} else {
|
||||
$newPath = preg_replace('/^.+?public(\/.+)$/i', '$1', $newPath);
|
||||
|
||||
return json_encode([
|
||||
"state" => "SUCCESS", // 上传状态,上传成功时必须返回"SUCCESS"
|
||||
"url" => $newPath, // 返回的地址
|
||||
"title" => $newPath, // 附件名
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function catchFile()
|
||||
{
|
||||
// 假装抓取成功了
|
||||
return json_encode([
|
||||
"state" => "SUCCESS", // 上传状态,上传成功时必须返回"SUCCESS"
|
||||
"url" => './upload/images/lyear_5de21f46cd8ba.jpg', // 返回的地址
|
||||
"title" => 'lyear_5de21f46cd8ba', // 附件名
|
||||
]);
|
||||
}
|
||||
|
||||
private function showFile($type = '', $config)
|
||||
{
|
||||
/* 判断类型 */
|
||||
switch ($type) {
|
||||
/* 列出附件 */
|
||||
case 'listfile':
|
||||
$allowFiles = $config['fileManagerAllowFiles'];
|
||||
$listSize = $config['fileManagerListSize'];
|
||||
$path = realpath('./upload/files/');
|
||||
break;
|
||||
|
||||
/* 列出图片 */
|
||||
case 'listimage':
|
||||
default:
|
||||
$allowFiles = $config['imageManagerAllowFiles'];
|
||||
$listSize = $config['imageManagerListSize'];
|
||||
$path = realpath('./upload/images/');
|
||||
}
|
||||
$allowFiles = substr(str_replace(".", "|", join("", $allowFiles)), 1);
|
||||
|
||||
/* 获取参数 */
|
||||
$size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $listSize;
|
||||
$start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0;
|
||||
$end = $start + $size;
|
||||
|
||||
/* 获取附件列表 */
|
||||
$files = $this->getfiles($path, $allowFiles);
|
||||
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];
|
||||
}
|
||||
|
||||
/* 返回数据 */
|
||||
$result = array(
|
||||
"state" => "SUCCESS",
|
||||
"list" => $list,
|
||||
"start" => $start,
|
||||
"total" => count($files),
|
||||
);
|
||||
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
private function getfiles($path = '', $allowFiles = '', &$files = array())
|
||||
{
|
||||
if (!is_dir($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (substr($path, strlen($path) - 1) != '/') {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
$handle = opendir($path);
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$path2 = $path . $file;
|
||||
if (is_dir($path2)) {
|
||||
$this->getfiles($path2, $allowFiles, $files);
|
||||
} else {
|
||||
if (preg_match("/\.(" . $allowFiles . ")$/i", $file)) {
|
||||
$files[] = array(
|
||||
'url' => str_replace("\\", "/", substr($path2, strlen($_SERVER['DOCUMENT_ROOT']))),
|
||||
'mtime' => filemtime($path2),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
namespace tpext\builder\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use tpext\builder\common\Module;
|
||||
use tpext\builder\common\Upload as UploadTool;
|
||||
|
||||
/* 参照 Light-Year-Example 相关上传处理方式*/
|
||||
|
||||
class Upload extends Controller
|
||||
{
|
||||
public function upfiles($type = '', $token = '')
|
||||
{
|
||||
if (empty($token)) {
|
||||
echo json_encode(['info' => 'no token', 'picurl' => '']);
|
||||
return;
|
||||
}
|
||||
|
||||
if (session('uploadtoken') != $token) {
|
||||
echo json_encode(['info' => 'token error', 'picurl' => '']);
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'editormd':
|
||||
$file_input_name = 'editormd-image-file';
|
||||
break;
|
||||
case 'ckeditor':
|
||||
$file_input_name = 'upload';
|
||||
break;
|
||||
default:
|
||||
$file_input_name = 'file';
|
||||
}
|
||||
|
||||
$config = Module::getInstance()->getConfig();
|
||||
|
||||
$config['allowSuffix'] = explode(',', $config['allowSuffix']);
|
||||
$config['maxSize'] = $config['maxSize'] * 1024 * 1024;
|
||||
|
||||
$up = new UploadTool($config);
|
||||
|
||||
$newPath = $up->uploadFile($file_input_name);
|
||||
|
||||
if ($newPath === false) {
|
||||
//var_dump($up->errorNumber);
|
||||
echo json_encode(['status' => 500, 'info' => '上传失败-' . $up->errorInfo, 'class' => 'error']);
|
||||
// 失败跟成功同样的方式返回
|
||||
} else {
|
||||
$newPath = preg_replace('/^.+?public(\/.+)$/i', '$1', $newPath);
|
||||
switch ($type) {
|
||||
case 'wangeditor':
|
||||
echo json_encode(['url' => $newPath]);
|
||||
break;
|
||||
case 'editormd':
|
||||
echo json_encode([
|
||||
"success" => 1,
|
||||
"message" => '上传成功',
|
||||
"url" => $newPath,
|
||||
]);
|
||||
break;
|
||||
case 'dropzone':
|
||||
echo json_encode(['status' => 200, 'info' => '上传成功', 'picurl' => $newPath]);
|
||||
break;
|
||||
case 'webuploader':
|
||||
echo json_encode(['status' => 200, 'info' => '上传成功', 'class' => 'success', 'id' => rand(1, 9999), 'picurl' => $newPath]);
|
||||
break;
|
||||
case 'tinymce':
|
||||
echo json_encode([
|
||||
"location" => $newPath,
|
||||
]);
|
||||
break;
|
||||
case 'ckeditor':
|
||||
echo json_encode([
|
||||
"uploaded" => 1,
|
||||
"fileName" => pathinfo($newPath)['filename'],
|
||||
"url" => $newPath,
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
echo json_encode([
|
||||
"status" => 1,
|
||||
"info" => '上传成功',
|
||||
"url" => $newPath,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ueditor($token = '')
|
||||
{
|
||||
if (empty($token)) {
|
||||
exit('no token');
|
||||
}
|
||||
|
||||
if (session('uploadtoken') != $token) {
|
||||
exit('token error');
|
||||
}
|
||||
|
||||
$action = $_GET['action'];
|
||||
$config_file = app()->getRootPath() . 'public/assets/tpextbuilder/js/ueditor/config.json';
|
||||
$config = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents($config_file)), true);
|
||||
switch ($action) {
|
||||
/* 获取配置信息 */
|
||||
case 'config':
|
||||
$result = $config;
|
||||
break;
|
||||
|
||||
/* 上传图片 */
|
||||
case 'uploadimage':
|
||||
/* 上传涂鸦 */
|
||||
case 'uploadscrawl':
|
||||
echo $this->saveFile('images');exit;
|
||||
break;
|
||||
|
||||
/* 上传视频 */
|
||||
case 'uploadvideo':
|
||||
echo $this->saveFile('videos');exit;
|
||||
break;
|
||||
|
||||
/* 上传附件 */
|
||||
case 'uploadfile':
|
||||
echo $this->saveFile('files');exit;
|
||||
break;
|
||||
|
||||
/* 列出图片 */
|
||||
case 'listimage':
|
||||
echo $this->showFile('listimage', $config);exit;
|
||||
break;
|
||||
|
||||
/* 列出附件 */
|
||||
case 'listfile':
|
||||
echo $this->showFile('listfile', $config);exit;
|
||||
break;
|
||||
|
||||
/* 抓取远程附件 */
|
||||
case 'catchimage':
|
||||
$result = $this->catchFile();
|
||||
break;
|
||||
|
||||
default:
|
||||
$result = ['state' => '请求地址出错'];
|
||||
break;
|
||||
}
|
||||
|
||||
/* 输出结果 */
|
||||
if (isset($_GET["callback"])) {
|
||||
if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
|
||||
echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
|
||||
} else {
|
||||
echo json_encode(['state' => 'callback参数不合法']);
|
||||
}
|
||||
} else {
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function base64()
|
||||
{
|
||||
$picdata = $_POST['picdata'];
|
||||
|
||||
if (empty($picdata)) {
|
||||
echo json_encode(['state' => 400, 'message' => '上传数据为空']);exit;
|
||||
}
|
||||
$picurl = $this->base64_image_content($picdata, app()->getRootPath() . 'public/upload/images/' . date('Ym') . '/');
|
||||
if ($picurl) {
|
||||
echo json_encode(['state' => 200, 'picurl' => $picurl]);exit;
|
||||
} else {
|
||||
echo json_encode(['state' => 500, 'message' => '上传失败']);exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function base64_image_content($base64_image_content, $path)
|
||||
{
|
||||
//匹配出图片的格式
|
||||
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)) {
|
||||
$type = $result[2];
|
||||
if (!preg_match('/^(png|jpg|jpeg|bmp|gif|webpg)$/i', $type)) {
|
||||
return false;
|
||||
}
|
||||
$new_file = $path . "/" . date('Ymd', time()) . "/";
|
||||
|
||||
if (!file_exists($new_file)) {
|
||||
//检查是否有该文件夹,如果没有就创建,并给予最高权限
|
||||
mkdir($new_file, 0755, true);
|
||||
}
|
||||
|
||||
$new_file = $new_file . md5(microtime(true)) . ".{$type}";
|
||||
if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))) {
|
||||
return '/' . $new_file;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function saveFile($type = '')
|
||||
{
|
||||
$file_input_name = 'upfile';
|
||||
|
||||
$config = Module::getInstance()->getConfig();
|
||||
|
||||
$config['path'] = app()->getRootPath() . "/public/upload/{$type}/" . date('Ym') . '/';
|
||||
|
||||
$up = new UploadTool($config);
|
||||
|
||||
$newPath = $up->uploadFile($file_input_name);
|
||||
if ($newPath === false) {
|
||||
//var_dump($up->errorNumber);
|
||||
//echo json_encode(['status' => 500, 'info' => '上传失败,没有权限', 'class' => 'error']);
|
||||
// 失败跟成功同样的方式返回
|
||||
return json_encode([
|
||||
"state" => "", // 上传状态,上传成功时必须返回"SUCCESS"
|
||||
"url" => '', // 返回的地址
|
||||
"title" => $up->errorInfo,
|
||||
]);
|
||||
} else {
|
||||
$newPath = preg_replace('/^.+?public(\/.+)$/i', '$1', $newPath);
|
||||
|
||||
return json_encode([
|
||||
"state" => "SUCCESS", // 上传状态,上传成功时必须返回"SUCCESS"
|
||||
"url" => $newPath, // 返回的地址
|
||||
"title" => $newPath, // 附件名
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function catchFile()
|
||||
{
|
||||
// 假装抓取成功了
|
||||
return json_encode([
|
||||
"state" => "SUCCESS", // 上传状态,上传成功时必须返回"SUCCESS"
|
||||
"url" => './upload/images/lyear_5de21f46cd8ba.jpg', // 返回的地址
|
||||
"title" => 'lyear_5de21f46cd8ba', // 附件名
|
||||
]);
|
||||
}
|
||||
|
||||
private function showFile($type = '', $config)
|
||||
{
|
||||
/* 判断类型 */
|
||||
switch ($type) {
|
||||
/* 列出附件 */
|
||||
case 'listfile':
|
||||
$allowFiles = $config['fileManagerAllowFiles'];
|
||||
$listSize = $config['fileManagerListSize'];
|
||||
$path = realpath('./upload/files/');
|
||||
break;
|
||||
|
||||
/* 列出图片 */
|
||||
case 'listimage':
|
||||
default:
|
||||
$allowFiles = $config['imageManagerAllowFiles'];
|
||||
$listSize = $config['imageManagerListSize'];
|
||||
$path = realpath('./upload/images/');
|
||||
}
|
||||
$allowFiles = substr(str_replace(".", "|", join("", $allowFiles)), 1);
|
||||
|
||||
/* 获取参数 */
|
||||
$size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $listSize;
|
||||
$start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0;
|
||||
$end = $start + $size;
|
||||
|
||||
/* 获取附件列表 */
|
||||
$files = $this->getfiles($path, $allowFiles);
|
||||
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];
|
||||
}
|
||||
|
||||
/* 返回数据 */
|
||||
$result = array(
|
||||
"state" => "SUCCESS",
|
||||
"list" => $list,
|
||||
"start" => $start,
|
||||
"total" => count($files),
|
||||
);
|
||||
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
private function getfiles($path = '', $allowFiles = '', &$files = array())
|
||||
{
|
||||
if (!is_dir($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (substr($path, strlen($path) - 1) != '/') {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
$handle = opendir($path);
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$path2 = $path . $file;
|
||||
if (is_dir($path2)) {
|
||||
$this->getfiles($path2, $allowFiles, $files);
|
||||
} else {
|
||||
if (preg_match("/\.(" . $allowFiles . ")$/i", $file)) {
|
||||
$files[] = array(
|
||||
'url' => str_replace("\\", "/", substr($path2, strlen($_SERVER['DOCUMENT_ROOT']))),
|
||||
'mtime' => filemtime($path2),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
{extend name="$admin_layout"/}
|
||||
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" href="__MODULE__/js/dropzone/min/basic.min.css" />
|
||||
<link rel="stylesheet" href="__MODULE__/js/dropzone/min/dropzone.min.css" />
|
||||
{/block}
|
||||
|
||||
{block name="content"}
|
||||
<div class="row">
|
||||
<div id="dropzone-elm" style="margin:10px;" class="dropzone"></div>
|
||||
</div>
|
||||
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script type="text/javascript" src="__MODULE__/js/dropzone/min/dropzone.min.js" charset="utf-8"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
// 默认使用情况
|
||||
$("#dropzone-elm").dropzone({
|
||||
url: "{$uploadUrl}",
|
||||
method: "post", // 也可用put
|
||||
paramName: "file", // 默认为file
|
||||
maxFiles: 1,// 一次性上传的文件数量上限
|
||||
maxFilesize: 200, // 文件大小,单位:MB
|
||||
acceptedFiles: "{$acceptedExts}", // 上传的类型
|
||||
addRemoveLinks: false,
|
||||
parallelUploads: 1,// 一次上传的文件数量
|
||||
dictDefaultMessage: '拖动文件至此或者点击上传',
|
||||
dictMaxFilesExceeded: "您最多只能上传1个文件!",
|
||||
dictResponseError: '文件上传失败!',
|
||||
dictInvalidFileType: "文件类型只能是{$acceptedExts}。",
|
||||
dictFallbackMessage: "浏览器不受支持",
|
||||
dictFileTooBig: "文件过大上传文件最大支持.",
|
||||
dictRemoveLinks: "删除",
|
||||
dictCancelUpload: "取消",
|
||||
init: function () {
|
||||
this.on("addedfile", function (file) {
|
||||
// 上传文件时触发的事件
|
||||
});
|
||||
this.on("success", function (file, data) {
|
||||
data = JSON.parse(data);
|
||||
location.href ='{$successUrl}?fileurl=' + encodeURI(data.picurl);
|
||||
// 上传成功触发的事件
|
||||
});
|
||||
this.on("error", function (file, data) {
|
||||
// 上传失败触发的事件
|
||||
parent.lightyear.notify('出现错误-'+ data, 'danger');
|
||||
});
|
||||
}
|
||||
});
|
||||
Dropzone.autoDiscover = false;
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
</body>
|
||||
|
||||
{extend name="$admin_layout"/}
|
||||
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" href="__MODULE__/js/dropzone/min/basic.min.css" />
|
||||
<link rel="stylesheet" href="__MODULE__/js/dropzone/min/dropzone.min.css" />
|
||||
{/block}
|
||||
|
||||
{block name="content"}
|
||||
<div class="row">
|
||||
<div id="dropzone-elm" style="margin:10px;" class="dropzone"></div>
|
||||
</div>
|
||||
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script type="text/javascript" src="__MODULE__/js/dropzone/min/dropzone.min.js" charset="utf-8"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
// 默认使用情况
|
||||
$("#dropzone-elm").dropzone({
|
||||
url: "{$uploadUrl}",
|
||||
method: "post", // 也可用put
|
||||
paramName: "file", // 默认为file
|
||||
maxFiles: 1,// 一次性上传的文件数量上限
|
||||
maxFilesize: 200, // 文件大小,单位:MB
|
||||
acceptedFiles: "{$acceptedExts}", // 上传的类型
|
||||
addRemoveLinks: false,
|
||||
parallelUploads: 1,// 一次上传的文件数量
|
||||
dictDefaultMessage: '拖动文件至此或者点击上传',
|
||||
dictMaxFilesExceeded: "您最多只能上传1个文件!",
|
||||
dictResponseError: '文件上传失败!',
|
||||
dictInvalidFileType: "文件类型只能是{$acceptedExts}。",
|
||||
dictFallbackMessage: "浏览器不受支持",
|
||||
dictFileTooBig: "文件过大上传文件最大支持.",
|
||||
dictRemoveLinks: "删除",
|
||||
dictCancelUpload: "取消",
|
||||
init: function () {
|
||||
this.on("addedfile", function (file) {
|
||||
// 上传文件时触发的事件
|
||||
});
|
||||
this.on("success", function (file, data) {
|
||||
data = JSON.parse(data);
|
||||
location.href ='{$successUrl}?fileurl=' + encodeURI(data.picurl);
|
||||
// 上传成功触发的事件
|
||||
});
|
||||
this.on("error", function (file, data) {
|
||||
// 上传失败触发的事件
|
||||
parent.lightyear.notify('出现错误-'+ data, 'danger');
|
||||
});
|
||||
}
|
||||
});
|
||||
Dropzone.autoDiscover = false;
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,308 +1,308 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\facade\View;
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Builder implements Renderable
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
protected $title = '';
|
||||
|
||||
protected $desc = null;
|
||||
|
||||
protected $csrf_token = '';
|
||||
|
||||
protected $minify = false;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rows = [];
|
||||
|
||||
protected $__row__ = null;
|
||||
|
||||
protected $js = [];
|
||||
|
||||
protected $css = [];
|
||||
|
||||
protected $style = [];
|
||||
|
||||
protected $script = [];
|
||||
|
||||
protected static $instance = null;
|
||||
|
||||
protected $notify = [];
|
||||
|
||||
protected function __construct($title, $desc)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->desc = $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $desc
|
||||
* @return $this
|
||||
*/
|
||||
public static function getInstance($title = 'Page', $desc = '')
|
||||
{
|
||||
if (static::$instance == null) {
|
||||
static::$instance = new static($title, $desc);
|
||||
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCsrfToken()
|
||||
{
|
||||
if (!$this->csrf_token) {
|
||||
$token = csrf_token();
|
||||
$this->csrf_token = $token;
|
||||
View::share(['__token__' => $token]);
|
||||
}
|
||||
|
||||
return $this->csrf_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array|string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addJs($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->js = array_merge($this->js, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array|string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addCss($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->css = array_merge($this->css, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array|string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addScript($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->script = array_merge($this->script, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addStyle($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->style = array_merge($this->style, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* lightyear.notify('修改成功,页面即将自动跳转~', 'success', 5000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
* @param string $msg
|
||||
* @param string $type
|
||||
* @param integer $delay
|
||||
* @param string $icon
|
||||
* @param string $from
|
||||
* @param string $align
|
||||
* @return $this
|
||||
*/
|
||||
public function notify($msg, $type = 'info', $delay = 2000, $icon = '', $from = 'top', $align = 'center')
|
||||
{
|
||||
$this->notify = [$msg, $type, $delay, $icon, $from, $align];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNotify()
|
||||
{
|
||||
return $this->notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Row
|
||||
*/
|
||||
public function row()
|
||||
{
|
||||
$row = new Row();
|
||||
$this->rows[] = $row;
|
||||
$this->__row__ = $row;
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Column
|
||||
*/
|
||||
public function column($size = 12)
|
||||
{
|
||||
if (!$this->__row__) {
|
||||
$this->row();
|
||||
}
|
||||
|
||||
return $this->__row__->column($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个form
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Form
|
||||
*/
|
||||
public function form($size = 12)
|
||||
{
|
||||
return $this->column($size)->form();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个表格
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Table
|
||||
*/
|
||||
public function table($size = 12)
|
||||
{
|
||||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个工具栏
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Toolbar
|
||||
*/
|
||||
public function toolbar($size = 12)
|
||||
{
|
||||
return $this->column($size)->toolbar();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一自定义内容
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Content
|
||||
*/
|
||||
public function content($size = 12)
|
||||
{
|
||||
return $this->column($size)->content();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一tab内容
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Tab
|
||||
*/
|
||||
public function tab($size = 12)
|
||||
{
|
||||
return $this->column($size)->tab();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取layer
|
||||
*
|
||||
* @return Layer
|
||||
*/
|
||||
public function layer()
|
||||
{
|
||||
return new Layer;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
$row->beforRender();
|
||||
}
|
||||
|
||||
$this->js[] = '/assets/tpextbuilder/js/layer/layer.js';
|
||||
$this->js[] = '/assets/tpextbuilder/js/tpextbuilder.js';
|
||||
|
||||
$this->css[] = '/assets/tpextbuilder/css/tpextbuilder.css';
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->beforRender();
|
||||
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'content.html']);
|
||||
|
||||
if (!empty($this->notify)) {
|
||||
|
||||
$this->script[] = "lightyear.notify('{$this->notify[0]}', '{$this->notify[1]}', {$this->notify[2]}, '{$this->notify[3]}', '{$this->notify[4]}', '{$this->notify[5]}');";
|
||||
}
|
||||
|
||||
$vars = [
|
||||
'title' => $this->title,
|
||||
'desc' => $this->desc,
|
||||
'rows' => $this->rows,
|
||||
'js' => $this->minify ? [] : array_unique($this->js),
|
||||
'css' => $this->minify ? [] : array_unique($this->css),
|
||||
'style' => implode('', array_unique($this->style)),
|
||||
'script' => implode('', array_unique($this->script)),
|
||||
];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
$instance = Module::getInstance();
|
||||
|
||||
$config = $instance->setConfig(['page_title' => $this->desc, 'page_position' => $this->title]);
|
||||
|
||||
View::share(['admin_page_title' => $this->desc, 'admin_page_position' => $this->title]);
|
||||
|
||||
return $view->assign($vars);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\facade\View;
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Builder implements Renderable
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
protected $title = '';
|
||||
|
||||
protected $desc = null;
|
||||
|
||||
protected $csrf_token = '';
|
||||
|
||||
protected $minify = false;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rows = [];
|
||||
|
||||
protected $__row__ = null;
|
||||
|
||||
protected $js = [];
|
||||
|
||||
protected $css = [];
|
||||
|
||||
protected $style = [];
|
||||
|
||||
protected $script = [];
|
||||
|
||||
protected static $instance = null;
|
||||
|
||||
protected $notify = [];
|
||||
|
||||
protected function __construct($title, $desc)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->desc = $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $desc
|
||||
* @return $this
|
||||
*/
|
||||
public static function getInstance($title = 'Page', $desc = '')
|
||||
{
|
||||
if (static::$instance == null) {
|
||||
static::$instance = new static($title, $desc);
|
||||
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCsrfToken()
|
||||
{
|
||||
if (!$this->csrf_token) {
|
||||
$token = csrf_token();
|
||||
$this->csrf_token = $token;
|
||||
View::share(['__token__' => $token]);
|
||||
}
|
||||
|
||||
return $this->csrf_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array|string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addJs($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->js = array_merge($this->js, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array|string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addCss($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->css = array_merge($this->css, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array|string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addScript($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->script = array_merge($this->script, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addStyle($val)
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = [$val];
|
||||
}
|
||||
$this->style = array_merge($this->style, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* lightyear.notify('修改成功,页面即将自动跳转~', 'success', 5000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
* @param string $msg
|
||||
* @param string $type
|
||||
* @param integer $delay
|
||||
* @param string $icon
|
||||
* @param string $from
|
||||
* @param string $align
|
||||
* @return $this
|
||||
*/
|
||||
public function notify($msg, $type = 'info', $delay = 2000, $icon = '', $from = 'top', $align = 'center')
|
||||
{
|
||||
$this->notify = [$msg, $type, $delay, $icon, $from, $align];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNotify()
|
||||
{
|
||||
return $this->notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Row
|
||||
*/
|
||||
public function row()
|
||||
{
|
||||
$row = new Row();
|
||||
$this->rows[] = $row;
|
||||
$this->__row__ = $row;
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Column
|
||||
*/
|
||||
public function column($size = 12)
|
||||
{
|
||||
if (!$this->__row__) {
|
||||
$this->row();
|
||||
}
|
||||
|
||||
return $this->__row__->column($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个form
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Form
|
||||
*/
|
||||
public function form($size = 12)
|
||||
{
|
||||
return $this->column($size)->form();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个表格
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Table
|
||||
*/
|
||||
public function table($size = 12)
|
||||
{
|
||||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个工具栏
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Toolbar
|
||||
*/
|
||||
public function toolbar($size = 12)
|
||||
{
|
||||
return $this->column($size)->toolbar();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一自定义内容
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Content
|
||||
*/
|
||||
public function content($size = 12)
|
||||
{
|
||||
return $this->column($size)->content();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一tab内容
|
||||
*
|
||||
* @param integer col大小
|
||||
* @return Tab
|
||||
*/
|
||||
public function tab($size = 12)
|
||||
{
|
||||
return $this->column($size)->tab();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取layer
|
||||
*
|
||||
* @return Layer
|
||||
*/
|
||||
public function layer()
|
||||
{
|
||||
return new Layer;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
$row->beforRender();
|
||||
}
|
||||
|
||||
$this->js[] = '/assets/tpextbuilder/js/layer/layer.js';
|
||||
$this->js[] = '/assets/tpextbuilder/js/tpextbuilder.js';
|
||||
|
||||
$this->css[] = '/assets/tpextbuilder/css/tpextbuilder.css';
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->beforRender();
|
||||
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'content.html']);
|
||||
|
||||
if (!empty($this->notify)) {
|
||||
|
||||
$this->script[] = "lightyear.notify('{$this->notify[0]}', '{$this->notify[1]}', {$this->notify[2]}, '{$this->notify[3]}', '{$this->notify[4]}', '{$this->notify[5]}');";
|
||||
}
|
||||
|
||||
$vars = [
|
||||
'title' => $this->title,
|
||||
'desc' => $this->desc,
|
||||
'rows' => $this->rows,
|
||||
'js' => $this->minify ? [] : array_unique($this->js),
|
||||
'css' => $this->minify ? [] : array_unique($this->css),
|
||||
'style' => implode('', array_unique($this->style)),
|
||||
'script' => implode('', array_unique($this->script)),
|
||||
];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
$instance = Module::getInstance();
|
||||
|
||||
$config = $instance->setConfig(['page_title' => $this->desc, 'page_position' => $this->title]);
|
||||
|
||||
View::share(['admin_page_title' => $this->desc, 'admin_page_position' => $this->title]);
|
||||
|
||||
return $view->assign($vars);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,130 +1,130 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use tpext\builder\common\Form;
|
||||
use tpext\builder\common\Table;
|
||||
|
||||
class Column
|
||||
{
|
||||
public $size = 12;
|
||||
|
||||
protected $elms = [];
|
||||
|
||||
public function __construct($size = 12)
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个form
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
|
||||
public function form()
|
||||
{
|
||||
$form = new Form();
|
||||
$this->elms[] = $form;
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个表格
|
||||
*
|
||||
* @return Table
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
$table = new Table();
|
||||
$this->elms[] = $table;
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个表格
|
||||
*
|
||||
* @return Toolbar
|
||||
*/
|
||||
public function toolbar()
|
||||
{
|
||||
$toolbar = new Toolbar();
|
||||
$this->elms[] = $toolbar;
|
||||
return $toolbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function content()
|
||||
{
|
||||
$content = new Content();
|
||||
$this->elms[] = $content;
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Tab
|
||||
*/
|
||||
public function tab()
|
||||
{
|
||||
$tab = new Tab();
|
||||
$this->elms[] = $tab;
|
||||
return $tab;
|
||||
}
|
||||
|
||||
public function accordion()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一新行
|
||||
*
|
||||
* @return Row
|
||||
*/
|
||||
public function row()
|
||||
{
|
||||
$row = new Row();
|
||||
$this->elms[] = $row;
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElms()
|
||||
{
|
||||
return $this->elms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->elms as $elm) {
|
||||
$elm->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use tpext\builder\common\Form;
|
||||
use tpext\builder\common\Table;
|
||||
|
||||
class Column
|
||||
{
|
||||
public $size = 12;
|
||||
|
||||
protected $elms = [];
|
||||
|
||||
public function __construct($size = 12)
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个form
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
|
||||
public function form()
|
||||
{
|
||||
$form = new Form();
|
||||
$this->elms[] = $form;
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个表格
|
||||
*
|
||||
* @return Table
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
$table = new Table();
|
||||
$this->elms[] = $table;
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个表格
|
||||
*
|
||||
* @return Toolbar
|
||||
*/
|
||||
public function toolbar()
|
||||
{
|
||||
$toolbar = new Toolbar();
|
||||
$this->elms[] = $toolbar;
|
||||
return $toolbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function content()
|
||||
{
|
||||
$content = new Content();
|
||||
$this->elms[] = $content;
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Tab
|
||||
*/
|
||||
public function tab()
|
||||
{
|
||||
$tab = new Tab();
|
||||
$this->elms[] = $tab;
|
||||
return $tab;
|
||||
}
|
||||
|
||||
public function accordion()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一新行
|
||||
*
|
||||
* @return Row
|
||||
*/
|
||||
public function row()
|
||||
{
|
||||
$row = new Row();
|
||||
$this->elms[] = $row;
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElms()
|
||||
{
|
||||
return $this->elms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->elms as $elm) {
|
||||
$elm->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,75 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Content implements Renderable
|
||||
{
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var ViewShow
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
protected $partial = false;
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->partial) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
return $this->content->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function partial($val = true)
|
||||
{
|
||||
$this->partial = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function fetch($template = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($template);
|
||||
|
||||
$this->content->assign($vars)->config($config);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function display($content = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($content);
|
||||
|
||||
$this->content->assign($vars)->config($config)->isContent(true);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Content implements Renderable
|
||||
{
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var ViewShow
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
protected $partial = false;
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->partial) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
return $this->content->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function partial($val = true)
|
||||
{
|
||||
$this->partial = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function fetch($template = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($template);
|
||||
|
||||
$this->content->assign($vars)->config($config);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function display($content = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($content);
|
||||
|
||||
$this->content->assign($vars)->config($config)->isContent(true);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
1232
src/common/Form.php
1232
src/common/Form.php
File diff suppressed because it is too large
Load Diff
|
@ -1,54 +1,54 @@
|
|||
<?php
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Module;
|
||||
|
||||
class Layer
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
public function close($success = true, $msg = '操作成功')
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
'layer_close' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'layer', 'close.html']);
|
||||
|
||||
$vars = [
|
||||
'success' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
return $view->assign($vars);
|
||||
}
|
||||
|
||||
public function closeRefresh($success = true, $msg = '操作成功')
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
'layer_close_refresh' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'layer', 'closeRefresh.html']);
|
||||
|
||||
$vars = [
|
||||
'success' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
return $view->assign($vars);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Module;
|
||||
|
||||
class Layer
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
public function close($success = true, $msg = '操作成功')
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
'layer_close' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'layer', 'close.html']);
|
||||
|
||||
$vars = [
|
||||
'success' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
return $view->assign($vars);
|
||||
}
|
||||
|
||||
public function closeRefresh($success = true, $msg = '操作成功')
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
'layer_close_refresh' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'layer', 'closeRefresh.html']);
|
||||
|
||||
$vars = [
|
||||
'success' => $success ? 1 : 0,
|
||||
'msg' => $msg,
|
||||
];
|
||||
|
||||
$view = new ViewShow($this->view);
|
||||
|
||||
return $view->assign($vars);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
interface Renderable
|
||||
{
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render();
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function beforRender();
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
interface Renderable
|
||||
{
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render();
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function beforRender();
|
||||
}
|
||||
|
|
|
@ -1,112 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Row
|
||||
{
|
||||
protected $cols = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Column
|
||||
*/
|
||||
public function column($size = 12)
|
||||
{
|
||||
$col = new Column($size);
|
||||
$this->cols[] = $col;
|
||||
return $col;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Form
|
||||
*/
|
||||
public function form($size = 12)
|
||||
{
|
||||
return $this->column($size)->form();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Table
|
||||
*/
|
||||
public function table($size = 12)
|
||||
{
|
||||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个工具栏
|
||||
*
|
||||
* @return Toolbar
|
||||
*/
|
||||
public function toolbar($size = 12)
|
||||
{
|
||||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function content($size = 12)
|
||||
{
|
||||
return $this->column($size)->content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Tab
|
||||
*/
|
||||
public function tab($size = 12)
|
||||
{
|
||||
return $this->column($size)->tab();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCols()
|
||||
{
|
||||
return $this->cols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->cols as $col) {
|
||||
$col->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'row.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
$vars = [
|
||||
'cols' => $this->cols,
|
||||
];
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Row
|
||||
{
|
||||
protected $cols = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Column
|
||||
*/
|
||||
public function column($size = 12)
|
||||
{
|
||||
$col = new Column($size);
|
||||
$this->cols[] = $col;
|
||||
return $col;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Form
|
||||
*/
|
||||
public function form($size = 12)
|
||||
{
|
||||
return $this->column($size)->form();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $size
|
||||
* @return Table
|
||||
*/
|
||||
public function table($size = 12)
|
||||
{
|
||||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个工具栏
|
||||
*
|
||||
* @return Toolbar
|
||||
*/
|
||||
public function toolbar($size = 12)
|
||||
{
|
||||
return $this->column($size)->table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function content($size = 12)
|
||||
{
|
||||
return $this->column($size)->content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Tab
|
||||
*/
|
||||
public function tab($size = 12)
|
||||
{
|
||||
return $this->column($size)->tab();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCols()
|
||||
{
|
||||
return $this->cols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->cols as $col) {
|
||||
$col->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'row.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
$vars = [
|
||||
'cols' => $this->cols,
|
||||
];
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,208 +1,208 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\form\FieldsContent;
|
||||
|
||||
class Tab implements Renderable
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $rows = [];
|
||||
|
||||
protected $labels = [];
|
||||
|
||||
protected $active = '';
|
||||
|
||||
protected $id = '';
|
||||
|
||||
protected $partial = false;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
if (empty($this->id)) {
|
||||
$this->id = 'tab-' . mt_rand(1000, 9999);
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param boolean $isActive
|
||||
* @param string $name
|
||||
* @return Row
|
||||
*/
|
||||
public function add($label, $isActive = false, $name = '')
|
||||
{
|
||||
if (empty($name)) {
|
||||
$name = (count($this->rows) + 1);
|
||||
}
|
||||
|
||||
if (empty($this->active) && count($this->rows) == 0) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
if ($isActive) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
$row = new Row();
|
||||
|
||||
$this->rows[$name] = ['content' => $row, 'active' => ''];
|
||||
$this->labels[$name] = ['content' => $label, 'active' => ''];
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function partial($val = true)
|
||||
{
|
||||
$this->partial = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param boolean $isActive
|
||||
* @param string $name
|
||||
* @return FieldsContent
|
||||
*/
|
||||
public function addFieldsContent($label, $isActive = false, $name = '')
|
||||
{
|
||||
if (empty($name)) {
|
||||
$name = (count($this->rows) + 1);
|
||||
}
|
||||
|
||||
if (empty($this->active) && count($this->rows) == 0) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
if ($isActive) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
$content = new FieldsContent();
|
||||
|
||||
$this->rows[$name] = ['content' => $content, 'active' => ''];
|
||||
$this->labels[$name] = ['content' => $label, 'active' => ''];
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function active($val)
|
||||
{
|
||||
$names = array_keys($this->labels);
|
||||
|
||||
if (in_array($val, $names)) {
|
||||
$this->active = $val;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return empty($this->class) ? '' : ' ' . $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
$row['content']->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'tab.html']);
|
||||
|
||||
$this->labels[$this->active]['active'] = 'active';
|
||||
$this->rows[$this->active]['active'] = 'in active';
|
||||
|
||||
$vars = [
|
||||
'labels' => $this->labels,
|
||||
'rows' => $this->rows,
|
||||
'active' => $this->active,
|
||||
'id' => $this->getId(),
|
||||
'class' => $this->class,
|
||||
];
|
||||
|
||||
$viewshow = new ViewShow($this->view);
|
||||
|
||||
if ($this->partial) {
|
||||
return $viewshow->assign($vars);
|
||||
}
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\form\FieldsContent;
|
||||
|
||||
class Tab implements Renderable
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $rows = [];
|
||||
|
||||
protected $labels = [];
|
||||
|
||||
protected $active = '';
|
||||
|
||||
protected $id = '';
|
||||
|
||||
protected $partial = false;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
if (empty($this->id)) {
|
||||
$this->id = 'tab-' . mt_rand(1000, 9999);
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param boolean $isActive
|
||||
* @param string $name
|
||||
* @return Row
|
||||
*/
|
||||
public function add($label, $isActive = false, $name = '')
|
||||
{
|
||||
if (empty($name)) {
|
||||
$name = (count($this->rows) + 1);
|
||||
}
|
||||
|
||||
if (empty($this->active) && count($this->rows) == 0) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
if ($isActive) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
$row = new Row();
|
||||
|
||||
$this->rows[$name] = ['content' => $row, 'active' => ''];
|
||||
$this->labels[$name] = ['content' => $label, 'active' => ''];
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function partial($val = true)
|
||||
{
|
||||
$this->partial = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param boolean $isActive
|
||||
* @param string $name
|
||||
* @return FieldsContent
|
||||
*/
|
||||
public function addFieldsContent($label, $isActive = false, $name = '')
|
||||
{
|
||||
if (empty($name)) {
|
||||
$name = (count($this->rows) + 1);
|
||||
}
|
||||
|
||||
if (empty($this->active) && count($this->rows) == 0) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
if ($isActive) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
$content = new FieldsContent();
|
||||
|
||||
$this->rows[$name] = ['content' => $content, 'active' => ''];
|
||||
$this->labels[$name] = ['content' => $label, 'active' => ''];
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function active($val)
|
||||
{
|
||||
$names = array_keys($this->labels);
|
||||
|
||||
if (in_array($val, $names)) {
|
||||
$this->active = $val;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return empty($this->class) ? '' : ' ' . $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
$row['content']->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'tab.html']);
|
||||
|
||||
$this->labels[$this->active]['active'] = 'active';
|
||||
$this->rows[$this->active]['active'] = 'in active';
|
||||
|
||||
$vars = [
|
||||
'labels' => $this->labels,
|
||||
'rows' => $this->rows,
|
||||
'active' => $this->active,
|
||||
'id' => $this->getId(),
|
||||
'class' => $this->class,
|
||||
];
|
||||
|
||||
$viewshow = new ViewShow($this->view);
|
||||
|
||||
if ($this->partial) {
|
||||
return $viewshow->assign($vars);
|
||||
}
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
1284
src/common/Table.php
1284
src/common/Table.php
File diff suppressed because it is too large
Load Diff
|
@ -1,128 +1,128 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\toolbar\Bar;
|
||||
use tpext\builder\toolbar\Wapper;
|
||||
|
||||
class Toolbar extends Wapper implements Renderable
|
||||
{
|
||||
protected $view = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $elms = [];
|
||||
|
||||
protected $__elm__;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Bar
|
||||
*/
|
||||
public function getCurrent()
|
||||
{
|
||||
return $this->__elm__;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->elms as $elm) {
|
||||
|
||||
$elm->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'toolbar.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
$vars = [
|
||||
'elms' => $this->elms,
|
||||
'class' => $this->class,
|
||||
'attr' => $this->attr,
|
||||
];
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
$count = count($arguments);
|
||||
|
||||
if ($count > 0 && static::isDisplayer($name)) {
|
||||
|
||||
$class = static::$displayerMap[$name];
|
||||
|
||||
$this->__elm__ = new $class($arguments[0], $count > 1 ? $arguments[1] : '');
|
||||
|
||||
$this->__elm__->created();
|
||||
|
||||
$this->elms[] = $this->__elm__;
|
||||
|
||||
return $this->__elm__;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\toolbar\Bar;
|
||||
use tpext\builder\toolbar\Wapper;
|
||||
|
||||
class Toolbar extends Wapper implements Renderable
|
||||
{
|
||||
protected $view = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $elms = [];
|
||||
|
||||
protected $__elm__;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Bar
|
||||
*/
|
||||
public function getCurrent()
|
||||
{
|
||||
return $this->__elm__;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->elms as $elm) {
|
||||
|
||||
$elm->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'toolbar.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
$vars = [
|
||||
'elms' => $this->elms,
|
||||
'class' => $this->class,
|
||||
'attr' => $this->attr,
|
||||
];
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
$count = count($arguments);
|
||||
|
||||
if ($count > 0 && static::isDisplayer($name)) {
|
||||
|
||||
$class = static::$displayerMap[$name];
|
||||
|
||||
$this->__elm__ = new $class($arguments[0], $count > 1 ? $arguments[1] : '');
|
||||
|
||||
$this->__elm__->created();
|
||||
|
||||
$this->elms[] = $this->__elm__;
|
||||
|
||||
return $this->__elm__;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,275 +1,275 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
class Upload
|
||||
{
|
||||
//文件上传保存路径
|
||||
protected $path = '';
|
||||
//允许文件上传的后缀
|
||||
public static $allowSuffix = [
|
||||
//
|
||||
'jpg', 'jpeg', 'gif', 'wbmp', 'webpg', 'png', 'bmp',
|
||||
//
|
||||
"flv", "swf", "mkv", "avi", "rm", "rmvb", "mpeg", "mpg", "ogv", "mov", "wmv", "mp4", "webm",
|
||||
//
|
||||
"ogg", "mp3", "wav", "mid",
|
||||
//
|
||||
"rar", "zip", "tar", "gz", "7z", "bz2", "cab", "iso",
|
||||
//
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "txt", "md",
|
||||
//
|
||||
"xml", "json"];
|
||||
|
||||
//允许文件上传的 Mime 类型
|
||||
protected $allowMime = ['image/jpeg', 'image/gif', 'image/wbmp', 'image/wbmp', 'image/png',
|
||||
'application/x-zip-compressed'];
|
||||
|
||||
//允许文件上传的文件最大大小
|
||||
protected $maxSize = 2000000;
|
||||
//是否启用随机名
|
||||
protected $isRandName = true;
|
||||
//加上文件前缀
|
||||
protected $prefix = 'file';
|
||||
|
||||
//自定义的错误号码和错误信息
|
||||
protected $errorNumber;
|
||||
protected $errorInfo;
|
||||
|
||||
//文件的信息
|
||||
protected $oldName; //文件名
|
||||
protected $suffix; //文件后缀
|
||||
protected $size; //文件大小
|
||||
protected $mime; //文件 mime
|
||||
protected $tmpName; //文件临时路径
|
||||
protected $newName; //文件新名字
|
||||
|
||||
public function __construct($arr = [])
|
||||
{
|
||||
$this->path = app()->getRootPath() . 'public/upload/images/' . date('Ym') . '/';
|
||||
|
||||
foreach ($arr as $key => $value) {
|
||||
$this->setOption($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
if ($name == 'errorNumber') {
|
||||
return $this->errorNumber;
|
||||
} else if ($name == 'errorInfo') {
|
||||
return $this->getErrorInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断这个$key 是不是我的成员属性,如果是,则设置
|
||||
*
|
||||
* @param [type] $key
|
||||
* @param [type] $value
|
||||
* @return void
|
||||
*/
|
||||
protected function setOption($key, $value)
|
||||
{
|
||||
//得到所有的成员属性
|
||||
$keys = array_keys(get_class_vars(__CLASS__));
|
||||
if (in_array($key, $keys)) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传函数
|
||||
* $key 就是你 input 框中的 name 属性值
|
||||
*
|
||||
* @param [type] $key
|
||||
* @return void
|
||||
*/
|
||||
public function uploadFile($key)
|
||||
{
|
||||
//判断有没有设置路径 path
|
||||
if (empty($this->path)) {
|
||||
$this->setOption('errorNumber', -1);
|
||||
return false;
|
||||
}
|
||||
//判断该路径是否存在,是否可写
|
||||
if (!$this->check()) {
|
||||
$this->setOption('errorNumber', -2);
|
||||
return false;
|
||||
}
|
||||
//判断$_FILES 里面的 error 信息是否为 0,如果为 0,说明文件信息在服务器端可以直接获取,提取信息保存到成员属性中
|
||||
$error = $_FILES[$key]['error'];
|
||||
if ($error) {
|
||||
$this->setOption('errorNumber', $error);
|
||||
return false;
|
||||
} else {
|
||||
//提取文件相关信息并且保存到成员属性中
|
||||
$this->getFileInfo($key);
|
||||
}
|
||||
//判断文件的大小、mime、后缀是否符合
|
||||
if (!$this->checkSize() /*|| !$this->checkMime() */ || !$this->checkSuffix()) {
|
||||
return false;
|
||||
}
|
||||
//得到新的文件名字
|
||||
$this->newName = $this->createNewName();
|
||||
//判断是否是上传文件,并且移动上传文件
|
||||
if (is_uploaded_file($this->tmpName)) {
|
||||
if (move_uploaded_file($this->tmpName, $this->path . $this->newName)) {
|
||||
return $this->path . $this->newName;
|
||||
} else {
|
||||
$this->setOption('errorNumber', -7);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->setOption('errorNumber', -6);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到文件的新名字
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function createNewName()
|
||||
{
|
||||
//判断是否使用随机名
|
||||
if ($this->isRandName) {
|
||||
$name = $this->prefix . uniqid() . '.' . $this->suffix;
|
||||
} else {
|
||||
$name = $this->prefix . $this->oldName;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断该路径是否存在,是否可写
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function check()
|
||||
{
|
||||
//文件夹不存在或者不是目录。创建文件夹
|
||||
if (!file_exists($this->path) || !is_dir($this->path)) {
|
||||
return mkdir($this->path, 0755, true);
|
||||
}
|
||||
//判断文件是否可写
|
||||
if (!is_writeable($this->path)) {
|
||||
return chmod($this->path, 0755);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取文件相关信息并且保存到成员属性中
|
||||
*
|
||||
* @param [type] $key
|
||||
* @return void
|
||||
*/
|
||||
protected function getFileInfo($key)
|
||||
{
|
||||
// 得到文件名字
|
||||
$this->oldName = $_FILES[$key]['name'];
|
||||
//得到文件的 mime 类型
|
||||
$this->mime = $_FILES[$key]['type'];
|
||||
//得到文件临时路径
|
||||
$this->tmpName = $_FILES[$key]['tmp_name'];
|
||||
//得到文件大小
|
||||
$this->size = $_FILES[$key]['size'];
|
||||
//得到文件后缀
|
||||
$this->suffix = pathinfo($this->oldName)['extension'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件大小
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkSize()
|
||||
{
|
||||
if ($this->size > $this->maxSize) {
|
||||
$this->setOption('errorNumber', -3);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件的 mime 是否符合
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkMime()
|
||||
{
|
||||
if (!in_array($this->mime, $this->allowMime)) {
|
||||
$this->setOption('errorNumber', -4);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件的后缀是否符合
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkSuffix()
|
||||
{
|
||||
if (!in_array($this->suffix, static::$allowSuffix)) {
|
||||
$this->setOption('errorNumber', -5);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误信息
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getErrorInfo()
|
||||
{
|
||||
switch ($this->errorNumber) {
|
||||
case -1:
|
||||
$str = '文件路径没有设置';
|
||||
break;
|
||||
case -2:
|
||||
$str = '文件路径不是目录或者没有权限';
|
||||
break;
|
||||
case -3:
|
||||
$str = '文件大小超过指定范围';
|
||||
break;
|
||||
case -4:
|
||||
$str = '文件 mime 类型不符合';
|
||||
break;
|
||||
case -5:
|
||||
$str = '文件后缀不符合';
|
||||
break;
|
||||
case -6:
|
||||
$str = '不是上传文件';
|
||||
break;
|
||||
case -7:
|
||||
$str = '文件上传失败';
|
||||
break;
|
||||
case 1:
|
||||
$str = '文件超出 php.ini 设置大小';
|
||||
break;
|
||||
case 2:
|
||||
$str = '文件超出 html 设置大小';
|
||||
break;
|
||||
case 3:
|
||||
$str = '文件部分上传';
|
||||
break;
|
||||
case 4:
|
||||
$str = '没有文件上传';
|
||||
break;
|
||||
case 6:
|
||||
$str = '找不到临时文件';
|
||||
break;
|
||||
case 7:
|
||||
$str = '文件写入失败';
|
||||
break;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
class Upload
|
||||
{
|
||||
//文件上传保存路径
|
||||
protected $path = '';
|
||||
//允许文件上传的后缀
|
||||
protected $allowSuffix = [
|
||||
//
|
||||
'jpg', 'jpeg', 'gif', 'wbmp', 'webpg', 'png', 'bmp',
|
||||
//
|
||||
"flv", "swf", "mkv", "avi", "rm", "rmvb", "mpeg", "mpg", "ogv", "mov", "wmv", "mp4", "webm",
|
||||
//
|
||||
"ogg", "mp3", "wav", "mid",
|
||||
//
|
||||
"rar", "zip", "tar", "gz", "7z", "bz2", "cab", "iso",
|
||||
//
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "txt", "md",
|
||||
//
|
||||
"xml", "json"];
|
||||
|
||||
//允许文件上传的 Mime 类型
|
||||
protected $allowMime = ['image/jpeg', 'image/gif', 'image/wbmp', 'image/wbmp', 'image/png',
|
||||
'application/x-zip-compressed'];
|
||||
|
||||
//允许文件上传的文件最大大小
|
||||
protected $maxSize = 20 * 1024 * 1024;
|
||||
//是否启用随机名
|
||||
protected $isRandName = true;
|
||||
//加上文件前缀
|
||||
protected $prefix = 'file';
|
||||
|
||||
//自定义的错误号码和错误信息
|
||||
protected $errorNumber;
|
||||
protected $errorInfo;
|
||||
|
||||
//文件的信息
|
||||
protected $oldName; //文件名
|
||||
protected $suffix; //文件后缀
|
||||
protected $size; //文件大小
|
||||
protected $mime; //文件 mime
|
||||
protected $tmpName; //文件临时路径
|
||||
protected $newName; //文件新名字
|
||||
|
||||
public function __construct($arr = [])
|
||||
{
|
||||
$this->path = app()->getRootPath() . 'public/upload/images/' . date('Ym') . '/';
|
||||
|
||||
foreach ($arr as $key => $value) {
|
||||
$this->setOption($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
if ($name == 'errorNumber') {
|
||||
return $this->errorNumber;
|
||||
} else if ($name == 'errorInfo') {
|
||||
return $this->getErrorInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断这个$key 是不是我的成员属性,如果是,则设置
|
||||
*
|
||||
* @param [type] $key
|
||||
* @param [type] $value
|
||||
* @return void
|
||||
*/
|
||||
protected function setOption($key, $value)
|
||||
{
|
||||
//得到所有的成员属性
|
||||
$keys = array_keys(get_class_vars(__CLASS__));
|
||||
if (in_array($key, $keys)) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传函数
|
||||
* $key 就是你 input 框中的 name 属性值
|
||||
*
|
||||
* @param [type] $key
|
||||
* @return void
|
||||
*/
|
||||
public function uploadFile($key)
|
||||
{
|
||||
//判断有没有设置路径 path
|
||||
if (empty($this->path)) {
|
||||
$this->setOption('errorNumber', -1);
|
||||
return false;
|
||||
}
|
||||
//判断该路径是否存在,是否可写
|
||||
if (!$this->check()) {
|
||||
$this->setOption('errorNumber', -2);
|
||||
return false;
|
||||
}
|
||||
//判断$_FILES 里面的 error 信息是否为 0,如果为 0,说明文件信息在服务器端可以直接获取,提取信息保存到成员属性中
|
||||
$error = $_FILES[$key]['error'];
|
||||
if ($error) {
|
||||
$this->setOption('errorNumber', $error);
|
||||
return false;
|
||||
} else {
|
||||
//提取文件相关信息并且保存到成员属性中
|
||||
$this->getFileInfo($key);
|
||||
}
|
||||
//判断文件的大小、mime、后缀是否符合
|
||||
if (!$this->checkSize() /*|| !$this->checkMime() */ || !$this->checkSuffix()) {
|
||||
return false;
|
||||
}
|
||||
//得到新的文件名字
|
||||
$this->newName = $this->createNewName();
|
||||
//判断是否是上传文件,并且移动上传文件
|
||||
if (is_uploaded_file($this->tmpName)) {
|
||||
if (move_uploaded_file($this->tmpName, $this->path . $this->newName)) {
|
||||
return $this->path . $this->newName;
|
||||
} else {
|
||||
$this->setOption('errorNumber', -7);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->setOption('errorNumber', -6);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到文件的新名字
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function createNewName()
|
||||
{
|
||||
//判断是否使用随机名
|
||||
if ($this->isRandName) {
|
||||
$name = $this->prefix . uniqid() . '.' . $this->suffix;
|
||||
} else {
|
||||
$name = $this->prefix . $this->oldName;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断该路径是否存在,是否可写
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function check()
|
||||
{
|
||||
//文件夹不存在或者不是目录。创建文件夹
|
||||
if (!file_exists($this->path) || !is_dir($this->path)) {
|
||||
return mkdir($this->path, 0755, true);
|
||||
}
|
||||
//判断文件是否可写
|
||||
if (!is_writeable($this->path)) {
|
||||
return chmod($this->path, 0755);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取文件相关信息并且保存到成员属性中
|
||||
*
|
||||
* @param [type] $key
|
||||
* @return void
|
||||
*/
|
||||
protected function getFileInfo($key)
|
||||
{
|
||||
// 得到文件名字
|
||||
$this->oldName = $_FILES[$key]['name'];
|
||||
//得到文件的 mime 类型
|
||||
$this->mime = $_FILES[$key]['type'];
|
||||
//得到文件临时路径
|
||||
$this->tmpName = $_FILES[$key]['tmp_name'];
|
||||
//得到文件大小
|
||||
$this->size = $_FILES[$key]['size'];
|
||||
//得到文件后缀
|
||||
$this->suffix = pathinfo($this->oldName)['extension'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件大小
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkSize()
|
||||
{
|
||||
if ($this->size > $this->maxSize) {
|
||||
$this->setOption('errorNumber', -3);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件的 mime 是否符合
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkMime()
|
||||
{
|
||||
if (!in_array($this->mime, $this->allowMime)) {
|
||||
$this->setOption('errorNumber', -4);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件的后缀是否符合
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkSuffix()
|
||||
{
|
||||
if (!in_array($this->suffix, $this->allowSuffix)) {
|
||||
$this->setOption('errorNumber', -5);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误信息
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getErrorInfo()
|
||||
{
|
||||
switch ($this->errorNumber) {
|
||||
case -1:
|
||||
$str = '文件路径没有设置';
|
||||
break;
|
||||
case -2:
|
||||
$str = '文件路径不是目录或者没有权限';
|
||||
break;
|
||||
case -3:
|
||||
$str = '文件大小超过指定范围';
|
||||
break;
|
||||
case -4:
|
||||
$str = '文件 mime 类型不符合';
|
||||
break;
|
||||
case -5:
|
||||
$str = '文件后缀不符合';
|
||||
break;
|
||||
case -6:
|
||||
$str = '不是上传文件';
|
||||
break;
|
||||
case -7:
|
||||
$str = '文件上传失败';
|
||||
break;
|
||||
case 1:
|
||||
$str = '文件超出 php.ini 设置大小';
|
||||
break;
|
||||
case 2:
|
||||
$str = '文件超出 html 设置大小';
|
||||
break;
|
||||
case 3:
|
||||
$str = '文件部分上传';
|
||||
break;
|
||||
case 4:
|
||||
$str = '没有文件上传';
|
||||
break;
|
||||
case 6:
|
||||
$str = '找不到临时文件';
|
||||
break;
|
||||
case 7:
|
||||
$str = '文件写入失败';
|
||||
break;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'allowSuffix' =>
|
||||
//
|
||||
"jpg,jpeg,gif,wbmp,webpg,png,bmp," .
|
||||
//
|
||||
"flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,ogv,mov,wmv,mp4,webm," .
|
||||
//
|
||||
"ogg,mp3,wav,mid," .
|
||||
//
|
||||
"rar,zip,tar,gz,7z,bz2,cab,iso," .
|
||||
//
|
||||
"doc,docx,xls,xlsx,ppt,pptx,pdf,txt,md," .
|
||||
//
|
||||
"xml,json,"
|
||||
,
|
||||
'maxSize' => 20,
|
||||
'isRandName' => 1,
|
||||
//配置描述
|
||||
'__config__' => [
|
||||
'allowSuffix' => ['type' => 'textarea', 'label' => '允许上传的文件后缀', 'size' => [2, 10]],
|
||||
'maxSize' => ['type' => 'number', 'label' => '上传文件大小限制(MB)'],
|
||||
'isRandName' => ['type' => 'radio', 'label' => '随机文件名', 'options' => [0 => '否', 1 => '是']],
|
||||
],
|
||||
];
|
|
@ -1,64 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Button extends Field
|
||||
{
|
||||
protected $view = 'button';
|
||||
|
||||
protected $type = 'button';
|
||||
|
||||
protected $bottom = false;
|
||||
|
||||
protected $size = [0, 12];
|
||||
|
||||
protected $showLabel = false;
|
||||
|
||||
protected $class = 'btn-default';
|
||||
|
||||
protected $loading = false;
|
||||
|
||||
public function created()
|
||||
{
|
||||
parent::created();
|
||||
|
||||
if (in_array($this->name, ['submit', 'reset'])) {
|
||||
$this->type = $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return void
|
||||
*/
|
||||
public function type($val)
|
||||
{
|
||||
$this->type = $val;
|
||||
}
|
||||
|
||||
public function loading($val = true)
|
||||
{
|
||||
$this->loading = $val;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->loading) {
|
||||
$this->class .= ' btn-loading';
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'type' => $this->type,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Button extends Field
|
||||
{
|
||||
protected $view = 'button';
|
||||
|
||||
protected $type = 'button';
|
||||
|
||||
protected $bottom = false;
|
||||
|
||||
protected $size = [0, 12];
|
||||
|
||||
protected $showLabel = false;
|
||||
|
||||
protected $class = 'btn-default';
|
||||
|
||||
protected $loading = false;
|
||||
|
||||
public function created()
|
||||
{
|
||||
parent::created();
|
||||
|
||||
if (in_array($this->name, ['submit', 'reset'])) {
|
||||
$this->type = $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return void
|
||||
*/
|
||||
public function type($val)
|
||||
{
|
||||
$this->type = $val;
|
||||
}
|
||||
|
||||
public function loading($val = true)
|
||||
{
|
||||
$this->loading = $val;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->loading) {
|
||||
$this->class .= ' btn-loading';
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'type' => $this->type,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,66 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class CKEditor extends Field
|
||||
{
|
||||
protected $view = 'ckeditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/ckeditor/ckeditor.js',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'language' => 'zh-cn',
|
||||
'uiColor' => '#eeeeee',
|
||||
'height' => 600,
|
||||
'image_previewText' => ' ',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
// 配置可放在config.js中
|
||||
// 成功返回格式{"uploaded":1,"fileName":"图片名称","url":"图片访问路径"}
|
||||
// 失败返回格式{"uploaded":0,"error":{"message":"失败原因"}}
|
||||
|
||||
if (!isset($this->jsOptions['filebrowserImageUploadUrl']) || empty($this->jsOptions['filebrowserImageUploadUrl'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['filebrowserImageUploadUrl'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'ckeditor', 'token' => $token]);
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
// 配置可放在config.js中
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
CKEDITOR.replace('{$this->name}', {$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class CKEditor extends Field
|
||||
{
|
||||
protected $view = 'ckeditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/ckeditor/ckeditor.js',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'language' => 'zh-cn',
|
||||
'uiColor' => '#eeeeee',
|
||||
'height' => 600,
|
||||
'image_previewText' => ' ',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
// 配置可放在config.js中
|
||||
// 成功返回格式{"uploaded":1,"fileName":"图片名称","url":"图片访问路径"}
|
||||
// 失败返回格式{"uploaded":0,"error":{"message":"失败原因"}}
|
||||
|
||||
if (!isset($this->jsOptions['filebrowserImageUploadUrl']) || empty($this->jsOptions['filebrowserImageUploadUrl'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['filebrowserImageUploadUrl'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'ckeditor', 'token' => $token]);
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
// 配置可放在config.js中
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
CKEDITOR.replace('{$this->name}', {$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,102 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Checkbox extends Field
|
||||
{
|
||||
protected $view = 'checkbox';
|
||||
|
||||
protected $class = 'lyear-checkbox checkbox-default';
|
||||
|
||||
protected $options = [];
|
||||
|
||||
protected $inline = true;
|
||||
|
||||
protected $checkallBtn = '';
|
||||
|
||||
protected $default = [];
|
||||
|
||||
protected $checked = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function inline($val = true)
|
||||
{
|
||||
$this->inline = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function checkallBtn($val = '全选')
|
||||
{
|
||||
$this->checkallBtn = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = []) {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null || $this->value === [])) {
|
||||
$this->checked = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
} else if (!($this->default === '' || $this->default === null || $this->default === [])) {
|
||||
$this->checked = is_array($this->default) ? $this->default : explode(',', $this->default);
|
||||
}
|
||||
|
||||
$checkall = false;
|
||||
|
||||
if ($this->checkallBtn) {
|
||||
$count = 0;
|
||||
foreach ($this->options as $key => $op) {
|
||||
if (in_array($key, $this->checked)) {
|
||||
$count += 1;
|
||||
}
|
||||
}
|
||||
$checkall = $count == count($this->options);
|
||||
}
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'inline' => $this->inline ? 'checkbox-inline' : 'm-t-10',
|
||||
'checkallBtn' => $this->checkallBtn,
|
||||
'checkall' => $checkall,
|
||||
'checked' => $this->checked,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Checkbox extends Field
|
||||
{
|
||||
protected $view = 'checkbox';
|
||||
|
||||
protected $class = 'lyear-checkbox checkbox-default';
|
||||
|
||||
protected $options = [];
|
||||
|
||||
protected $inline = true;
|
||||
|
||||
protected $checkallBtn = '';
|
||||
|
||||
protected $default = [];
|
||||
|
||||
protected $checked = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function inline($val = true)
|
||||
{
|
||||
$this->inline = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function checkallBtn($val = '全选')
|
||||
{
|
||||
$this->checkallBtn = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = []) {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null || $this->value === [])) {
|
||||
$this->checked = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
} else if (!($this->default === '' || $this->default === null || $this->default === [])) {
|
||||
$this->checked = is_array($this->default) ? $this->default : explode(',', $this->default);
|
||||
}
|
||||
|
||||
$checkall = false;
|
||||
|
||||
if ($this->checkallBtn) {
|
||||
$count = 0;
|
||||
foreach ($this->options as $key => $op) {
|
||||
if (in_array($key, $this->checked)) {
|
||||
$count += 1;
|
||||
}
|
||||
}
|
||||
$checkall = $count == count($this->options);
|
||||
}
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'inline' => $this->inline ? 'checkbox-inline' : 'm-t-10',
|
||||
'checkallBtn' => $this->checkallBtn,
|
||||
'checkall' => $checkall,
|
||||
'checked' => $this->checked,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,135 +1,135 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Color extends Text
|
||||
{
|
||||
protected $view = 'color';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-colorpicker/bootstrap-colorpicker.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css',
|
||||
];
|
||||
|
||||
protected $format = 'hex';
|
||||
|
||||
protected $inline = false;
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i style="background-color: blue;"></i></span>';
|
||||
|
||||
protected $jsOptions = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* rgb|rgba|hsl|hsla|hex
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rgb()
|
||||
{
|
||||
$this->format('rgb');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rgba()
|
||||
{
|
||||
$this->format('rgba');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hsl()
|
||||
{
|
||||
$this->format('hsl');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hsla()
|
||||
{
|
||||
$this->format('hsla');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hex()
|
||||
{
|
||||
$this->format('hex');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function inline($val)
|
||||
{
|
||||
$this->inline = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function colorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$this->jsOptions['format'] = $this->format;
|
||||
$this->jsOptions['inline'] = $this->inline;
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').parent('div.input-group').colorpicker({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->colorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Color extends Text
|
||||
{
|
||||
protected $view = 'color';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-colorpicker/bootstrap-colorpicker.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css',
|
||||
];
|
||||
|
||||
protected $format = 'hex';
|
||||
|
||||
protected $inline = false;
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i style="background-color: blue;"></i></span>';
|
||||
|
||||
protected $jsOptions = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* rgb|rgba|hsl|hsla|hex
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rgb()
|
||||
{
|
||||
$this->format('rgb');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rgba()
|
||||
{
|
||||
$this->format('rgba');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hsl()
|
||||
{
|
||||
$this->format('hsl');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hsla()
|
||||
{
|
||||
$this->format('hsla');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hex()
|
||||
{
|
||||
$this->format('hex');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function inline($val)
|
||||
{
|
||||
$this->inline = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function colorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$this->jsOptions['format'] = $this->format;
|
||||
$this->jsOptions['inline'] = $this->inline;
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').parent('div.input-group').colorpicker({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->colorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Date extends DateTime
|
||||
{
|
||||
protected $format = 'YYYY-MM-DD';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-range"></i></span>';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'Y-m-d')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Date extends DateTime
|
||||
{
|
||||
protected $format = 'YYYY-MM-DD';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-range"></i></span>';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'Y-m-d')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class DateRange extends DateTimeRange
|
||||
{
|
||||
protected $format = 'YYYY-MM-DD';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-range"></i></span>';
|
||||
|
||||
protected $timePicker = false;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class DateRange extends DateTimeRange
|
||||
{
|
||||
protected $format = 'YYYY-MM-DD';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-range"></i></span>';
|
||||
|
||||
protected $timePicker = false;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,117 +1,117 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class DateTime extends Text
|
||||
{
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/moment/moment.min.js',
|
||||
'/assets/tpextbuilder/js/moment/locale/zh-cn.js',
|
||||
'/assets/tpextbuilder/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js',
|
||||
'/assets/tpextbuilder/js/bootstrap-datetimepicker/locale/zh-cn.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css',
|
||||
];
|
||||
|
||||
protected $size = [2, 3];
|
||||
|
||||
protected $format = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-clock"></i></span>';
|
||||
|
||||
protected $timespan = '';
|
||||
|
||||
protected $jsOptions = [
|
||||
'useCurrent' => false,
|
||||
'locale' => 'zh-cn',
|
||||
'showTodayButton' => false,
|
||||
'showClear' => true,
|
||||
'showClose' => true,
|
||||
'sideBySide' => true,
|
||||
'inline' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function dateTimeScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$str = preg_replace('/\W/', '', $this->name);
|
||||
|
||||
$this->jsOptions['format'] = $this->format;
|
||||
|
||||
$locale = isset($this->jsOptions['locale']) ? $this->jsOptions['locale'] : 'zh-cn';
|
||||
|
||||
unset($this->jsOptions['locale']);
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
var locale{$str} = moment.locale('{$locale}');
|
||||
|
||||
$('#{$inputId}').datetimepicker({
|
||||
"locale" : locale{$str},
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'Y-m-d H:i:s')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->dateTimeScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->timespan) {
|
||||
$this->value = date($this->timespan, $this->value);
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class DateTime extends Text
|
||||
{
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/moment/moment.min.js',
|
||||
'/assets/tpextbuilder/js/moment/locale/zh-cn.js',
|
||||
'/assets/tpextbuilder/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js',
|
||||
'/assets/tpextbuilder/js/bootstrap-datetimepicker/locale/zh-cn.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css',
|
||||
];
|
||||
|
||||
protected $size = [2, 3];
|
||||
|
||||
protected $format = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-clock"></i></span>';
|
||||
|
||||
protected $timespan = '';
|
||||
|
||||
protected $jsOptions = [
|
||||
'useCurrent' => false,
|
||||
'locale' => 'zh-cn',
|
||||
'showTodayButton' => false,
|
||||
'showClear' => true,
|
||||
'showClose' => true,
|
||||
'sideBySide' => true,
|
||||
'inline' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function dateTimeScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$str = preg_replace('/\W/', '', $this->name);
|
||||
|
||||
$this->jsOptions['format'] = $this->format;
|
||||
|
||||
$locale = isset($this->jsOptions['locale']) ? $this->jsOptions['locale'] : 'zh-cn';
|
||||
|
||||
unset($this->jsOptions['locale']);
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
var locale{$str} = moment.locale('{$locale}');
|
||||
|
||||
$('#{$inputId}').datetimepicker({
|
||||
"locale" : locale{$str},
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'Y-m-d H:i:s')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->dateTimeScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->timespan) {
|
||||
$this->value = date($this->timespan, $this->value);
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,120 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class DateTimeRange extends Text
|
||||
{
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/moment/moment.min.js',
|
||||
'/assets/tpextbuilder/js/moment/locale/zh-cn.js',
|
||||
'/assets/tpextbuilder/js/bootstrap-daterangepicker/daterangepicker.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-daterangepicker/daterangepicker.css',
|
||||
];
|
||||
|
||||
protected $size = [2, 6];
|
||||
|
||||
protected $format = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-multiple"></i></span>';
|
||||
|
||||
protected $timePicker = true;
|
||||
|
||||
protected $separator = ' ~ ';
|
||||
|
||||
protected $jsOptions = [
|
||||
'opens' => 'right',
|
||||
'showDropdowns' => true,
|
||||
'timePicker24Hour' => true, //设置小时为24小时制
|
||||
'locale' => [
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function dateTimeRangeScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$this->jsOptions['timePicker'] = $this->timePicker;
|
||||
|
||||
$this->jsOptions['locale'] = array_merge(
|
||||
$this->jsOptions['locale'],
|
||||
[
|
||||
'format' => $this->format,
|
||||
'separator' => $this->separator,
|
||||
]);
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if ($vars['value']) {
|
||||
$values = explode($this->separator, $vars['value']);
|
||||
|
||||
if (count($values) == 2) {
|
||||
$this->jsOptions['startDate'] = $values[0];
|
||||
$this->jsOptions['endDate'] = $values[1];
|
||||
} else {
|
||||
$this->jsOptions['startDate'] = date('Y-m-25 H:i:s');
|
||||
$this->jsOptions['endDate'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').daterangepicker({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* ' ~ '
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function separator($val = ' ~ ')
|
||||
{
|
||||
$this->separator = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->dateTimeRangeScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class DateTimeRange extends Text
|
||||
{
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/moment/moment.min.js',
|
||||
'/assets/tpextbuilder/js/moment/locale/zh-cn.js',
|
||||
'/assets/tpextbuilder/js/bootstrap-daterangepicker/daterangepicker.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-daterangepicker/daterangepicker.css',
|
||||
];
|
||||
|
||||
protected $size = [2, 6];
|
||||
|
||||
protected $format = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-calendar-multiple"></i></span>';
|
||||
|
||||
protected $timePicker = true;
|
||||
|
||||
protected $separator = ' ~ ';
|
||||
|
||||
protected $jsOptions = [
|
||||
'opens' => 'right',
|
||||
'showDropdowns' => true,
|
||||
'timePicker24Hour' => true, //设置小时为24小时制
|
||||
'locale' => [
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function dateTimeRangeScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$this->jsOptions['timePicker'] = $this->timePicker;
|
||||
|
||||
$this->jsOptions['locale'] = array_merge(
|
||||
$this->jsOptions['locale'],
|
||||
[
|
||||
'format' => $this->format,
|
||||
'separator' => $this->separator,
|
||||
]);
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if ($vars['value']) {
|
||||
$values = explode($this->separator, $vars['value']);
|
||||
|
||||
if (count($values) == 2) {
|
||||
$this->jsOptions['startDate'] = $values[0];
|
||||
$this->jsOptions['endDate'] = $values[1];
|
||||
} else {
|
||||
$this->jsOptions['startDate'] = date('Y-m-25 H:i:s');
|
||||
$this->jsOptions['endDate'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').daterangepicker({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY-MM-DD HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* ' ~ '
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function separator($val = ' ~ ')
|
||||
{
|
||||
$this->separator = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->dateTimeRangeScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Divider extends Field
|
||||
{
|
||||
protected $view = 'divider';
|
||||
|
||||
public function created()
|
||||
{
|
||||
parent::created();
|
||||
|
||||
$this->value = $this->name;
|
||||
|
||||
$this->label = '';
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Divider extends Field
|
||||
{
|
||||
protected $view = 'divider';
|
||||
|
||||
public function created()
|
||||
{
|
||||
parent::created();
|
||||
|
||||
$this->value = $this->name;
|
||||
|
||||
$this->label = '';
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,27 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class File extends MultipleFile
|
||||
{
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = '') {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, [
|
||||
'fileNumLimit' => 1,
|
||||
'multiple' => false,
|
||||
]);
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class File extends MultipleFile
|
||||
{
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = '') {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, [
|
||||
'fileNumLimit' => 1,
|
||||
'multiple' => false,
|
||||
]);
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Hidden extends Field
|
||||
{
|
||||
protected $view = 'hidden';
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function created()
|
||||
{
|
||||
$this->getWapper()->addAttr('style="display:none;"');
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Hidden extends Field
|
||||
{
|
||||
protected $view = 'hidden';
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function created()
|
||||
{
|
||||
$this->getWapper()->addAttr('style="display:none;"');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,74 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Html extends Field
|
||||
{
|
||||
protected $view = 'html';
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var ViewShow
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
public function created()
|
||||
{
|
||||
parent::created();
|
||||
|
||||
$this->value = $this->name;
|
||||
|
||||
$this->name = 'html' . mt_rand(100, 999);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function fetch($template = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($template);
|
||||
|
||||
$this->content->assign($vars)->config($config);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $content
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function display($content = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($content);
|
||||
|
||||
$this->content->assign($vars)->config($config)->isContent(true);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->content) {
|
||||
$this->value = $this->content->getContent();
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
|
||||
class Html extends Field
|
||||
{
|
||||
protected $view = 'html';
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var ViewShow
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
public function created()
|
||||
{
|
||||
parent::created();
|
||||
|
||||
$this->value = $this->name;
|
||||
|
||||
$this->name = 'html' . mt_rand(100, 999);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function fetch($template = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($template);
|
||||
|
||||
$this->content->assign($vars)->config($config);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $content
|
||||
* @param array $vars
|
||||
* @param array $config
|
||||
* @return $this
|
||||
*/
|
||||
public function display($content = '', $vars = [], $config = [])
|
||||
{
|
||||
$this->content = new ViewShow($content);
|
||||
|
||||
$this->content->assign($vars)->config($config)->isContent(true);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->content) {
|
||||
$this->value = $this->content->getContent();
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,78 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Icon extends Text
|
||||
{
|
||||
protected $view = 'icon';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/fontIconPicker/jquery.fonticonpicker.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/fontIconPicker/css/jquery.fonticonpicker.min.css',
|
||||
'/assets/tpextbuilder/js/fontIconPicker/themes/bootstrap-theme/jquery.fonticonpicker.bootstrap.min.css',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'theme' => 'fip-bootstrap',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function iconScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$str = preg_replace('/\W/', '', $this->name);
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var icon{$str} = $('#{$inputId}').fontIconPicker({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: '/assets/tpextbuilder/js/fontIconPicker/fontjson/materialdesignicons.json',
|
||||
type: 'GET',
|
||||
dataType: 'json'
|
||||
}).done(function(response) {
|
||||
var fontello_json_icons = [];
|
||||
$.each(response.glyphs, function(i, v) {
|
||||
fontello_json_icons.push( v.css );
|
||||
});
|
||||
|
||||
icon{$str}.setIcons(fontello_json_icons);
|
||||
}).fail(function() {
|
||||
console.error('字体图标配置加载失败');
|
||||
});
|
||||
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->iconScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Icon extends Text
|
||||
{
|
||||
protected $view = 'icon';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/fontIconPicker/jquery.fonticonpicker.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/fontIconPicker/css/jquery.fonticonpicker.min.css',
|
||||
'/assets/tpextbuilder/js/fontIconPicker/themes/bootstrap-theme/jquery.fonticonpicker.bootstrap.min.css',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'theme' => 'fip-bootstrap',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function iconScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$str = preg_replace('/\W/', '', $this->name);
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var icon{$str} = $('#{$inputId}').fontIconPicker({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: '/assets/tpextbuilder/js/fontIconPicker/fontjson/materialdesignicons.json',
|
||||
type: 'GET',
|
||||
dataType: 'json'
|
||||
}).done(function(response) {
|
||||
var fontello_json_icons = [];
|
||||
$.each(response.glyphs, function(i, v) {
|
||||
fontello_json_icons.push( v.css );
|
||||
});
|
||||
|
||||
icon{$str}.setIcons(fontello_json_icons);
|
||||
}).fail(function() {
|
||||
console.error('字体图标配置加载失败');
|
||||
});
|
||||
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->iconScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Image extends File
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$this->image();
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Image extends File
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$this->image();
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class MDEditor extends Field
|
||||
{
|
||||
protected $view = 'mdeditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/editor.md/editormd.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/editor.md/css/editormd.min.css',
|
||||
];
|
||||
|
||||
/*模板样式里面有一个css会影响editor.md的图标,这里重设下*/
|
||||
protected $style = [
|
||||
'.editormd .divider {
|
||||
width: auto;
|
||||
}
|
||||
.editormd .divider:before,
|
||||
.editormd .divider:after {
|
||||
margin: 0px;
|
||||
|
||||
}
|
||||
',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'height' => 600,
|
||||
'path' => "/assets/tpextbuilder/js/editor.md/lib/",
|
||||
'codeFold' => true,
|
||||
'htmlDecode' => 'iframe|on*', // 开启标签
|
||||
'imageUpload' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
/**
|
||||
* 上传的后台只需要返回一个 JSON 数据,结构如下:
|
||||
* {
|
||||
* success : 0 | 1, // 0 表示上传失败,1 表示上传成功
|
||||
* message : "提示的信息,上传成功或上传失败及错误信息等。",
|
||||
* url : "图片地址" // 上传成功时才返回
|
||||
* }
|
||||
*/
|
||||
if (!isset($this->jsOptions['imageUploadURL']) || empty($this->jsOptions['imageUploadURL'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['imageUploadURL'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'editormd', 'token' => $token]);
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var editor = editormd("{$inputId}-div", {$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class MDEditor extends Field
|
||||
{
|
||||
protected $view = 'mdeditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/editor.md/editormd.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/editor.md/css/editormd.min.css',
|
||||
];
|
||||
|
||||
/*模板样式里面有一个css会影响editor.md的图标,这里重设下*/
|
||||
protected $style = [
|
||||
'.editormd .divider {
|
||||
width: auto;
|
||||
}
|
||||
.editormd .divider:before,
|
||||
.editormd .divider:after {
|
||||
margin: 0px;
|
||||
|
||||
}
|
||||
',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'height' => 600,
|
||||
'path' => "/assets/tpextbuilder/js/editor.md/lib/",
|
||||
'codeFold' => true,
|
||||
'htmlDecode' => 'iframe|on*', // 开启标签
|
||||
'imageUpload' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
/**
|
||||
* 上传的后台只需要返回一个 JSON 数据,结构如下:
|
||||
* {
|
||||
* success : 0 | 1, // 0 表示上传失败,1 表示上传成功
|
||||
* message : "提示的信息,上传成功或上传失败及错误信息等。",
|
||||
* url : "图片地址" // 上传成功时才返回
|
||||
* }
|
||||
*/
|
||||
if (!isset($this->jsOptions['imageUploadURL']) || empty($this->jsOptions['imageUploadURL'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['imageUploadURL'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'editormd', 'token' => $token]);
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var editor = editormd("{$inputId}-div", {$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Match extends Raw
|
||||
{
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
if (isset($this->options[$vars['value']])) {
|
||||
$this->value = $vars['value'] = $this->options[$vars['value']];
|
||||
} else if (isset($this->options['__default__'])) {
|
||||
$this->value = $vars['value'] = $this->options['__default__'];
|
||||
}
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Match extends Raw
|
||||
{
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
if (isset($this->options[$vars['value']])) {
|
||||
$this->value = $vars['value'] = $this->options[$vars['value']];
|
||||
} else if (isset($this->options['__default__'])) {
|
||||
$this->value = $vars['value'] = $this->options['__default__'];
|
||||
}
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Matches extends Raw
|
||||
{
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$values = explode(',', $vars['value']);
|
||||
$texts = [];
|
||||
|
||||
foreach ($values as $value) {
|
||||
if (isset($this->options[$value])) {
|
||||
$texts[] = $this->options[$value];
|
||||
}
|
||||
}
|
||||
|
||||
$this->value = $vars['value'] = implode(', ', $texts);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Matches extends Raw
|
||||
{
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$values = explode(',', $vars['value']);
|
||||
$texts = [];
|
||||
|
||||
foreach ($values as $value) {
|
||||
if (isset($this->options[$value])) {
|
||||
$texts[] = $this->options[$value];
|
||||
}
|
||||
}
|
||||
|
||||
$this->value = $vars['value'] = implode(', ', $texts);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Month extends Date
|
||||
{
|
||||
protected $format = 'MM';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* MM
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'm')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Month extends Date
|
||||
{
|
||||
protected $format = 'MM';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* MM
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'm')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,153 +1,153 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
/**
|
||||
* MultipleFile class
|
||||
* @method MultipleFile image()
|
||||
* @method MultipleFile office()
|
||||
* @method MultipleFile video()
|
||||
* @method MultipleFile audio()
|
||||
* @method MultipleFile pkg()
|
||||
*/
|
||||
class MultipleFile extends Field
|
||||
{
|
||||
protected $view = 'multiplefile';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/webuploader/webuploader.min.js',
|
||||
'/assets/tpextbuilder/js/magnific-popup/jquery.magnific-popup.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/webuploader/webuploader.css',
|
||||
'/assets/tpextbuilder/js/magnific-popup/magnific-popup.min.css',
|
||||
'/assets/tpextbuilder/css/uploadfiles.css',
|
||||
];
|
||||
|
||||
protected $canUpload = true;
|
||||
|
||||
protected $files = [];
|
||||
|
||||
protected $jsOptions = [
|
||||
'resize' => false,
|
||||
'duplicate' => true,
|
||||
'ext' => [
|
||||
//
|
||||
'jpg', 'jpeg', 'gif', 'wbmp', 'webpg', 'png', 'bmp',
|
||||
//
|
||||
"flv", "swf", "mkv", "avi", "rm", "rmvb", "mpeg", "mpg", "ogv", "mov", "wmv", "mp4", "webm",
|
||||
//
|
||||
"ogg", "mp3", "wav", "mid",
|
||||
//
|
||||
"rar", "zip", "tar", "gz", "7z", "bz2", "cab", "iso",
|
||||
//
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "txt", "md",
|
||||
//
|
||||
"xml", "json"],
|
||||
'multiple' => true,
|
||||
'mimeTypes' => '*/*',
|
||||
'swf_url' => '/assets/tpextbuilder/js/webuploader/Uploader.swf',
|
||||
'fileSingleSizeLimit' => 5 * 1024 * 1024,
|
||||
'fileNumLimit' => 5,
|
||||
'fileSizeLimit' => 0,
|
||||
'thumbnailWidth' => 165,
|
||||
'thumbnailHeight' => 110,
|
||||
];
|
||||
|
||||
protected $extTypes = [
|
||||
'image' => ['jpg', 'jpeg', 'gif', 'wbmp', 'webpg', 'png', 'bmp'],
|
||||
'office' => ["doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"],
|
||||
'video' => ["flv", "swf", "mkv", "avi", "rm", "rmvb", "mpeg", "mpg", "ogv", "mov", "wmv", "mp4", "webm"],
|
||||
'audio' => ["ogg", "mp3", "wav", "mid"],
|
||||
'pkg' => ["rar", "zip", "tar", "gz", "7z", "bz2", "cab", "iso"],
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = []) {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function canUpload($val)
|
||||
{
|
||||
$this->canUpload = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* fileNumLimit
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function limit($val)
|
||||
{
|
||||
$this->jsOptions['fileNumLimit'] = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (!isset($this->jsOptions['upload_url']) || empty($this->jsOptions['upload_url'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['upload_url'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'webuploader', 'token' => $token]);
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!empty($this->value)) {
|
||||
$this->files = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
} else if (!empty($this->default)) {
|
||||
$this->files = is_array($this->default) ? $this->default : explode(',', $this->default);
|
||||
}
|
||||
|
||||
$this->jsOptions['canUpload'] = $this->canUpload && empty($this->tableRowKey);
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'jsOptions' => $this->jsOptions,
|
||||
'canUpload' => $this->canUpload && empty($this->tableRowKey),
|
||||
'files' => $this->files,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (isset($this->extTypes[$name])) {
|
||||
$this->jsOptions['ext'] = $this->extTypes[$name];
|
||||
return $this;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
/**
|
||||
* MultipleFile class
|
||||
* @method MultipleFile image()
|
||||
* @method MultipleFile office()
|
||||
* @method MultipleFile video()
|
||||
* @method MultipleFile audio()
|
||||
* @method MultipleFile pkg()
|
||||
*/
|
||||
class MultipleFile extends Field
|
||||
{
|
||||
protected $view = 'multiplefile';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/webuploader/webuploader.min.js',
|
||||
'/assets/tpextbuilder/js/magnific-popup/jquery.magnific-popup.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/webuploader/webuploader.css',
|
||||
'/assets/tpextbuilder/js/magnific-popup/magnific-popup.min.css',
|
||||
'/assets/tpextbuilder/css/uploadfiles.css',
|
||||
];
|
||||
|
||||
protected $canUpload = true;
|
||||
|
||||
protected $files = [];
|
||||
|
||||
protected $jsOptions = [
|
||||
'resize' => false,
|
||||
'duplicate' => true,
|
||||
'ext' => [
|
||||
//
|
||||
'jpg', 'jpeg', 'gif', 'wbmp', 'webpg', 'png', 'bmp',
|
||||
//
|
||||
"flv", "swf", "mkv", "avi", "rm", "rmvb", "mpeg", "mpg", "ogv", "mov", "wmv", "mp4", "webm",
|
||||
//
|
||||
"ogg", "mp3", "wav", "mid",
|
||||
//
|
||||
"rar", "zip", "tar", "gz", "7z", "bz2", "cab", "iso",
|
||||
//
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "txt", "md",
|
||||
//
|
||||
"xml", "json"],
|
||||
'multiple' => true,
|
||||
'mimeTypes' => '*/*',
|
||||
'swf_url' => '/assets/tpextbuilder/js/webuploader/Uploader.swf',
|
||||
'fileSingleSizeLimit' => 5 * 1024 * 1024,
|
||||
'fileNumLimit' => 5,
|
||||
'fileSizeLimit' => 0,
|
||||
'thumbnailWidth' => 165,
|
||||
'thumbnailHeight' => 110,
|
||||
];
|
||||
|
||||
protected $extTypes = [
|
||||
'image' => ['jpg', 'jpeg', 'gif', 'wbmp', 'webpg', 'png', 'bmp'],
|
||||
'office' => ["doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"],
|
||||
'video' => ["flv", "swf", "mkv", "avi", "rm", "rmvb", "mpeg", "mpg", "ogv", "mov", "wmv", "mp4", "webm"],
|
||||
'audio' => ["ogg", "mp3", "wav", "mid"],
|
||||
'pkg' => ["rar", "zip", "tar", "gz", "7z", "bz2", "cab", "iso"],
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = []) {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function canUpload($val)
|
||||
{
|
||||
$this->canUpload = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* fileNumLimit
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function limit($val)
|
||||
{
|
||||
$this->jsOptions['fileNumLimit'] = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (!isset($this->jsOptions['upload_url']) || empty($this->jsOptions['upload_url'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['upload_url'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'webuploader', 'token' => $token]);
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!empty($this->value)) {
|
||||
$this->files = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
} else if (!empty($this->default)) {
|
||||
$this->files = is_array($this->default) ? $this->default : explode(',', $this->default);
|
||||
}
|
||||
|
||||
$this->jsOptions['canUpload'] = $this->canUpload && empty($this->tableRowKey);
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'jsOptions' => $this->jsOptions,
|
||||
'canUpload' => $this->canUpload && empty($this->tableRowKey),
|
||||
'files' => $this->files,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (isset($this->extTypes[$name])) {
|
||||
$this->jsOptions['ext'] = $this->extTypes[$name];
|
||||
return $this;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class MultipleImage extends MultipleFile
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$this->image();
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class MultipleImage extends MultipleFile
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$this->image();
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,53 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class MultipleSelect extends Select
|
||||
{
|
||||
protected $view = 'multipleselect';
|
||||
|
||||
protected $attr = 'size="1"';
|
||||
|
||||
protected $default = [];
|
||||
|
||||
protected $checked = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = []) {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->select2) {
|
||||
$this->select2Script();
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null || $this->value === [])) {
|
||||
$this->checked = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
} else if (!($this->default === '' || $this->default === null || $this->default === [])) {
|
||||
$this->checked = is_array($this->default) ? $this->default : explode(',', $this->default);
|
||||
}
|
||||
|
||||
$this->isGroup();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'checked' => $this->checked,
|
||||
'select2' => $this->select2,
|
||||
'group' => $this->group,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class MultipleSelect extends Select
|
||||
{
|
||||
protected $view = 'multipleselect';
|
||||
|
||||
protected $attr = 'size="1"';
|
||||
|
||||
protected $default = [];
|
||||
|
||||
protected $checked = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
function default($val = []) {
|
||||
$this->default = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->select2) {
|
||||
$this->select2Script();
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null || $this->value === [])) {
|
||||
$this->checked = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
} else if (!($this->default === '' || $this->default === null || $this->default === [])) {
|
||||
$this->checked = is_array($this->default) ? $this->default : explode(',', $this->default);
|
||||
}
|
||||
|
||||
$this->isGroup();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'checked' => $this->checked,
|
||||
'select2' => $this->select2,
|
||||
'group' => $this->group,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,100 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Number extends Field
|
||||
{
|
||||
protected $view = 'number';
|
||||
|
||||
protected $rules = 'number';
|
||||
|
||||
protected $size = [2, 3];
|
||||
|
||||
protected $min = 0;
|
||||
|
||||
protected $max = 9999999;
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-touchspin/jquery.bootstrap-touchspin.css',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
//'postfix' => '%',
|
||||
//'prefix' => '¥',
|
||||
'step' => 1,
|
||||
'verticalbuttons' => true,
|
||||
'initval' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function min($val)
|
||||
{
|
||||
$this->min = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function max($val)
|
||||
{
|
||||
$this->max = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function numberScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$this->jsOptions = array_merge($this->jsOptions, [
|
||||
'min' => $this->min,
|
||||
'max' => $this->max,
|
||||
]);
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').TouchSpin({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->numberScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Number extends Field
|
||||
{
|
||||
protected $view = 'number';
|
||||
|
||||
protected $rules = 'number';
|
||||
|
||||
protected $size = [2, 3];
|
||||
|
||||
protected $min = 0;
|
||||
|
||||
protected $max = 9999999;
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/bootstrap-touchspin/jquery.bootstrap-touchspin.css',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
//'postfix' => '%',
|
||||
//'prefix' => '¥',
|
||||
'step' => 1,
|
||||
'verticalbuttons' => true,
|
||||
'initval' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function min($val)
|
||||
{
|
||||
$this->min = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function max($val)
|
||||
{
|
||||
$this->max = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function numberScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$this->jsOptions = array_merge($this->jsOptions, [
|
||||
'min' => $this->min,
|
||||
'max' => $this->max,
|
||||
]);
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').TouchSpin({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->numberScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Password extends Text
|
||||
{
|
||||
protected $view = 'password';
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Password extends Text
|
||||
{
|
||||
protected $view = 'password';
|
||||
}
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Radio extends Field
|
||||
{
|
||||
protected $view = 'radio';
|
||||
|
||||
protected $class = 'lyear-radio radio-default';
|
||||
|
||||
protected $options = [];
|
||||
|
||||
protected $inline = true;
|
||||
|
||||
protected $checked = '';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function inline($val = true)
|
||||
{
|
||||
$this->inline = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null)) {
|
||||
$this->checked = $this->value;
|
||||
} else {
|
||||
$this->checked = $this->default;
|
||||
}
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'inline' => $this->inline ? 'radio-inline' : 'm-t-10',
|
||||
'checked' => $this->checked,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Radio extends Field
|
||||
{
|
||||
protected $view = 'radio';
|
||||
|
||||
protected $class = 'lyear-radio radio-default';
|
||||
|
||||
protected $options = [];
|
||||
|
||||
protected $inline = true;
|
||||
|
||||
protected $checked = '';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function inline($val = true)
|
||||
{
|
||||
$this->inline = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null)) {
|
||||
$this->checked = $this->value;
|
||||
} else {
|
||||
$this->checked = $this->default;
|
||||
}
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'inline' => $this->inline ? 'radio-inline' : 'm-t-10',
|
||||
'checked' => $this->checked,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class RangeSlider extends Text
|
||||
{
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/ion-rangeslider/ion.rangeSlider.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/ion-rangeslider/ion.rangeSlider.min.css',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'type' => 'single',
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
];
|
||||
|
||||
protected $checked = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function rangeScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
if (!empty($this->value)) {
|
||||
$this->checked = is_array($this->value) ? $this->value : explode(';', $this->value);
|
||||
} else if (!empty($this->default)) {
|
||||
$this->checked = is_array($this->default) ? $this->default : explode(';', $this->default);
|
||||
}
|
||||
|
||||
if (count($this->checked) > 0) {
|
||||
$this->jsOptions['from'] = $this->checked[0];
|
||||
|
||||
if (count($this->checked) > 1) {
|
||||
$this->jsOptions['to'] = $this->checked[1];
|
||||
$this->jsOptions['type'] = 'double';
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->disabled) {
|
||||
$this->jsOptions['disable'] = true;
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').ionRangeSlider({$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->rangeScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class RangeSlider extends Text
|
||||
{
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/ion-rangeslider/ion.rangeSlider.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/ion-rangeslider/ion.rangeSlider.min.css',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'type' => 'single',
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
];
|
||||
|
||||
protected $checked = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function rangeScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
if (!empty($this->value)) {
|
||||
$this->checked = is_array($this->value) ? $this->value : explode(';', $this->value);
|
||||
} else if (!empty($this->default)) {
|
||||
$this->checked = is_array($this->default) ? $this->default : explode(';', $this->default);
|
||||
}
|
||||
|
||||
if (count($this->checked) > 0) {
|
||||
$this->jsOptions['from'] = $this->checked[0];
|
||||
|
||||
if (count($this->checked) > 1) {
|
||||
$this->jsOptions['to'] = $this->checked[1];
|
||||
$this->jsOptions['type'] = 'double';
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->disabled) {
|
||||
$this->jsOptions['disable'] = true;
|
||||
}
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$inputId}').ionRangeSlider({$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->rangeScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Rate extends Text
|
||||
{
|
||||
protected $rules = 'number|regex:^([1-9]?\d|100)$';
|
||||
|
||||
protected $after = '<span class="input-group-addon">%</span>';
|
||||
|
||||
protected $size = [2, 3];
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Rate extends Text
|
||||
{
|
||||
protected $rules = 'number|regex:^([1-9]?\d|100)$';
|
||||
|
||||
protected $after = '<span class="input-group-addon">%</span>';
|
||||
|
||||
protected $size = [2, 3];
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Raw extends Field
|
||||
{
|
||||
protected $view = 'raw';
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Raw extends Field
|
||||
{
|
||||
protected $view = 'raw';
|
||||
}
|
||||
|
|
|
@ -1,205 +1,205 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Select extends Radio
|
||||
{
|
||||
protected $view = 'select';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/select2/select2.min.js',
|
||||
'/assets/tpextbuilder/js/select2/i18n/zh-CN.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/select2/select2.min.css',
|
||||
];
|
||||
|
||||
protected $options = [];
|
||||
|
||||
protected $attr = 'size="1"';
|
||||
|
||||
protected $group = false;
|
||||
|
||||
protected $select2 = true;
|
||||
|
||||
protected $jsOptions = [
|
||||
'placeholder' => '请选择',
|
||||
'allowClear' => true,
|
||||
'minimumInputLength' => 0,
|
||||
'language' => 'zh-CN',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $show
|
||||
* @return $this
|
||||
*/
|
||||
public function select2($use)
|
||||
{
|
||||
$this->select2 = $use;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $show
|
||||
* @return $this
|
||||
*/
|
||||
public function dataUrl($url, $options = ['delay' => 250, 'id' => 'id', 'text' => 'text'], $loadmore = true)
|
||||
{
|
||||
$this->jsOptions['ajax'] = [
|
||||
'url' => $url,
|
||||
'options' => $options,
|
||||
'loadmore' => $loadmore,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function select2Script()
|
||||
{
|
||||
$script = '';
|
||||
$selectId = $this->getId();
|
||||
|
||||
if (isset($this->jsOptions['ajax'])) {
|
||||
$ajax = $this->jsOptions['ajax'];
|
||||
unset($this->jsOptions['ajax']);
|
||||
$url = $ajax['url'];
|
||||
$id = isset($ajax['id']) ? $ajax['id'] : 'id';
|
||||
$text = isset($ajax['text']) ? $ajax['text'] : 'text';
|
||||
$delay = isset($ajax['delay']) ? $ajax['delay'] : 250;
|
||||
$loadmore = $ajax['loadmore'];
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
$('#{$selectId}').select2({
|
||||
{$configs},
|
||||
ajax: {
|
||||
url: '{$url}',
|
||||
dataType: 'json',
|
||||
delay: {$delay},
|
||||
data: function (params) {
|
||||
return {
|
||||
q: params.term || '',
|
||||
page: params.page || 1,
|
||||
eleid : '{$selectId}'
|
||||
};
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
params.page = params.page || 1;
|
||||
var list = data.data ? data.data : data;
|
||||
return {
|
||||
results: $.map(list, function (d) {
|
||||
d.id = d.{$id};
|
||||
d.text = d.{$text};
|
||||
return d;
|
||||
}),
|
||||
pagination: {
|
||||
more: {$loadmore} ? data.more_url : ''
|
||||
}
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
escapeMarkup: function (markup) {
|
||||
return markup;
|
||||
}
|
||||
});
|
||||
|
||||
EOT;
|
||||
} else {
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
$('#{$selectId}').select2({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
}
|
||||
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
protected function isGroup()
|
||||
{
|
||||
foreach ($this->options as $option) {
|
||||
|
||||
if (isset($option['options']) && isset($option['label'])) {
|
||||
$this->group = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if ($this->select2) {
|
||||
$this->select2Script();
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null)) {
|
||||
$this->checked = $this->value;
|
||||
} else {
|
||||
$this->checked = $this->default;
|
||||
}
|
||||
|
||||
$this->isGroup();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'checked' => $this->checked,
|
||||
'select2' => $this->select2,
|
||||
'group' => $this->group,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Select extends Radio
|
||||
{
|
||||
protected $view = 'select';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/select2/select2.min.js',
|
||||
'/assets/tpextbuilder/js/select2/i18n/zh-CN.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/select2/select2.min.css',
|
||||
];
|
||||
|
||||
protected $options = [];
|
||||
|
||||
protected $attr = 'size="1"';
|
||||
|
||||
protected $group = false;
|
||||
|
||||
protected $select2 = true;
|
||||
|
||||
protected $jsOptions = [
|
||||
'placeholder' => '请选择',
|
||||
'allowClear' => true,
|
||||
'minimumInputLength' => 0,
|
||||
'language' => 'zh-CN',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $show
|
||||
* @return $this
|
||||
*/
|
||||
public function select2($use)
|
||||
{
|
||||
$this->select2 = $use;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function options($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $show
|
||||
* @return $this
|
||||
*/
|
||||
public function dataUrl($url, $options = ['delay' => 250, 'id' => 'id', 'text' => 'text'], $loadmore = true)
|
||||
{
|
||||
$this->jsOptions['ajax'] = [
|
||||
'url' => $url,
|
||||
'options' => $options,
|
||||
'loadmore' => $loadmore,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function select2Script()
|
||||
{
|
||||
$script = '';
|
||||
$selectId = $this->getId();
|
||||
|
||||
if (isset($this->jsOptions['ajax'])) {
|
||||
$ajax = $this->jsOptions['ajax'];
|
||||
unset($this->jsOptions['ajax']);
|
||||
$url = $ajax['url'];
|
||||
$id = isset($ajax['id']) ? $ajax['id'] : 'id';
|
||||
$text = isset($ajax['text']) ? $ajax['text'] : 'text';
|
||||
$delay = isset($ajax['delay']) ? $ajax['delay'] : 250;
|
||||
$loadmore = $ajax['loadmore'];
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
$('#{$selectId}').select2({
|
||||
{$configs},
|
||||
ajax: {
|
||||
url: '{$url}',
|
||||
dataType: 'json',
|
||||
delay: {$delay},
|
||||
data: function (params) {
|
||||
return {
|
||||
q: params.term || '',
|
||||
page: params.page || 1,
|
||||
eleid : '{$selectId}'
|
||||
};
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
params.page = params.page || 1;
|
||||
var list = data.data ? data.data : data;
|
||||
return {
|
||||
results: $.map(list, function (d) {
|
||||
d.id = d.{$id};
|
||||
d.text = d.{$text};
|
||||
return d;
|
||||
}),
|
||||
pagination: {
|
||||
more: {$loadmore} ? data.more_url : ''
|
||||
}
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
escapeMarkup: function (markup) {
|
||||
return markup;
|
||||
}
|
||||
});
|
||||
|
||||
EOT;
|
||||
} else {
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$configs = substr($configs, 1, strlen($configs) - 2);
|
||||
|
||||
$script = <<<EOT
|
||||
$('#{$selectId}').select2({
|
||||
{$configs}
|
||||
});
|
||||
|
||||
EOT;
|
||||
}
|
||||
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
protected function isGroup()
|
||||
{
|
||||
foreach ($this->options as $option) {
|
||||
|
||||
if (isset($option['options']) && isset($option['label'])) {
|
||||
$this->group = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if ($this->select2) {
|
||||
$this->select2Script();
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!($this->value === '' || $this->value === null)) {
|
||||
$this->checked = $this->value;
|
||||
} else {
|
||||
$this->checked = $this->default;
|
||||
}
|
||||
|
||||
$this->isGroup();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'checked' => $this->checked,
|
||||
'select2' => $this->select2,
|
||||
'group' => $this->group,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Show extends Field
|
||||
{
|
||||
protected $view = 'show';
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Show extends Field
|
||||
{
|
||||
protected $view = 'show';
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class SwitchBtn extends Field
|
||||
{
|
||||
protected $view = 'switchbtn';
|
||||
|
||||
protected $class = 'switch-solid switch-primary';
|
||||
|
||||
protected $checked = '';
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!empty($this->value)) {
|
||||
$this->checked = $this->value;
|
||||
} else {
|
||||
$this->checked = $this->default;
|
||||
}
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'checked' => $this->checked,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class SwitchBtn extends Field
|
||||
{
|
||||
protected $view = 'switchbtn';
|
||||
|
||||
protected $class = 'switch-solid switch-primary';
|
||||
|
||||
protected $checked = '';
|
||||
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
if (!empty($this->value)) {
|
||||
$this->checked = $this->value;
|
||||
} else {
|
||||
$this->checked = $this->default;
|
||||
}
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'checked' => $this->checked,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Tags extends Field
|
||||
{
|
||||
protected $view = 'tags';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/jquery-tags-input/jquery.tagsinput.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/jquery-tags-input/jquery.tagsinput.min.css',
|
||||
];
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Tags extends Field
|
||||
{
|
||||
protected $view = 'tags';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/jquery-tags-input/jquery.tagsinput.min.js',
|
||||
];
|
||||
|
||||
protected $css = [
|
||||
'/assets/tpextbuilder/js/jquery-tags-input/jquery.tagsinput.min.css',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,97 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Text extends Field
|
||||
{
|
||||
protected $view = 'text';
|
||||
|
||||
protected $befor = '';
|
||||
|
||||
protected $after = '';
|
||||
|
||||
protected $maxlength = 0;
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-maxlength/bootstrap-maxlength.min.js',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $val
|
||||
* @return $this
|
||||
*/
|
||||
public function maxlength($val = 0)
|
||||
{
|
||||
$this->maxlength = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $html
|
||||
* @return $this
|
||||
*/
|
||||
public function befor($html)
|
||||
{
|
||||
$this->befor = $html;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $text
|
||||
* @return $this
|
||||
*/
|
||||
public function after($html)
|
||||
{
|
||||
$this->after = $html;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $text
|
||||
* @return $this
|
||||
*/
|
||||
public function beforSymbol($text)
|
||||
{
|
||||
$this->befor = '<span class="input-group-addon">' . $text . '</span>';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $html
|
||||
* @return $this
|
||||
*/
|
||||
public function afterSymbol($text)
|
||||
{
|
||||
$this->after = '<span class="input-group-addon">' . $text . '</span>';
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
if ($this->maxlength > 0) {
|
||||
$this->attr .= ' maxlength="' . $this->maxlength . '"';
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'befor' => $this->befor,
|
||||
'after' => $this->after,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Text extends Field
|
||||
{
|
||||
protected $view = 'text';
|
||||
|
||||
protected $befor = '';
|
||||
|
||||
protected $after = '';
|
||||
|
||||
protected $maxlength = 0;
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-maxlength/bootstrap-maxlength.min.js',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $val
|
||||
* @return $this
|
||||
*/
|
||||
public function maxlength($val = 0)
|
||||
{
|
||||
$this->maxlength = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $html
|
||||
* @return $this
|
||||
*/
|
||||
public function befor($html)
|
||||
{
|
||||
$this->befor = $html;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $text
|
||||
* @return $this
|
||||
*/
|
||||
public function after($html)
|
||||
{
|
||||
$this->after = $html;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $text
|
||||
* @return $this
|
||||
*/
|
||||
public function beforSymbol($text)
|
||||
{
|
||||
$this->befor = '<span class="input-group-addon">' . $text . '</span>';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $html
|
||||
* @return $this
|
||||
*/
|
||||
public function afterSymbol($text)
|
||||
{
|
||||
$this->after = '<span class="input-group-addon">' . $text . '</span>';
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
if ($this->maxlength > 0) {
|
||||
$this->attr .= ' maxlength="' . $this->maxlength . '"';
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'befor' => $this->befor,
|
||||
'after' => $this->after,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Textarea extends Field
|
||||
{
|
||||
protected $view = 'textarea';
|
||||
|
||||
protected $maxlength = 0;
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-maxlength/bootstrap-maxlength.min.js',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $val
|
||||
* @return $this
|
||||
*/
|
||||
public function maxlength($val = 0)
|
||||
{
|
||||
$this->maxlength = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
if ($this->maxlength > 0) {
|
||||
$this->attr .= ' maxlength="' . $this->maxlength . '"';
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Textarea extends Field
|
||||
{
|
||||
protected $view = 'textarea';
|
||||
|
||||
protected $maxlength = 0;
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/bootstrap-maxlength/bootstrap-maxlength.min.js',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param integer $val
|
||||
* @return $this
|
||||
*/
|
||||
public function maxlength($val = 0)
|
||||
{
|
||||
$this->maxlength = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
if ($this->maxlength > 0) {
|
||||
$this->attr .= ' maxlength="' . $this->maxlength . '"';
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Time extends DateTime
|
||||
{
|
||||
protected $format = 'HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-clock"></i></span>';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'H:i:s')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Time extends DateTime
|
||||
{
|
||||
protected $format = 'HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-clock"></i></span>';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'H:i:s')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class TimeRange extends DateTimeRange
|
||||
{
|
||||
protected $format = 'HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-clock"></i></span>';
|
||||
|
||||
protected $timePicker = true;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class TimeRange extends DateTimeRange
|
||||
{
|
||||
protected $format = 'HH:mm:ss';
|
||||
|
||||
protected $befor = '<span class="input-group-addon"><i class="mdi mdi-clock"></i></span>';
|
||||
|
||||
protected $timePicker = true;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* HH:mm:ss
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,72 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Tinymce extends Field
|
||||
{
|
||||
protected $view = 'tinymce';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/tinymce/tinymce.min.js',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'language' => 'zh_CN',
|
||||
'directionality' => 'ltl',
|
||||
'browser_spellcheck' => true,
|
||||
'contextmenu' => false,
|
||||
'height' => 600,
|
||||
'plugins' => [
|
||||
"advlist autolink lists link image charmap print preview anchor",
|
||||
"searchreplace visualblocks code fullscreen",
|
||||
"insertdatetime media table contextmenu paste imagetools wordcount",
|
||||
"code",
|
||||
],
|
||||
'toolbar' => "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code",
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
if (!isset($this->jsOptions['images_upload_url']) || empty($this->jsOptions['images_upload_url'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['images_upload_url'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'tinymce', 'token' => $token]);
|
||||
}
|
||||
|
||||
$this->jsOptions['selector'] = "#{$inputId}";
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
tinymce.init({$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Tinymce extends Field
|
||||
{
|
||||
protected $view = 'tinymce';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/tinymce/tinymce.min.js',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'language' => 'zh_CN',
|
||||
'directionality' => 'ltl',
|
||||
'browser_spellcheck' => true,
|
||||
'contextmenu' => false,
|
||||
'height' => 600,
|
||||
'plugins' => [
|
||||
"advlist autolink lists link image charmap print preview anchor",
|
||||
"searchreplace visualblocks code fullscreen",
|
||||
"insertdatetime media table contextmenu paste imagetools wordcount",
|
||||
"code",
|
||||
],
|
||||
'toolbar' => "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code",
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
if (!isset($this->jsOptions['images_upload_url']) || empty($this->jsOptions['images_upload_url'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['images_upload_url'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'tinymce', 'token' => $token]);
|
||||
}
|
||||
|
||||
$this->jsOptions['selector'] = "#{$inputId}";
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
tinymce.init({$configs});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,85 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class UEditor extends Field
|
||||
{
|
||||
protected $view = 'ueditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/ueditor/ueditor.config.js',
|
||||
];
|
||||
|
||||
protected $configJsPath = '/assets/tpextbuilder/js/ueditor/ueditor.all.min.js';
|
||||
|
||||
protected $uploadUrl = '';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function configJsPath($val)
|
||||
{
|
||||
$this->configJsPath = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function uploadUrl($val)
|
||||
{
|
||||
$this->uploadUrl = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var ue = UE.getEditor('{$inputId}');
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->js[] = $this->configJsPath;
|
||||
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->uploadUrl)) {
|
||||
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());$token = md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->uploadUrl = url('/tpextbuilder/admin/upload/ueditor', ['token' => $token]);
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'uploadUrl' => $this->uploadUrl,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class UEditor extends Field
|
||||
{
|
||||
protected $view = 'ueditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/ueditor/ueditor.config.js',
|
||||
];
|
||||
|
||||
protected $configJsPath = '/assets/tpextbuilder/js/ueditor/ueditor.all.min.js';
|
||||
|
||||
protected $uploadUrl = '';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function configJsPath($val)
|
||||
{
|
||||
$this->configJsPath = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function uploadUrl($val)
|
||||
{
|
||||
$this->uploadUrl = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var ue = UE.getEditor('{$inputId}');
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->js[] = $this->configJsPath;
|
||||
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->uploadUrl)) {
|
||||
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());$token = md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->uploadUrl = url('/tpextbuilder/admin/upload/ueditor', ['token' => $token]);
|
||||
}
|
||||
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'uploadUrl' => $this->uploadUrl,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,83 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class WangEditor extends Field
|
||||
{
|
||||
protected $view = 'wangeditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/wangEditor/wangEditor.min.js',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'uploadImgMaxSize' => 20 * 1024 * 1024,
|
||||
'uploadImgMaxLength' => 10,
|
||||
'uploadImgTimeout' => 3000,
|
||||
'uploadFileName' => 'file',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
if (!isset($this->jsOptions['uploadImgServer']) || empty($this->jsOptions['uploadImgServer'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['uploadImgServer'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'wangeditor', 'token' => $token]);
|
||||
}
|
||||
|
||||
$this->jsOptions['uploadImgParams'] = [];
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var E = window.wangEditor;
|
||||
var editor = new E('#{$inputId}-div');
|
||||
|
||||
editor.customConfig = {$configs};
|
||||
|
||||
editor.customConfig.uploadImgHooks = {
|
||||
customInsert: function (insertImg, result, editor) {
|
||||
// 图片上传并返回结果,自定义插入图片的事件(而不是编辑器自动插入图片!!!)
|
||||
// insertImg 是插入图片的函数,editor 是编辑器对象,result 是服务器端返回的结果
|
||||
// 举例:假如上传图片成功后,服务器端返回的是 {url:'....'} 这种格式,即可这样插入图片:
|
||||
var url = result.url;
|
||||
insertImg(url);
|
||||
// result 必须是一个 JSON 格式字符串!!!否则报错
|
||||
}
|
||||
};
|
||||
// 设置内容
|
||||
editor.customConfig.onchange = function (html) {
|
||||
$('#{$inputId}').val(html);
|
||||
}
|
||||
editor.create();
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class WangEditor extends Field
|
||||
{
|
||||
protected $view = 'wangeditor';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/wangEditor/wangEditor.min.js',
|
||||
];
|
||||
|
||||
protected $jsOptions = [
|
||||
'uploadImgMaxSize' => 20 * 1024 * 1024,
|
||||
'uploadImgMaxLength' => 10,
|
||||
'uploadImgTimeout' => 3000,
|
||||
'uploadFileName' => 'file',
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function jsOptions($options)
|
||||
{
|
||||
$this->jsOptions = array_merge($this->jsOptions, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function editorScript()
|
||||
{
|
||||
$inputId = $this->getId();
|
||||
|
||||
if (!isset($this->jsOptions['uploadImgServer']) || empty($this->jsOptions['uploadImgServer'])) {
|
||||
$token = session('uploadtoken') ? session('uploadtoken') : md5('uploadtoken' . time() . uniqid());
|
||||
|
||||
session('uploadtoken', $token);
|
||||
|
||||
$this->jsOptions['uploadImgServer'] = url('/tpextbuilder/admin/upload/upfiles', ['type' => 'wangeditor', 'token' => $token]);
|
||||
}
|
||||
|
||||
$this->jsOptions['uploadImgParams'] = [];
|
||||
|
||||
$configs = json_encode($this->jsOptions);
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
var E = window.wangEditor;
|
||||
var editor = new E('#{$inputId}-div');
|
||||
|
||||
editor.customConfig = {$configs};
|
||||
|
||||
editor.customConfig.uploadImgHooks = {
|
||||
customInsert: function (insertImg, result, editor) {
|
||||
// 图片上传并返回结果,自定义插入图片的事件(而不是编辑器自动插入图片!!!)
|
||||
// insertImg 是插入图片的函数,editor 是编辑器对象,result 是服务器端返回的结果
|
||||
// 举例:假如上传图片成功后,服务器端返回的是 {url:'....'} 这种格式,即可这样插入图片:
|
||||
var url = result.url;
|
||||
insertImg(url);
|
||||
// result 必须是一个 JSON 格式字符串!!!否则报错
|
||||
}
|
||||
};
|
||||
// 设置内容
|
||||
editor.customConfig.onchange = function (html) {
|
||||
$('#{$inputId}').val(html);
|
||||
}
|
||||
editor.create();
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
$this->editorScript();
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Year extends Date
|
||||
{
|
||||
protected $format = 'YYYY';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'Y')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Year extends Date
|
||||
{
|
||||
protected $format = 'YYYY';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* YYYY
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function format($val)
|
||||
{
|
||||
$this->format = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function timespan($val = 'Y')
|
||||
{
|
||||
$this->timespan = $val;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,78 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Renderable;
|
||||
use tpext\builder\common\Module;
|
||||
|
||||
class FieldsContent extends Wapper implements Renderable
|
||||
{
|
||||
protected $rows = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
|
||||
$row->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param Row $row
|
||||
* @return void
|
||||
*/
|
||||
public function addRow($row)
|
||||
{
|
||||
$this->rows[] = $row;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'form', 'fieldscontent.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
$vars = [
|
||||
'rows' => $this->rows,
|
||||
];
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
$count = count($arguments);
|
||||
|
||||
if ($count > 0 && static::isDisplayer($name)) {
|
||||
|
||||
$row = new Row($arguments[0], $count > 1 ? $arguments[1] : '', $count > 2 ? $arguments[2] : 12, $count > 3 ? $arguments[3] : '', $count > 4 ? $arguments[4] : '');
|
||||
|
||||
$this->rows[] = $row;
|
||||
|
||||
return $row->$name($arguments[0], $row->getLabel());
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Renderable;
|
||||
use tpext\builder\common\Module;
|
||||
|
||||
class FieldsContent extends Wapper implements Renderable
|
||||
{
|
||||
protected $rows = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
|
||||
$row->beforRender();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param Row $row
|
||||
* @return void
|
||||
*/
|
||||
public function addRow($row)
|
||||
{
|
||||
$this->rows[] = $row;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'form', 'fieldscontent.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
$vars = [
|
||||
'rows' => $this->rows,
|
||||
];
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
$count = count($arguments);
|
||||
|
||||
if ($count > 0 && static::isDisplayer($name)) {
|
||||
|
||||
$row = new Row($arguments[0], $count > 1 ? $arguments[1] : '', $count > 2 ? $arguments[2] : 12, $count > 3 ? $arguments[3] : '', $count > 4 ? $arguments[4] : '');
|
||||
|
||||
$this->rows[] = $row;
|
||||
|
||||
return $row->$name($arguments[0], $row->getLabel());
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
|
|
554
src/form/Row.php
554
src/form/Row.php
|
@ -1,277 +1,277 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
use tpext\builder\common\Renderable;
|
||||
|
||||
class Row extends Wapper implements Renderable
|
||||
{
|
||||
protected $attributes = [];
|
||||
|
||||
protected $name = '';
|
||||
|
||||
protected $label = '';
|
||||
|
||||
protected $cloSize = 12;
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $errorClass = '';
|
||||
|
||||
/**
|
||||
* Displayer
|
||||
*
|
||||
* @var \tpext\builder\displayer\Field
|
||||
*/
|
||||
protected $displayer;
|
||||
|
||||
public function __construct($name, $label = '', $colSize = 12, $colClass = '', $colAttr = '')
|
||||
{
|
||||
if (empty($label)) {
|
||||
$label = ucfirst($name);
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
$this->cloSize = $colSize;
|
||||
$this->class = $colClass;
|
||||
$this->attr = $colAttr;
|
||||
|
||||
$this->createDisplayer(\tpext\builder\displayer\Field::class, [$name, $label]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function cloSize($val)
|
||||
{
|
||||
$this->size = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function style($val)
|
||||
{
|
||||
$this->style = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function errorClass($val)
|
||||
{
|
||||
$this->errorClass = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addStyle($val)
|
||||
{
|
||||
$this->style .= $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColSize()
|
||||
{
|
||||
return $this->cloSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
$arr = explode(' ', $this->class);
|
||||
|
||||
return 'row-' . $this->name . ' ' . implode(' ', array_unique($arr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorClass()
|
||||
{
|
||||
return $this->errorClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttr()
|
||||
{
|
||||
return (empty($this->attr) ? '' : ' ' . $this->attr) . (empty($this->style) ? '' : ' style="' . $this->style . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return \tpext\builder\displayer\Field
|
||||
*/
|
||||
public function getDisplayer()
|
||||
{
|
||||
return $this->displayer;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return $this->displayer->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
$this->displayer->beforRender();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function fill($data = [])
|
||||
{
|
||||
$this->displayer->fill($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function createDisplayer($class, $arguments)
|
||||
{
|
||||
$displayer = new $class($arguments[0], $arguments[1]);
|
||||
$displayer->setWapper($this);
|
||||
$displayer->created();
|
||||
|
||||
$this->displayer = $displayer;
|
||||
|
||||
return $displayer;
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (static::isDisplayer($name)) {
|
||||
|
||||
$class = static::$displayerMap[$name];
|
||||
|
||||
return $this->createDisplayer($class, $arguments);
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
use tpext\builder\common\Renderable;
|
||||
|
||||
class Row extends Wapper implements Renderable
|
||||
{
|
||||
protected $attributes = [];
|
||||
|
||||
protected $name = '';
|
||||
|
||||
protected $label = '';
|
||||
|
||||
protected $cloSize = 12;
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $errorClass = '';
|
||||
|
||||
/**
|
||||
* Displayer
|
||||
*
|
||||
* @var \tpext\builder\displayer\Field
|
||||
*/
|
||||
protected $displayer;
|
||||
|
||||
public function __construct($name, $label = '', $colSize = 12, $colClass = '', $colAttr = '')
|
||||
{
|
||||
if (empty($label)) {
|
||||
$label = ucfirst($name);
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
$this->cloSize = $colSize;
|
||||
$this->class = $colClass;
|
||||
$this->attr = $colAttr;
|
||||
|
||||
$this->createDisplayer(\tpext\builder\displayer\Field::class, [$name, $label]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function cloSize($val)
|
||||
{
|
||||
$this->size = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function style($val)
|
||||
{
|
||||
$this->style = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function errorClass($val)
|
||||
{
|
||||
$this->errorClass = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addStyle($val)
|
||||
{
|
||||
$this->style .= $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColSize()
|
||||
{
|
||||
return $this->cloSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
$arr = explode(' ', $this->class);
|
||||
|
||||
return 'row-' . $this->name . ' ' . implode(' ', array_unique($arr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorClass()
|
||||
{
|
||||
return $this->errorClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttr()
|
||||
{
|
||||
return (empty($this->attr) ? '' : ' ' . $this->attr) . (empty($this->style) ? '' : ' style="' . $this->style . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return \tpext\builder\displayer\Field
|
||||
*/
|
||||
public function getDisplayer()
|
||||
{
|
||||
return $this->displayer;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return $this->displayer->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
$this->displayer->beforRender();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function fill($data = [])
|
||||
{
|
||||
$this->displayer->fill($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function createDisplayer($class, $arguments)
|
||||
{
|
||||
$displayer = new $class($arguments[0], $arguments[1]);
|
||||
$displayer->setWapper($this);
|
||||
$displayer->created();
|
||||
|
||||
$this->displayer = $displayer;
|
||||
|
||||
return $displayer;
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if (static::isDisplayer($name)) {
|
||||
|
||||
$class = static::$displayerMap[$name];
|
||||
|
||||
return $this->createDisplayer($class, $arguments);
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,255 +1,255 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Builder;
|
||||
use tpext\builder\common\Module;
|
||||
use tpext\builder\common\Renderable;
|
||||
|
||||
class Step implements Renderable
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $navigateable = true;
|
||||
|
||||
protected $size = [2, 8];
|
||||
|
||||
protected $rows = [];
|
||||
|
||||
protected $labels = [];
|
||||
|
||||
protected $active = '';
|
||||
|
||||
protected $id = '';
|
||||
|
||||
protected $mode = 'dots';
|
||||
|
||||
public function getId()
|
||||
{
|
||||
if (empty($this->id)) {
|
||||
$this->id = 'step-' . mt_rand(1000, 9999);
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param boolean $isActive
|
||||
* @param string $name
|
||||
* @return FieldsContent
|
||||
*/
|
||||
public function addFieldsContent($label, $description = '', $isActive = false, $name = '')
|
||||
{
|
||||
if (empty($name)) {
|
||||
$name = (count($this->rows) + 1);
|
||||
}
|
||||
|
||||
if (count($this->rows) == 0) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
if ($isActive) {
|
||||
$this->actives[$name] = $name;
|
||||
}
|
||||
|
||||
$content = new FieldsContent();
|
||||
|
||||
$this->rows[$name] = ['content' => $content, 'description' => $description, 'active' => ''];
|
||||
$this->labels[$name] = ['content' => $label, 'active' => ''];
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function navigateable($val)
|
||||
{
|
||||
$this->navigateable = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
public function size($left = 2, $width = 8)
|
||||
{
|
||||
$this->size = [$left, $width];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function anchor()
|
||||
{
|
||||
$this->mode = 'anchor';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function dots()
|
||||
{
|
||||
$this->mode = 'dots';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function active($val)
|
||||
{
|
||||
$names = array_keys($this->labels);
|
||||
|
||||
if (in_array($val, $names)) {
|
||||
$this->active = $val;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function stepScript()
|
||||
{
|
||||
$id = $this->getId();
|
||||
$navigateable = $this->navigateable ? 'true' : 'false';
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$id}').bootstrapWizard({
|
||||
'tabClass': 'nav-step',
|
||||
'nextSelector': '[data-wizard="next"]',
|
||||
'previousSelector': '[data-wizard="prev"]',
|
||||
'finishSelector': '[data-wizard="finish"]',
|
||||
'onTabClick': function(e, t, i) {
|
||||
return {$navigateable};
|
||||
},
|
||||
'onTabShow': function(e, t, i) {
|
||||
t.children(":gt(" + i + ").complete").removeClass("complete");
|
||||
t.children(":lt(" + i + "):not(.complete)").addClass("complete");
|
||||
},
|
||||
'onFinish': function(e, t, i) {
|
||||
// 点击完成后处理提交
|
||||
}
|
||||
});
|
||||
|
||||
EOT;
|
||||
Builder::getInstance()->addScript($script);
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return empty($this->class) ? '' : ' ' . $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
$row['content']->beforRender();
|
||||
}
|
||||
|
||||
Builder::getInstance()->addJs('/assets/tpextbuilder/js/jquery.bootstrap.wizard.min.js');
|
||||
|
||||
$this->stepScript();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($partial = false)
|
||||
{
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'form', 'step.html']);
|
||||
|
||||
$names = array_keys($this->labels);
|
||||
|
||||
foreach ($names as $name) {
|
||||
if ($name == $this->active) {
|
||||
$this->labels[$name]['active'] = 'active';
|
||||
$this->rows[$name]['active'] = 'active';
|
||||
|
||||
break;
|
||||
} else {
|
||||
$this->labels[$name]['active'] = 'complete';
|
||||
$this->rows[$name]['active'] = 'complete';
|
||||
}
|
||||
}
|
||||
|
||||
$vars = [
|
||||
'labels' => $this->labels,
|
||||
'rows' => $this->rows,
|
||||
'active' => $this->active,
|
||||
'id' => $this->getId(),
|
||||
'class' => ($this->mode == 'anchor' ? 'step-anchor' : 'step-dots') . ' ' . $this->class,
|
||||
'mode' => $this->mode,
|
||||
'size' => $this->size,
|
||||
];
|
||||
|
||||
$viewshow = new ViewShow($this->view);
|
||||
|
||||
if ($partial) {
|
||||
return $viewshow->assign($vars);
|
||||
}
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Builder;
|
||||
use tpext\builder\common\Module;
|
||||
use tpext\builder\common\Renderable;
|
||||
|
||||
class Step implements Renderable
|
||||
{
|
||||
private $view = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $navigateable = true;
|
||||
|
||||
protected $size = [2, 8];
|
||||
|
||||
protected $rows = [];
|
||||
|
||||
protected $labels = [];
|
||||
|
||||
protected $active = '';
|
||||
|
||||
protected $id = '';
|
||||
|
||||
protected $mode = 'dots';
|
||||
|
||||
public function getId()
|
||||
{
|
||||
if (empty($this->id)) {
|
||||
$this->id = 'step-' . mt_rand(1000, 9999);
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param boolean $isActive
|
||||
* @param string $name
|
||||
* @return FieldsContent
|
||||
*/
|
||||
public function addFieldsContent($label, $description = '', $isActive = false, $name = '')
|
||||
{
|
||||
if (empty($name)) {
|
||||
$name = (count($this->rows) + 1);
|
||||
}
|
||||
|
||||
if (count($this->rows) == 0) {
|
||||
$this->active = $name;
|
||||
}
|
||||
|
||||
if ($isActive) {
|
||||
$this->actives[$name] = $name;
|
||||
}
|
||||
|
||||
$content = new FieldsContent();
|
||||
|
||||
$this->rows[$name] = ['content' => $content, 'description' => $description, 'active' => ''];
|
||||
$this->labels[$name] = ['content' => $label, 'active' => ''];
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function navigateable($val)
|
||||
{
|
||||
$this->navigateable = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return $this
|
||||
*/
|
||||
public function size($left = 2, $width = 8)
|
||||
{
|
||||
$this->size = [$left, $width];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function anchor()
|
||||
{
|
||||
$this->mode = 'anchor';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function dots()
|
||||
{
|
||||
$this->mode = 'dots';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function active($val)
|
||||
{
|
||||
$names = array_keys($this->labels);
|
||||
|
||||
if (in_array($val, $names)) {
|
||||
$this->active = $val;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function stepScript()
|
||||
{
|
||||
$id = $this->getId();
|
||||
$navigateable = $this->navigateable ? 'true' : 'false';
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
$('#{$id}').bootstrapWizard({
|
||||
'tabClass': 'nav-step',
|
||||
'nextSelector': '[data-wizard="next"]',
|
||||
'previousSelector': '[data-wizard="prev"]',
|
||||
'finishSelector': '[data-wizard="finish"]',
|
||||
'onTabClick': function(e, t, i) {
|
||||
return {$navigateable};
|
||||
},
|
||||
'onTabShow': function(e, t, i) {
|
||||
t.children(":gt(" + i + ").complete").removeClass("complete");
|
||||
t.children(":lt(" + i + "):not(.complete)").addClass("complete");
|
||||
},
|
||||
'onFinish': function(e, t, i) {
|
||||
// 点击完成后处理提交
|
||||
}
|
||||
});
|
||||
|
||||
EOT;
|
||||
Builder::getInstance()->addScript($script);
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return empty($this->class) ? '' : ' ' . $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
foreach ($this->rows as $row) {
|
||||
$row['content']->beforRender();
|
||||
}
|
||||
|
||||
Builder::getInstance()->addJs('/assets/tpextbuilder/js/jquery.bootstrap.wizard.min.js');
|
||||
|
||||
$this->stepScript();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($partial = false)
|
||||
{
|
||||
$this->view = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'form', 'step.html']);
|
||||
|
||||
$names = array_keys($this->labels);
|
||||
|
||||
foreach ($names as $name) {
|
||||
if ($name == $this->active) {
|
||||
$this->labels[$name]['active'] = 'active';
|
||||
$this->rows[$name]['active'] = 'active';
|
||||
|
||||
break;
|
||||
} else {
|
||||
$this->labels[$name]['active'] = 'complete';
|
||||
$this->rows[$name]['active'] = 'complete';
|
||||
}
|
||||
}
|
||||
|
||||
$vars = [
|
||||
'labels' => $this->labels,
|
||||
'rows' => $this->rows,
|
||||
'active' => $this->active,
|
||||
'id' => $this->getId(),
|
||||
'class' => ($this->mode == 'anchor' ? 'step-anchor' : 'step-dots') . ' ' . $this->class,
|
||||
'mode' => $this->mode,
|
||||
'size' => $this->size,
|
||||
];
|
||||
|
||||
$viewshow = new ViewShow($this->view);
|
||||
|
||||
if ($partial) {
|
||||
return $viewshow->assign($vars);
|
||||
}
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,131 +1,131 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
/**
|
||||
* Class Wapper.
|
||||
*
|
||||
* @method \tpext\builder\displayer\Field field($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Text text($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Checkbox checkbox($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Radio radio($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Button button($type, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Select select($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MultipleSelect multipleSelect($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Textarea textarea($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Hidden hidden($name)
|
||||
* @method \tpext\builder\displayer\Color color($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\RangeSlider rangeSlider($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\File file($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Image image($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Date date($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Datetime datetime($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Time time($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Year year($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Month month($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\DateRange dateRange($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\DateTimeRange datetimeRange($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\TimeRange timeRange($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Number number($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\SwitchBtn switchBtn($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Rate rate($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Divider divider($text, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Password password($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Decimal decimal($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Html html($html, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Raw raw($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Show show($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Tags tags($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Icon icon($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MultipleImage multipleImage($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MultipleFile multipleFile($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\WangEditor wangEditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Tinymce tinymce($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\UEditor ueditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\WangEditor editor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\CKEditor ckeditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MDEditor mdeditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Match match($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Matches matches($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
*/
|
||||
|
||||
class Wapper
|
||||
{
|
||||
protected $dfaultDisplayerSize = null;
|
||||
|
||||
protected static $displayers = [];
|
||||
|
||||
protected static $displayerMap = [
|
||||
'field' => \tpext\builder\displayer\Field::class,
|
||||
'text' => \tpext\builder\displayer\Text::class,
|
||||
'textarea' => \tpext\builder\displayer\Textarea::class,
|
||||
'html' => \tpext\builder\displayer\Html::class,
|
||||
'divider' => \tpext\builder\displayer\Divider::class,
|
||||
'raw' => \tpext\builder\displayer\Raw::class,
|
||||
'checkbox' => \tpext\builder\displayer\Checkbox::class,
|
||||
'radio' => \tpext\builder\displayer\Radio::class,
|
||||
'button' => \tpext\builder\displayer\Button::class,
|
||||
'select' => \tpext\builder\displayer\Select::class,
|
||||
'multipleSelect' => \tpext\builder\displayer\MultipleSelect::class,
|
||||
'hidden' => \tpext\builder\displayer\Hidden::class,
|
||||
'switchBtn' => \tpext\builder\displayer\SwitchBtn::class,
|
||||
'tags' => \tpext\builder\displayer\Tags::class,
|
||||
'datetime' => \tpext\builder\displayer\DateTime::class,
|
||||
'date' => \tpext\builder\displayer\Date::class,
|
||||
'time' => \tpext\builder\displayer\Time::class,
|
||||
'datetimeRange' => \tpext\builder\displayer\DateTimeRange::class,
|
||||
'dateRange' => \tpext\builder\displayer\DateRange::class,
|
||||
'timeRange' => \tpext\builder\displayer\TimeRange::class,
|
||||
'color' => \tpext\builder\displayer\Color::class,
|
||||
'number' => \tpext\builder\displayer\Number::class,
|
||||
'icon' => \tpext\builder\displayer\Icon::class,
|
||||
'wangEditor' => \tpext\builder\displayer\WangEditor::class,
|
||||
'tinymce' => \tpext\builder\displayer\Tinymce::class,
|
||||
'ueditor' => \tpext\builder\displayer\UEditor::class,
|
||||
'ckeditor' => \tpext\builder\displayer\CKEditor::class,
|
||||
'mdeditor' => \tpext\builder\displayer\MDEditor::class,
|
||||
'editor' => \tpext\builder\displayer\WangEditor::class,
|
||||
'rate' => \tpext\builder\displayer\Rate::class,
|
||||
'month' => \tpext\builder\displayer\Month::class,
|
||||
'year' => \tpext\builder\displayer\Year::class,
|
||||
'multipleFile' => \tpext\builder\displayer\MultipleFile::class,
|
||||
'file' => \tpext\builder\displayer\File::class,
|
||||
'multipleImage' => \tpext\builder\displayer\MultipleImage::class,
|
||||
'image' => \tpext\builder\displayer\Image::class,
|
||||
'rangeSlider' => \tpext\builder\displayer\RangeSlider::class,
|
||||
'match' => \tpext\builder\displayer\Match::class,
|
||||
'matches' => \tpext\builder\displayer\Matches::class,
|
||||
'show' => \tpext\builder\displayer\Show::class,
|
||||
'password' => \tpext\builder\displayer\Password::class,
|
||||
];
|
||||
|
||||
protected static $defaultFieldClass = [];
|
||||
|
||||
public static function isDisplayer($name)
|
||||
{
|
||||
if (empty(static::$displayers)) {
|
||||
static::$displayers = array_keys(static::$displayerMap);
|
||||
}
|
||||
|
||||
return in_array($name, static::$displayers);
|
||||
}
|
||||
|
||||
public static function hasDefaultFieldClass($type)
|
||||
{
|
||||
if (isset(static::$defaultFieldClass[$type])) {
|
||||
return static::$defaultFieldClass[$type];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function extend($pair)
|
||||
{
|
||||
static::$displayerMap = array_merge(static::$displayerMap, $pair);
|
||||
}
|
||||
|
||||
public static function setdefaultFieldClass($pair)
|
||||
{
|
||||
static::$defaultFieldClass = array_merge(static::$defaultFieldClass, $pair);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\form;
|
||||
|
||||
/**
|
||||
* Class Wapper.
|
||||
*
|
||||
* @method \tpext\builder\displayer\Field field($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Text text($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Checkbox checkbox($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Radio radio($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Button button($type, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Select select($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MultipleSelect multipleSelect($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Textarea textarea($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Hidden hidden($name)
|
||||
* @method \tpext\builder\displayer\Color color($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\RangeSlider rangeSlider($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\File file($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Image image($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Date date($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Datetime datetime($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Time time($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Year year($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Month month($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\DateRange dateRange($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\DateTimeRange datetimeRange($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\TimeRange timeRange($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Number number($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\SwitchBtn switchBtn($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Rate rate($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Divider divider($text, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Password password($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Decimal decimal($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Html html($html, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Raw raw($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Show show($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Tags tags($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Icon icon($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MultipleImage multipleImage($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MultipleFile multipleFile($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\WangEditor wangEditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Tinymce tinymce($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\UEditor ueditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\WangEditor editor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\CKEditor ckeditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MDEditor mdeditor($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Match match($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Matches matches($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
*/
|
||||
|
||||
class Wapper
|
||||
{
|
||||
protected $dfaultDisplayerSize = null;
|
||||
|
||||
protected static $displayers = [];
|
||||
|
||||
protected static $displayerMap = [
|
||||
'field' => \tpext\builder\displayer\Field::class,
|
||||
'text' => \tpext\builder\displayer\Text::class,
|
||||
'textarea' => \tpext\builder\displayer\Textarea::class,
|
||||
'html' => \tpext\builder\displayer\Html::class,
|
||||
'divider' => \tpext\builder\displayer\Divider::class,
|
||||
'raw' => \tpext\builder\displayer\Raw::class,
|
||||
'checkbox' => \tpext\builder\displayer\Checkbox::class,
|
||||
'radio' => \tpext\builder\displayer\Radio::class,
|
||||
'button' => \tpext\builder\displayer\Button::class,
|
||||
'select' => \tpext\builder\displayer\Select::class,
|
||||
'multipleSelect' => \tpext\builder\displayer\MultipleSelect::class,
|
||||
'hidden' => \tpext\builder\displayer\Hidden::class,
|
||||
'switchBtn' => \tpext\builder\displayer\SwitchBtn::class,
|
||||
'tags' => \tpext\builder\displayer\Tags::class,
|
||||
'datetime' => \tpext\builder\displayer\DateTime::class,
|
||||
'date' => \tpext\builder\displayer\Date::class,
|
||||
'time' => \tpext\builder\displayer\Time::class,
|
||||
'datetimeRange' => \tpext\builder\displayer\DateTimeRange::class,
|
||||
'dateRange' => \tpext\builder\displayer\DateRange::class,
|
||||
'timeRange' => \tpext\builder\displayer\TimeRange::class,
|
||||
'color' => \tpext\builder\displayer\Color::class,
|
||||
'number' => \tpext\builder\displayer\Number::class,
|
||||
'icon' => \tpext\builder\displayer\Icon::class,
|
||||
'wangEditor' => \tpext\builder\displayer\WangEditor::class,
|
||||
'tinymce' => \tpext\builder\displayer\Tinymce::class,
|
||||
'ueditor' => \tpext\builder\displayer\UEditor::class,
|
||||
'ckeditor' => \tpext\builder\displayer\CKEditor::class,
|
||||
'mdeditor' => \tpext\builder\displayer\MDEditor::class,
|
||||
'editor' => \tpext\builder\displayer\WangEditor::class,
|
||||
'rate' => \tpext\builder\displayer\Rate::class,
|
||||
'month' => \tpext\builder\displayer\Month::class,
|
||||
'year' => \tpext\builder\displayer\Year::class,
|
||||
'multipleFile' => \tpext\builder\displayer\MultipleFile::class,
|
||||
'file' => \tpext\builder\displayer\File::class,
|
||||
'multipleImage' => \tpext\builder\displayer\MultipleImage::class,
|
||||
'image' => \tpext\builder\displayer\Image::class,
|
||||
'rangeSlider' => \tpext\builder\displayer\RangeSlider::class,
|
||||
'match' => \tpext\builder\displayer\Match::class,
|
||||
'matches' => \tpext\builder\displayer\Matches::class,
|
||||
'show' => \tpext\builder\displayer\Show::class,
|
||||
'password' => \tpext\builder\displayer\Password::class,
|
||||
];
|
||||
|
||||
protected static $defaultFieldClass = [];
|
||||
|
||||
public static function isDisplayer($name)
|
||||
{
|
||||
if (empty(static::$displayers)) {
|
||||
static::$displayers = array_keys(static::$displayerMap);
|
||||
}
|
||||
|
||||
return in_array($name, static::$displayers);
|
||||
}
|
||||
|
||||
public static function hasDefaultFieldClass($type)
|
||||
{
|
||||
if (isset(static::$defaultFieldClass[$type])) {
|
||||
return static::$defaultFieldClass[$type];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function extend($pair)
|
||||
{
|
||||
static::$displayerMap = array_merge(static::$displayerMap, $pair);
|
||||
}
|
||||
|
||||
public static function setdefaultFieldClass($pair)
|
||||
{
|
||||
static::$defaultFieldClass = array_merge(static::$defaultFieldClass, $pair);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
use tpext\common\ExtLoader;
|
||||
|
||||
$classMap = [
|
||||
'tpext\\builder\\common\\Module',
|
||||
'tpext\\builder\\common\\Plugin',
|
||||
];
|
||||
|
||||
ExtLoader::addClassMap($classMap);
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
use tpext\common\ExtLoader;
|
||||
|
||||
$classMap = [
|
||||
'tpext\\builder\\common\\Module',
|
||||
'tpext\\builder\\common\\Plugin',
|
||||
];
|
||||
|
||||
ExtLoader::addClassMap($classMap);
|
||||
|
|
|
@ -1,288 +1,288 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use tpext\builder\common\Toolbar;
|
||||
|
||||
class Actionbar extends Toolbar
|
||||
{
|
||||
protected $pk;
|
||||
|
||||
protected $tableRowKey = '';
|
||||
|
||||
protected $rowid;
|
||||
|
||||
protected $rowdata;
|
||||
|
||||
protected $script = [];
|
||||
|
||||
protected $useLayer = true;
|
||||
|
||||
protected $mapClass = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function useLayer($val)
|
||||
{
|
||||
$this->useLayer = $val;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function tableRowKey($val)
|
||||
{
|
||||
$this->tableRowKey = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
if (empty($this->elms)) {
|
||||
$this->buttons();
|
||||
}
|
||||
|
||||
foreach ($this->elms as $elm) {
|
||||
|
||||
if ($this->tableRowKey) {
|
||||
$elm->tableRowKey($this->tableRowKey);
|
||||
}
|
||||
|
||||
if ($this->rowid) {
|
||||
$elm->dataid($this->rowid);
|
||||
}
|
||||
|
||||
if ($this->rowdata) {
|
||||
$elm->parse($this->rowdata);
|
||||
}
|
||||
|
||||
if ($this->mapClass) {
|
||||
$elm->mapClass($this->mapClass);
|
||||
}
|
||||
|
||||
$elm->useLayer($this->useLayer);
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function pk($val)
|
||||
{
|
||||
$this->pk = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function rowdata($data)
|
||||
{
|
||||
if (isset($data[$this->pk])) {
|
||||
$this->rowid = $data[$this->pk];
|
||||
}
|
||||
|
||||
$this->rowdata = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function mapClass($data)
|
||||
{
|
||||
$this->mapClass = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function buttons()
|
||||
{
|
||||
$this->btnEdit();
|
||||
$this->btnDelete();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnEdit($url = '', $label = '', $class = 'btn-primary', $icon = 'mdi-lead-pencil', $attr = 'title="编辑"')
|
||||
{
|
||||
if (empty($url)) {
|
||||
$url = url('edit', ['id' => '__data.pk__']);
|
||||
}
|
||||
$this->actionBtn('edit', $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnView($url = '', $label = '', $class = 'btn-primary', $icon = 'mdi-lead-pencil', $attr = 'title="编辑"')
|
||||
{
|
||||
if (empty($url)) {
|
||||
$url = url('view', ['id' => '__data.pk__']);
|
||||
}
|
||||
$this->actionBtn('edit', $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDelete($postUrl = '', $label = '', $class = 'btn-danger', $icon = 'mdi-delete', $confirm = true, $attr = 'title="删除"')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('delete');
|
||||
}
|
||||
$this->actionBtn('delete', $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDisable($postUrl = '', $label = '', $class = 'btn-warning', $icon = 'mdi-block-helper', $confirm = true, $attr = 'title="禁用"')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('disable');
|
||||
}
|
||||
$this->actionBtn('disable', $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnEnable($postUrl = '', $label = '', $class = 'btn-success', $icon = 'mdi-check', $confirm = true, $attr = 'title="启用"')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('enable');
|
||||
}
|
||||
$this->actionBtn('enable', $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnLink($name = '', $url, $label = '', $class = 'btn-secondary', $icon = '', $attr = '')
|
||||
{
|
||||
if (!$name) {
|
||||
$name = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $url, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$name = mt_rand(10, 99);
|
||||
}
|
||||
}
|
||||
|
||||
$this->actionBtn($name, $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function btnPostRowid($name = '', $postUrl, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '', $confirm = true)
|
||||
{
|
||||
if (!$name) {
|
||||
$name = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $postUrl, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$name = mt_rand(10, 99);
|
||||
}
|
||||
}
|
||||
|
||||
$this->actionBtn($name, $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use tpext\builder\common\Toolbar;
|
||||
|
||||
class Actionbar extends Toolbar
|
||||
{
|
||||
protected $pk;
|
||||
|
||||
protected $tableRowKey = '';
|
||||
|
||||
protected $rowid;
|
||||
|
||||
protected $rowdata;
|
||||
|
||||
protected $script = [];
|
||||
|
||||
protected $useLayer = true;
|
||||
|
||||
protected $mapClass = [];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function useLayer($val)
|
||||
{
|
||||
$this->useLayer = $val;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function tableRowKey($val)
|
||||
{
|
||||
$this->tableRowKey = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
if (empty($this->elms)) {
|
||||
$this->buttons();
|
||||
}
|
||||
|
||||
foreach ($this->elms as $elm) {
|
||||
|
||||
if ($this->tableRowKey) {
|
||||
$elm->tableRowKey($this->tableRowKey);
|
||||
}
|
||||
|
||||
if ($this->rowid) {
|
||||
$elm->dataid($this->rowid);
|
||||
}
|
||||
|
||||
if ($this->rowdata) {
|
||||
$elm->parse($this->rowdata);
|
||||
}
|
||||
|
||||
if ($this->mapClass) {
|
||||
$elm->mapClass($this->mapClass);
|
||||
}
|
||||
|
||||
$elm->useLayer($this->useLayer);
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function pk($val)
|
||||
{
|
||||
$this->pk = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function rowdata($data)
|
||||
{
|
||||
if (isset($data[$this->pk])) {
|
||||
$this->rowid = $data[$this->pk];
|
||||
}
|
||||
|
||||
$this->rowdata = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function mapClass($data)
|
||||
{
|
||||
$this->mapClass = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function buttons()
|
||||
{
|
||||
$this->btnEdit();
|
||||
$this->btnDelete();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnEdit($url = '', $label = '', $class = 'btn-primary', $icon = 'mdi-lead-pencil', $attr = 'title="编辑"')
|
||||
{
|
||||
if (empty($url)) {
|
||||
$url = url('edit', ['id' => '__data.pk__']);
|
||||
}
|
||||
$this->actionBtn('edit', $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnView($url = '', $label = '', $class = 'btn-primary', $icon = 'mdi-lead-pencil', $attr = 'title="编辑"')
|
||||
{
|
||||
if (empty($url)) {
|
||||
$url = url('view', ['id' => '__data.pk__']);
|
||||
}
|
||||
$this->actionBtn('edit', $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDelete($postUrl = '', $label = '', $class = 'btn-danger', $icon = 'mdi-delete', $confirm = true, $attr = 'title="删除"')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('delete');
|
||||
}
|
||||
$this->actionBtn('delete', $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDisable($postUrl = '', $label = '', $class = 'btn-warning', $icon = 'mdi-block-helper', $confirm = true, $attr = 'title="禁用"')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('disable');
|
||||
}
|
||||
$this->actionBtn('disable', $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnEnable($postUrl = '', $label = '', $class = 'btn-success', $icon = 'mdi-check', $confirm = true, $attr = 'title="启用"')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('enable');
|
||||
}
|
||||
$this->actionBtn('enable', $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnLink($name = '', $url, $label = '', $class = 'btn-secondary', $icon = '', $attr = '')
|
||||
{
|
||||
if (!$name) {
|
||||
$name = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $url, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$name = mt_rand(10, 99);
|
||||
}
|
||||
}
|
||||
|
||||
$this->actionBtn($name, $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function btnPostRowid($name = '', $postUrl, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '', $confirm = true)
|
||||
{
|
||||
if (!$name) {
|
||||
$name = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $postUrl, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$name = mt_rand(10, 99);
|
||||
}
|
||||
}
|
||||
|
||||
$this->actionBtn($name, $label)->postRowid($postUrl, $confirm)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use tpext\builder\form\Row;
|
||||
|
||||
class Column extends Row
|
||||
{
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use tpext\builder\form\Row;
|
||||
|
||||
class Column extends Row
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,279 +1,279 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use tpext\builder\common\Toolbar;
|
||||
|
||||
class MultipleToolbar extends Toolbar
|
||||
{
|
||||
protected $useLayer = true;
|
||||
|
||||
protected $hasSearch = false;
|
||||
|
||||
protected $btnSearch = null;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function useLayer($val)
|
||||
{
|
||||
$this->useLayer = $val;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function hasSearch($val)
|
||||
{
|
||||
$this->hasSearch = $val;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
if (empty($this->elms)) {
|
||||
$this->buttons();
|
||||
}
|
||||
|
||||
if ($this->hasSearch && !$this->btnSearch) {
|
||||
$this->btnToggleSearch();
|
||||
}
|
||||
|
||||
foreach ($this->elms as $elm) {
|
||||
|
||||
if (!$this->useLayer) {
|
||||
$elm->useLayer(false);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function buttons()
|
||||
{
|
||||
$this->btnAdd();
|
||||
$this->btnDelete();
|
||||
$this->btnRefresh();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnAdd($url = '', $label = '添加', $class = 'btn-primary', $icon = 'mdi-plus', $attr = '')
|
||||
{
|
||||
if (empty($url)) {
|
||||
$url = url('add');
|
||||
}
|
||||
$this->linkBtn('add', $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDelete($postUrl = '', $label = '删除', $class = 'btn-danger', $icon = 'mdi-delete', $confirm = true, $attr = '')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('delete');
|
||||
}
|
||||
$this->linkBtn('delete', $label)->postChecked($postUrl, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDisable($postUrl = '', $label = '禁用', $class = 'btn-warning', $icon = 'mdi-block-helper', $confirm = true, $attr = '')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('disable');
|
||||
}
|
||||
$this->linkBtn('disable', $label)->postChecked($postUrl, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnEnable($postUrl = '', $label = '启用', $class = 'btn-success', $icon = 'mdi-check', $confirm = true, $attr = '')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('enable');
|
||||
}
|
||||
$this->linkBtn('enable', $label)->postChecked($postUrl, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnRefresh($label = '', $class = 'btn-cyan', $icon = 'mdi-refresh', $attr = 'title="刷新"')
|
||||
{
|
||||
$this->linkBtn('refresh', $label)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnToggleSearch($label = '', $class = 'btn-secondary', $icon = 'mdi-magnify', $attr = 'title="搜索"')
|
||||
{
|
||||
$this->linkBtn('search', $label)->class($class)->icon($icon)->attr($attr);
|
||||
|
||||
$this->btnSearch = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $afterSuccessUrl
|
||||
* @param string|array acceptedExts
|
||||
* @param int fileSize MB
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnImport($afterSuccessUrl, $acceptedExts = "rar,zip,doc,docx,xls,xlsx,ppt,pptx,pdf", $fileSize = '20', $label = '导入', $class = 'btn-pink', $icon = 'mdi-cloud-upload', $attr = 'title="上传文件"')
|
||||
{
|
||||
if (empty($afterSuccessUrl)) {
|
||||
$afterSuccessUrl = url('/tpextbuilder/admin/import/afterSuccess');
|
||||
}
|
||||
|
||||
if (is_array($acceptedExts)) {
|
||||
$acceptedExts = implode(',', $acceptedExts);
|
||||
}
|
||||
|
||||
$afterSuccessUrl = urlencode($afterSuccessUrl);
|
||||
|
||||
$afterSuccessUrl = preg_replace('/(.+?)(\.html)?$/', '$1', $afterSuccessUrl);
|
||||
|
||||
$importpagetoken = session('importpagetoken') ? session('importpagetoken') : md5('importpagetoken' . time() . uniqid());
|
||||
|
||||
session('importpagetoken', $importpagetoken);
|
||||
|
||||
$pagetoken = md5($importpagetoken . $acceptedExts . $fileSize);
|
||||
|
||||
$url = url('/tpextbuilder/admin/import/index') . '?successUrl=' . $afterSuccessUrl . '&acceptedExts=' . $acceptedExts . '&fileSize=' . $fileSize . '&pageToken=' . $pagetoken;
|
||||
|
||||
$this->linkBtn('import', $label)->useLayer(true, ['220px', '300px'])->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnLink($url, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '')
|
||||
{
|
||||
$action = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $url, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$action = mt_rand(10, 99);
|
||||
}
|
||||
|
||||
$this->linkBtn($action, $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function btnPostChecked($url, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '', $confirm = true)
|
||||
{
|
||||
$action = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $url, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$action = mt_rand(10, 99);
|
||||
}
|
||||
|
||||
$this->linkBtn($action, $label)->postChecked($url, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use tpext\builder\common\Toolbar;
|
||||
|
||||
class MultipleToolbar extends Toolbar
|
||||
{
|
||||
protected $useLayer = true;
|
||||
|
||||
protected $hasSearch = false;
|
||||
|
||||
protected $btnSearch = null;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function useLayer($val)
|
||||
{
|
||||
$this->useLayer = $val;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function hasSearch($val)
|
||||
{
|
||||
$this->hasSearch = $val;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforRender()
|
||||
{
|
||||
if (empty($this->elms)) {
|
||||
$this->buttons();
|
||||
}
|
||||
|
||||
if ($this->hasSearch && !$this->btnSearch) {
|
||||
$this->btnToggleSearch();
|
||||
}
|
||||
|
||||
foreach ($this->elms as $elm) {
|
||||
|
||||
if (!$this->useLayer) {
|
||||
$elm->useLayer(false);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function buttons()
|
||||
{
|
||||
$this->btnAdd();
|
||||
$this->btnDelete();
|
||||
$this->btnRefresh();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnAdd($url = '', $label = '添加', $class = 'btn-primary', $icon = 'mdi-plus', $attr = '')
|
||||
{
|
||||
if (empty($url)) {
|
||||
$url = url('add');
|
||||
}
|
||||
$this->linkBtn('add', $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDelete($postUrl = '', $label = '删除', $class = 'btn-danger', $icon = 'mdi-delete', $confirm = true, $attr = '')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('delete');
|
||||
}
|
||||
$this->linkBtn('delete', $label)->postChecked($postUrl, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnDisable($postUrl = '', $label = '禁用', $class = 'btn-warning', $icon = 'mdi-block-helper', $confirm = true, $attr = '')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('disable');
|
||||
}
|
||||
$this->linkBtn('disable', $label)->postChecked($postUrl, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $postUrl
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnEnable($postUrl = '', $label = '启用', $class = 'btn-success', $icon = 'mdi-check', $confirm = true, $attr = '')
|
||||
{
|
||||
if (empty($postUrl)) {
|
||||
$postUrl = url('enable');
|
||||
}
|
||||
$this->linkBtn('enable', $label)->postChecked($postUrl, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnRefresh($label = '', $class = 'btn-cyan', $icon = 'mdi-refresh', $attr = 'title="刷新"')
|
||||
{
|
||||
$this->linkBtn('refresh', $label)->class($class)->icon($icon)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param boolean $confirm
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnToggleSearch($label = '', $class = 'btn-secondary', $icon = 'mdi-magnify', $attr = 'title="搜索"')
|
||||
{
|
||||
$this->linkBtn('search', $label)->class($class)->icon($icon)->attr($attr);
|
||||
|
||||
$this->btnSearch = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $afterSuccessUrl
|
||||
* @param string|array acceptedExts
|
||||
* @param int fileSize MB
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnImport($afterSuccessUrl, $acceptedExts = "rar,zip,doc,docx,xls,xlsx,ppt,pptx,pdf", $fileSize = '20', $label = '导入', $class = 'btn-pink', $icon = 'mdi-cloud-upload', $attr = 'title="上传文件"')
|
||||
{
|
||||
if (empty($afterSuccessUrl)) {
|
||||
$afterSuccessUrl = url('/tpextbuilder/admin/import/afterSuccess');
|
||||
}
|
||||
|
||||
if (is_array($acceptedExts)) {
|
||||
$acceptedExts = implode(',', $acceptedExts);
|
||||
}
|
||||
|
||||
$afterSuccessUrl = urlencode($afterSuccessUrl);
|
||||
|
||||
$afterSuccessUrl = preg_replace('/(.+?)(\.html)?$/', '$1', $afterSuccessUrl);
|
||||
|
||||
$importpagetoken = session('importpagetoken') ? session('importpagetoken') : md5('importpagetoken' . time() . uniqid());
|
||||
|
||||
session('importpagetoken', $importpagetoken);
|
||||
|
||||
$pagetoken = md5($importpagetoken . $acceptedExts . $fileSize);
|
||||
|
||||
$url = url('/tpextbuilder/admin/import/index') . '?successUrl=' . $afterSuccessUrl . '&acceptedExts=' . $acceptedExts . '&fileSize=' . $fileSize . '&pageToken=' . $pagetoken;
|
||||
|
||||
$this->linkBtn('import', $label)->useLayer(true, ['220px', '300px'])->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @return $this
|
||||
*/
|
||||
public function btnLink($url, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '')
|
||||
{
|
||||
$action = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $url, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$action = mt_rand(10, 99);
|
||||
}
|
||||
|
||||
$this->linkBtn($action, $label)->href($url)->icon($icon)->class($class)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param string $icon
|
||||
* @param string $attr
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function btnPostChecked($url, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '', $confirm = true)
|
||||
{
|
||||
$action = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $url, -1, $count);
|
||||
|
||||
if (!$count) {
|
||||
$action = mt_rand(10, 99);
|
||||
}
|
||||
|
||||
$this->linkBtn($action, $label)->postChecked($url, $confirm)->class($class)->icon($icon)->attr($attr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,147 +1,147 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use think\Collection;
|
||||
use think\paginator\driver\Bootstrap;
|
||||
|
||||
class Paginator extends Bootstrap
|
||||
{
|
||||
protected $paginatorClass = 'pagination-sm';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $class = 'text-center';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttr()
|
||||
{
|
||||
return $this->attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return void
|
||||
*/
|
||||
public function options($val)
|
||||
{
|
||||
$this->options = array_merge($this->options, $val);
|
||||
$this->reset();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->lastPage = (int) ceil($this->total / $this->listRows);
|
||||
$this->currentPage = $this->setCurrentPage($this->currentPage);
|
||||
$this->hasMore = $this->currentPage < $this->lastPage;
|
||||
}
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems($items)
|
||||
{
|
||||
if (!$items instanceof Collection) {
|
||||
$items = Collection::make($items);
|
||||
}
|
||||
|
||||
$this->items = $items;
|
||||
$this->reset();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function setTotal($val)
|
||||
{
|
||||
$this->total = $val;
|
||||
$this->reset();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (!$this->total) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = parent::render();
|
||||
|
||||
if ($this->paginatorClass) {
|
||||
$html = preg_replace('/(.+)(pagination)(.+)/i', '$1$2 ' . $this->paginatorClass . '$3', $html);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\table;
|
||||
|
||||
use think\Collection;
|
||||
use think\paginator\driver\Bootstrap;
|
||||
|
||||
class Paginator extends Bootstrap
|
||||
{
|
||||
protected $paginatorClass = 'pagination-sm';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $class = 'text-center';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttr()
|
||||
{
|
||||
return $this->attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $val
|
||||
* @return void
|
||||
*/
|
||||
public function options($val)
|
||||
{
|
||||
$this->options = array_merge($this->options, $val);
|
||||
$this->reset();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->lastPage = (int) ceil($this->total / $this->listRows);
|
||||
$this->currentPage = $this->setCurrentPage($this->currentPage);
|
||||
$this->hasMore = $this->currentPage < $this->lastPage;
|
||||
}
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems($items)
|
||||
{
|
||||
if (!$items instanceof Collection) {
|
||||
$items = Collection::make($items);
|
||||
}
|
||||
|
||||
$this->items = $items;
|
||||
$this->reset();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $val
|
||||
* @return $this
|
||||
*/
|
||||
public function setTotal($val)
|
||||
{
|
||||
$this->total = $val;
|
||||
$this->reset();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (!$this->total) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = parent::render();
|
||||
|
||||
if ($this->paginatorClass) {
|
||||
$html = preg_replace('/(.+)(pagination)(.+)/i', '$1$2 ' . $this->paginatorClass . '$3', $html);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,151 +1,151 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
class ActionBtn extends Bar
|
||||
{
|
||||
protected $view = 'actionbtn';
|
||||
|
||||
protected $mapClass = [];
|
||||
|
||||
protected $postRowid = '';
|
||||
|
||||
protected $extClass = '';
|
||||
|
||||
protected $data = [];
|
||||
|
||||
protected $dataid = 0;
|
||||
|
||||
protected $confirm = true;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function parse($data)
|
||||
{
|
||||
$this->__href__ = preg_replace('/__data\.pk__/', $this->dataid, $this->href);
|
||||
|
||||
if (empty($data)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->data = $data;
|
||||
|
||||
$ma = preg_match_all('/__data\.(\w+)__/', $this->__href__, $matches);
|
||||
|
||||
if ($ma) {
|
||||
foreach ($matches as $match) {
|
||||
if (count($match) > 0) {
|
||||
$key = $match[0];
|
||||
}
|
||||
|
||||
if (isset($data[$key])) {
|
||||
$this->__href__ = preg_replace('/__data\.' . $key . '__/', $data[$key], $this->__href__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function parseMapClass($data)
|
||||
{
|
||||
$this->extClass = '';
|
||||
foreach ($this->mapClass as $class => $check) {
|
||||
if (isset($data[$check]) && $data[$check]) {
|
||||
$this->extClass .= ' ' . $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $mapData
|
||||
* @return $this
|
||||
*/
|
||||
public function mapClass($mapData)
|
||||
{
|
||||
if (!empty($mapData) && isset($mapData[$this->name])) {
|
||||
$this->mapClass = $mapData[$this->name];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function dataid($val)
|
||||
{
|
||||
$this->dataid = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*/
|
||||
public function postRowid($url, $confirm = true)
|
||||
{
|
||||
$this->postRowid = $url;
|
||||
$this->confirm = $confirm;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function postRowidScript()
|
||||
{
|
||||
$script = '';
|
||||
$class = 'action-' . $this->name;
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
tpextbuilder.postRowid('{$class}', '{$this->postRowid}', {$this->confirm});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if ($this->postRowid) {
|
||||
|
||||
$this->postRowidScript();
|
||||
}
|
||||
|
||||
$this->parseMapClass($this->data);
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'class' => $vars['class'] . $this->extClass,
|
||||
'dataid' => $this->dataid,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
class ActionBtn extends Bar
|
||||
{
|
||||
protected $view = 'actionbtn';
|
||||
|
||||
protected $mapClass = [];
|
||||
|
||||
protected $postRowid = '';
|
||||
|
||||
protected $extClass = '';
|
||||
|
||||
protected $data = [];
|
||||
|
||||
protected $dataid = 0;
|
||||
|
||||
protected $confirm = true;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function parse($data)
|
||||
{
|
||||
$this->__href__ = preg_replace('/__data\.pk__/', $this->dataid, $this->href);
|
||||
|
||||
if (empty($data)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->data = $data;
|
||||
|
||||
$ma = preg_match_all('/__data\.(\w+)__/', $this->__href__, $matches);
|
||||
|
||||
if ($ma) {
|
||||
foreach ($matches as $match) {
|
||||
if (count($match) > 0) {
|
||||
$key = $match[0];
|
||||
}
|
||||
|
||||
if (isset($data[$key])) {
|
||||
$this->__href__ = preg_replace('/__data\.' . $key . '__/', $data[$key], $this->__href__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function parseMapClass($data)
|
||||
{
|
||||
$this->extClass = '';
|
||||
foreach ($this->mapClass as $class => $check) {
|
||||
if (isset($data[$check]) && $data[$check]) {
|
||||
$this->extClass .= ' ' . $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $mapData
|
||||
* @return $this
|
||||
*/
|
||||
public function mapClass($mapData)
|
||||
{
|
||||
if (!empty($mapData) && isset($mapData[$this->name])) {
|
||||
$this->mapClass = $mapData[$this->name];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function dataid($val)
|
||||
{
|
||||
$this->dataid = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*/
|
||||
public function postRowid($url, $confirm = true)
|
||||
{
|
||||
$this->postRowid = $url;
|
||||
$this->confirm = $confirm;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function postRowidScript()
|
||||
{
|
||||
$script = '';
|
||||
$class = 'action-' . $this->name;
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
tpextbuilder.postRowid('{$class}', '{$this->postRowid}', {$this->confirm});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if ($this->postRowid) {
|
||||
|
||||
$this->postRowidScript();
|
||||
}
|
||||
|
||||
$this->parseMapClass($this->data);
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'class' => $vars['class'] . $this->extClass,
|
||||
'dataid' => $this->dataid,
|
||||
]);
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,274 +1,274 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Builder;
|
||||
use tpext\builder\common\Module;
|
||||
use tpext\builder\common\Renderable;
|
||||
|
||||
class Bar implements Renderable
|
||||
{
|
||||
protected $view = '';
|
||||
|
||||
protected $tableRowKey = '';
|
||||
|
||||
protected $class = 'btn-default';
|
||||
|
||||
protected $name = '';
|
||||
|
||||
protected $icon = '';
|
||||
|
||||
protected $href = 'javascript:;';
|
||||
|
||||
protected $__href__ = '';
|
||||
|
||||
protected $label = '';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $script = [];
|
||||
|
||||
protected $useLayer = true;
|
||||
|
||||
protected $layerSize = ['90%', '90%'];
|
||||
|
||||
public function __construct($name, $label = '')
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
public function created()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return 'bar-' . $this->name . $this->tableRowKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function label($val)
|
||||
{
|
||||
$this->label = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function style($val)
|
||||
{
|
||||
$this->style = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function icon($val)
|
||||
{
|
||||
$this->icon = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function href($val)
|
||||
{
|
||||
$this->href = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @param array $size
|
||||
* @return $this
|
||||
*/
|
||||
public function useLayer($val, $size = ['90%', '90%'])
|
||||
{
|
||||
$this->useLayer = $val;
|
||||
$this->layerSize = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addStyle($val)
|
||||
{
|
||||
$this->attr .= $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function tableRowKey($val)
|
||||
{
|
||||
$this->tableRowKey = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getScript()
|
||||
{
|
||||
return $this->script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if (!empty($this->js)) {
|
||||
Builder::getInstance()->addJs($this->js);
|
||||
}
|
||||
|
||||
if (!empty($this->css)) {
|
||||
Builder::getInstance()->addCss($this->css);
|
||||
}
|
||||
|
||||
if (!empty($this->script)) {
|
||||
Builder::getInstance()->addScript($this->script);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return '<!--empty bar-->';
|
||||
}
|
||||
|
||||
protected function getViewInstance()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'toolbar', $this->view . '.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
return $viewshow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function commonVars()
|
||||
{
|
||||
|
||||
$this->useLayer = $this->useLayer && !empty($this->href) && !preg_match('/javascript:.*/i', $this->href) && !preg_match('/^#.*/i', $this->href);
|
||||
|
||||
$vars = [
|
||||
'id' => $this->getId(),
|
||||
'label' => $this->label,
|
||||
'name' => $this->getName(),
|
||||
'class' => ' ' . $this->class,
|
||||
'href' => empty($this->__href__) ? $this->href : $this->__href__,
|
||||
'icon' => $this->icon,
|
||||
'attr' => $this->attr . (empty($this->style) ? '' : ' style="' . $this->style . '"'),
|
||||
'useLayer' => $this->useLayer,
|
||||
'layerSize' => implode(',', $this->layerSize),
|
||||
];
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Builder;
|
||||
use tpext\builder\common\Module;
|
||||
use tpext\builder\common\Renderable;
|
||||
|
||||
class Bar implements Renderable
|
||||
{
|
||||
protected $view = '';
|
||||
|
||||
protected $tableRowKey = '';
|
||||
|
||||
protected $class = 'btn-default';
|
||||
|
||||
protected $name = '';
|
||||
|
||||
protected $icon = '';
|
||||
|
||||
protected $href = 'javascript:;';
|
||||
|
||||
protected $__href__ = '';
|
||||
|
||||
protected $label = '';
|
||||
|
||||
protected $attr = '';
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $script = [];
|
||||
|
||||
protected $useLayer = true;
|
||||
|
||||
protected $layerSize = ['90%', '90%'];
|
||||
|
||||
public function __construct($name, $label = '')
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
public function created()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return 'bar-' . $this->name . $this->tableRowKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function label($val)
|
||||
{
|
||||
$this->label = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function style($val)
|
||||
{
|
||||
$this->style = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
function class ($val)
|
||||
{
|
||||
$this->class = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function icon($val)
|
||||
{
|
||||
$this->icon = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function href($val)
|
||||
{
|
||||
$this->href = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function attr($val)
|
||||
{
|
||||
$this->attr = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @param array $size
|
||||
* @return $this
|
||||
*/
|
||||
public function useLayer($val, $size = ['90%', '90%'])
|
||||
{
|
||||
$this->useLayer = $val;
|
||||
$this->layerSize = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addClass($val)
|
||||
{
|
||||
$this->class .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttr($val)
|
||||
{
|
||||
$this->attr .= ' ' . $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function addStyle($val)
|
||||
{
|
||||
$this->attr .= $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function tableRowKey($val)
|
||||
{
|
||||
$this->tableRowKey = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getScript()
|
||||
{
|
||||
return $this->script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if (!empty($this->js)) {
|
||||
Builder::getInstance()->addJs($this->js);
|
||||
}
|
||||
|
||||
if (!empty($this->css)) {
|
||||
Builder::getInstance()->addCss($this->css);
|
||||
}
|
||||
|
||||
if (!empty($this->script)) {
|
||||
Builder::getInstance()->addScript($this->script);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return '<!--empty bar-->';
|
||||
}
|
||||
|
||||
protected function getViewInstance()
|
||||
{
|
||||
$template = Module::getInstance()->getRoot() . implode(DIRECTORY_SEPARATOR, ['src', 'view', 'toolbar', $this->view . '.html']);
|
||||
|
||||
$viewshow = new ViewShow($template);
|
||||
|
||||
return $viewshow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function commonVars()
|
||||
{
|
||||
|
||||
$this->useLayer = $this->useLayer && !empty($this->href) && !preg_match('/javascript:.*/i', $this->href) && !preg_match('/^#.*/i', $this->href);
|
||||
|
||||
$vars = [
|
||||
'id' => $this->getId(),
|
||||
'label' => $this->label,
|
||||
'name' => $this->getName(),
|
||||
'class' => ' ' . $this->class,
|
||||
'href' => empty($this->__href__) ? $this->href : $this->__href__,
|
||||
'icon' => $this->icon,
|
||||
'attr' => $this->attr . (empty($this->style) ? '' : ' style="' . $this->style . '"'),
|
||||
'useLayer' => $this->useLayer,
|
||||
'layerSize' => implode(',', $this->layerSize),
|
||||
];
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
class Html extends Bar
|
||||
{
|
||||
protected $view = 'html';
|
||||
|
||||
public function __construct($html)
|
||||
{
|
||||
$this->label = $html;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
class Html extends Bar
|
||||
{
|
||||
protected $view = 'html';
|
||||
|
||||
public function __construct($html)
|
||||
{
|
||||
$this->label = $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
class LinkBtn extends Bar
|
||||
{
|
||||
protected $view = 'linkbtn';
|
||||
|
||||
protected $postChecked = '';
|
||||
|
||||
protected $confirm = true;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return 'btn-' . $this->name . preg_replace('/\W/', '', $this->tableRowKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*/
|
||||
public function postChecked($url, $confirm = true)
|
||||
{
|
||||
$this->postChecked = $url;
|
||||
$this->confirm = $confirm;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function postCheckedScript()
|
||||
{
|
||||
$script = '';
|
||||
$inputId = $this->getId();
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
tpextbuilder.postChecked('{$inputId}', '{$this->postChecked}', {$this->confirm});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if ($this->postChecked) {
|
||||
|
||||
$this->postCheckedScript();
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
class LinkBtn extends Bar
|
||||
{
|
||||
protected $view = 'linkbtn';
|
||||
|
||||
protected $postChecked = '';
|
||||
|
||||
protected $confirm = true;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return 'btn-' . $this->name . preg_replace('/\W/', '', $this->tableRowKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url
|
||||
* @param boolean $confirm
|
||||
* @return $this
|
||||
*/
|
||||
public function postChecked($url, $confirm = true)
|
||||
{
|
||||
$this->postChecked = $url;
|
||||
$this->confirm = $confirm;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function postCheckedScript()
|
||||
{
|
||||
$script = '';
|
||||
$inputId = $this->getId();
|
||||
|
||||
$script = <<<EOT
|
||||
|
||||
tpextbuilder.postChecked('{$inputId}', '{$this->postChecked}', {$this->confirm});
|
||||
|
||||
EOT;
|
||||
$this->script[] = $script;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function beforRender()
|
||||
{
|
||||
if ($this->postChecked) {
|
||||
|
||||
$this->postCheckedScript();
|
||||
}
|
||||
|
||||
return parent::beforRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$vars = $this->commonVars();
|
||||
|
||||
$viewshow = $this->getViewInstance();
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
/**
|
||||
* Class Wapper.
|
||||
*
|
||||
* @method \tpext\builder\toolbar\LinkBtn linkBtn($name, $label)
|
||||
* @method \tpext\builder\toolbar\ActionBtn actionBtn($name, $label)
|
||||
* @method \tpext\builder\toolbar\ImportBtn importBtn($name, $label)
|
||||
* @method \tpext\builder\toolbar\Html html($html)
|
||||
*/
|
||||
|
||||
class Wapper
|
||||
{
|
||||
protected static $displayers = [];
|
||||
|
||||
protected static $displayerMap = [
|
||||
'linkBtn' => \tpext\builder\toolbar\LinkBtn::class,
|
||||
'actionBtn' => \tpext\builder\toolbar\ActionBtn::class,
|
||||
'html' => \tpext\builder\toolbar\Html::class,
|
||||
];
|
||||
|
||||
protected static $defaultFieldClass = [
|
||||
'linkBtn' => 'btn-sm',
|
||||
];
|
||||
|
||||
public static function isDisplayer($name)
|
||||
{
|
||||
if (empty(static::$displayers)) {
|
||||
static::$displayers = array_keys(static::$displayerMap);
|
||||
}
|
||||
|
||||
return in_array($name, static::$displayers);
|
||||
}
|
||||
|
||||
public static function hasDefaultFieldClass($type)
|
||||
{
|
||||
if (isset(static::$defaultFieldClass[$type])) {
|
||||
return static::$defaultFieldClass[$type];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function extend($pair)
|
||||
{
|
||||
static::$displayerMap = array_merge(static::$displayerMap, $pair);
|
||||
}
|
||||
|
||||
public static function setdefaultFieldClass($pair)
|
||||
{
|
||||
static::$defaultFieldClass = array_merge(static::$defaultFieldClass, $pair);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace tpext\builder\toolbar;
|
||||
|
||||
/**
|
||||
* Class Wapper.
|
||||
*
|
||||
* @method \tpext\builder\toolbar\LinkBtn linkBtn($name, $label)
|
||||
* @method \tpext\builder\toolbar\ActionBtn actionBtn($name, $label)
|
||||
* @method \tpext\builder\toolbar\ImportBtn importBtn($name, $label)
|
||||
* @method \tpext\builder\toolbar\Html html($html)
|
||||
*/
|
||||
|
||||
class Wapper
|
||||
{
|
||||
protected static $displayers = [];
|
||||
|
||||
protected static $displayerMap = [
|
||||
'linkBtn' => \tpext\builder\toolbar\LinkBtn::class,
|
||||
'actionBtn' => \tpext\builder\toolbar\ActionBtn::class,
|
||||
'html' => \tpext\builder\toolbar\Html::class,
|
||||
];
|
||||
|
||||
protected static $defaultFieldClass = [
|
||||
'linkBtn' => 'btn-sm',
|
||||
];
|
||||
|
||||
public static function isDisplayer($name)
|
||||
{
|
||||
if (empty(static::$displayers)) {
|
||||
static::$displayers = array_keys(static::$displayerMap);
|
||||
}
|
||||
|
||||
return in_array($name, static::$displayers);
|
||||
}
|
||||
|
||||
public static function hasDefaultFieldClass($type)
|
||||
{
|
||||
if (isset(static::$defaultFieldClass[$type])) {
|
||||
return static::$defaultFieldClass[$type];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function extend($pair)
|
||||
{
|
||||
static::$displayerMap = array_merge(static::$displayerMap, $pair);
|
||||
}
|
||||
|
||||
public static function setdefaultFieldClass($pair)
|
||||
{
|
||||
static::$defaultFieldClass = array_merge(static::$defaultFieldClass, $pair);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<button type="{$type}" class="btn {$class}" {$attr|raw}
|
||||
id="{$id}">{$label|raw}</button>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<button type="{$type}" class="btn {$class}" {$attr|raw}
|
||||
id="{$id}">{$label|raw}</button>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,18 +1,18 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} checkbox-div" id="{$id}">
|
||||
{if condition="$checkallBtn"}
|
||||
<label class="lyear-checkbox {$inline} {$class}">
|
||||
<input type="checkbox" class="checkall" id="checkall-{$name}" {if
|
||||
condition="$checkall" }checked{/if}
|
||||
data-check="check-{$name}"><span>{$checkallBtn}</span>
|
||||
</label>
|
||||
{/if}
|
||||
{volist name="options" id="option"}
|
||||
<label class="{$inline} {$class}">
|
||||
<input type="checkbox" value="{$key}" class="check-{$name}" {in
|
||||
name="$key" value="$checked" }checked{/in}
|
||||
id="{$id}-{$key}" name="{$name}[]" {$attr|raw}><span>{$option}</span>
|
||||
</label>
|
||||
{/volist}
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} checkbox-div" id="{$id}">
|
||||
{if condition="$checkallBtn"}
|
||||
<label class="lyear-checkbox {$inline} {$class}">
|
||||
<input type="checkbox" class="checkall" id="checkall-{$name}" {if
|
||||
condition="$checkall" }checked{/if}
|
||||
data-check="check-{$name}"><span>{$checkallBtn}</span>
|
||||
</label>
|
||||
{/if}
|
||||
{volist name="options" id="option"}
|
||||
<label class="{$inline} {$class}">
|
||||
<input type="checkbox" value="{$key}" class="check-{$name}" {in
|
||||
name="$key" value="$checked" }checked{/in}
|
||||
id="{$id}-{$key}" name="{$name}[]" {$attr|raw}><span>{$option}</span>
|
||||
</label>
|
||||
{/volist}
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value}</textarea>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value}</textarea>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,10 +1,10 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="input-group colorpicker-element col-md-12">
|
||||
<span class="input-group-addon"><i style="background-color: #fff;"></i></span>
|
||||
<input type="text" class="form-control {$class}"
|
||||
placeholder="请输选择{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="input-group colorpicker-element col-md-12">
|
||||
<span class="input-group-addon"><i style="background-color: #fff;"></i></span>
|
||||
<input type="text" class="form-control {$class}"
|
||||
placeholder="请输选择{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,5 +1,5 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class='divider'>{$value|default='-'|raw}</div>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class='divider'>{$value|default='-'|raw}</div>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,8 +1,8 @@
|
|||
{notempty name="error"}
|
||||
<small class="help-block">{$error}</small>
|
||||
{/notempty}
|
||||
{notempty name="help"}
|
||||
<div class="help-block">
|
||||
<i class="mdi mdi-information-outline"></i>{$help|raw}
|
||||
</div>
|
||||
{notempty name="error"}
|
||||
<small class="help-block">{$error}</small>
|
||||
{/notempty}
|
||||
{notempty name="help"}
|
||||
<div class="help-block">
|
||||
<i class="mdi mdi-information-outline"></i> {$help|raw}
|
||||
</div>
|
||||
{/notempty}
|
|
@ -1,5 +1,5 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
{$value|raw}
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
{$value|raw}
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,6 +1,6 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<input type="text" class="form-control {$class}" placeholder="请输入{$label}" value="{$value}" name="{$name}"
|
||||
id="{$id}" {$attr|raw}>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<input type="text" class="form-control {$class}" placeholder="请输入{$label}" value="{$value}" name="{$name}"
|
||||
id="{$id}" {$attr|raw}>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,6 +1,6 @@
|
|||
{if condition="$showLabel"}
|
||||
<label class="col-md-{$size[0]} {$labelClass}" {$labelAttr|raw} for="{$id}">
|
||||
{$label|raw}
|
||||
<strong title="必填" class="field-required" {$requiredStyle|raw}> *</strong>
|
||||
</label>
|
||||
{if condition="$showLabel"}
|
||||
<label class="col-md-{$size[0]} {$labelClass}" {$labelAttr|raw} for="{$id}">
|
||||
{$label|raw}
|
||||
<strong title="必填" class="field-required" {$requiredStyle|raw}> *</strong>
|
||||
</label>
|
||||
{/if}
|
|
@ -1,9 +1,9 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div id="{$id}-div">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value|raw}</textarea>
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div id="{$id}-div">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value|raw}</textarea>
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,49 +1,49 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="js-upload-files" data-name="{$name}">
|
||||
{if condition="$canUpload"}
|
||||
<div>
|
||||
<input type="hidden" name="{$name}" class="{$class}"
|
||||
value="{$value}" id="{$id}" {$attr|raw}>
|
||||
<div id="picker_{$name}"><i class="mdi
|
||||
mdi-cloud-upload"></i> 上传{if
|
||||
condition="$jsOptions.multiple"}多{else/}单{/if}个文件</div>
|
||||
</div>
|
||||
{/if}
|
||||
<ul id="file_list_{$name}" class="pull-left list-inline clearfix
|
||||
lyear-uploads-pic">
|
||||
{volist name="files" id="file"}
|
||||
<li class="pic-item" id="flie{$key}">
|
||||
<figure>
|
||||
<div>
|
||||
<img style="display: none;" class="preview-img"
|
||||
src="{$file}" />
|
||||
</div>
|
||||
<figcaption>
|
||||
<a class="btn btn-round btn-square btn-primary
|
||||
btn-link-pic" data-id="file{$key}"
|
||||
href="{$file}"><i class="mdi mdi-eye"></i></a>
|
||||
{if condition="$canUpload"}
|
||||
<a class="btn btn-round btn-square btn-danger
|
||||
btn-remove-pic" href="javascript:;"><i class="mdi
|
||||
mdi-delete"></i></a>
|
||||
{/if}
|
||||
</figcaption>
|
||||
</figure>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
<script>
|
||||
var jsOptions = JSON.parse('{$jsOptions|json_encode|raw}')
|
||||
|
||||
if(!window.uploadConfigs)
|
||||
{
|
||||
window.uploadConfigs = [];
|
||||
}
|
||||
|
||||
window.uploadConfigs['{$name}']= jsOptions;
|
||||
|
||||
</script>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="js-upload-files" data-name="{$name}">
|
||||
{if condition="$canUpload"}
|
||||
<div>
|
||||
<input type="hidden" name="{$name}" class="{$class}"
|
||||
value="{$value}" id="{$id}" {$attr|raw}>
|
||||
<div id="picker_{$name}"><i class="mdi
|
||||
mdi-cloud-upload"></i> 上传{if
|
||||
condition="$jsOptions.multiple"}多{else/}单{/if}个文件</div>
|
||||
</div>
|
||||
{/if}
|
||||
<ul id="file_list_{$name}" class="pull-left list-inline clearfix
|
||||
lyear-uploads-pic">
|
||||
{volist name="files" id="file"}
|
||||
<li class="pic-item" id="flie{$key}">
|
||||
<figure>
|
||||
<div>
|
||||
<img style="display: none;" class="preview-img"
|
||||
src="{$file}" />
|
||||
</div>
|
||||
<figcaption>
|
||||
<a class="btn btn-round btn-square btn-primary
|
||||
btn-link-pic" data-id="file{$key}"
|
||||
href="{$file}"><i class="mdi mdi-eye"></i></a>
|
||||
{if condition="$canUpload"}
|
||||
<a class="btn btn-round btn-square btn-danger
|
||||
btn-remove-pic" href="javascript:;"><i class="mdi
|
||||
mdi-delete"></i></a>
|
||||
{/if}
|
||||
</figcaption>
|
||||
</figure>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
<script>
|
||||
var jsOptions = JSON.parse('{$jsOptions|json_encode|raw}')
|
||||
|
||||
if(!window.uploadConfigs)
|
||||
{
|
||||
window.uploadConfigs = [];
|
||||
}
|
||||
|
||||
window.uploadConfigs['{$name}']= jsOptions;
|
||||
|
||||
</script>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,22 +1,22 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} clearfix">
|
||||
<select class="form-control {$class}" name="{$name}[]" id="{$id}"
|
||||
multiple="multiple" {$attr|raw}>
|
||||
{if condition="$group"}
|
||||
{volist name="options" id="group"}
|
||||
<optgroup label="{$group.label}">
|
||||
{volist name="group.options" id="option"}
|
||||
<option value="{$key}" {in
|
||||
name="$key" value="$checked" }selected{/in}>{$option}</option>
|
||||
{/volist}
|
||||
</optgroup>
|
||||
{/volist}
|
||||
{else/}
|
||||
{volist name="options" id="option"}
|
||||
<option value="{$key}" {in
|
||||
name="$key" value="$checked" }selected{/in}>{$option}</option>
|
||||
{/volist}
|
||||
{/if}
|
||||
</select>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} clearfix">
|
||||
<select class="form-control {$class}" name="{$name}[]" id="{$id}"
|
||||
multiple="multiple" {$attr|raw}>
|
||||
{if condition="$group"}
|
||||
{volist name="options" id="group"}
|
||||
<optgroup label="{$group.label}">
|
||||
{volist name="group.options" id="option"}
|
||||
<option value="{$key}" {in
|
||||
name="$key" value="$checked" }selected{/in}>{$option}</option>
|
||||
{/volist}
|
||||
</optgroup>
|
||||
{/volist}
|
||||
{else/}
|
||||
{volist name="options" id="option"}
|
||||
<option value="{$key}" {in
|
||||
name="$key" value="$checked" }selected{/in}>{$option}</option>
|
||||
{/volist}
|
||||
{/if}
|
||||
</select>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<input type="text" class="form-control {$class}"
|
||||
placeholder="请输入{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<input type="text" class="form-control {$class}"
|
||||
placeholder="请输入{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,11 +1,11 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="input-group col-md-12">
|
||||
{$befor|raw}
|
||||
<input type="password" class="form-control {$class}"
|
||||
placeholder="请输入{$label}" autocomplete="new-password"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{$after|raw}
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="input-group col-md-12">
|
||||
{$befor|raw}
|
||||
<input type="password" class="form-control {$class}"
|
||||
placeholder="请输入{$label}" autocomplete="new-password"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{$after|raw}
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,11 +1,11 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} radio-div" id="{$id}">
|
||||
{volist name="options" id="option"}
|
||||
<label class="{$inline} {$class}">
|
||||
<input type="radio" value="{$key}" class="check-{$name}" {if
|
||||
condition="$key eq $checked" }checked{/if} id="{$id}-{$key}"
|
||||
name="{$name}" {$attr|raw}><span>{$option}</span>
|
||||
</label>
|
||||
{/volist}
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} radio-div" id="{$id}">
|
||||
{volist name="options" id="option"}
|
||||
<label class="{$inline} {$class}">
|
||||
<input type="radio" value="{$key}" class="check-{$name}" {if
|
||||
condition="$key eq $checked" }checked{/if} id="{$id}-{$key}"
|
||||
name="{$name}" {$attr|raw}><span>{$option}</span>
|
||||
</label>
|
||||
{/volist}
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,5 +1,5 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} field-raw">
|
||||
{$value|raw}
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} field-raw">
|
||||
{$value|raw}
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,20 +1,20 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} clearfix">
|
||||
<select class="form-control {$class}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{if condition="$group"}
|
||||
{volist name="options" id="group"}
|
||||
<optgroup label="{$group.label}">
|
||||
{volist name="group.options" id="option"}
|
||||
<option value="{$key}" {if condition="$key eq $checked"
|
||||
}selected{/if}>{$option}</option>
|
||||
{/volist}
|
||||
</optgroup>
|
||||
{/volist}
|
||||
{else/}
|
||||
{volist name="options" id="option"}
|
||||
<option value="{$key}" {if condition="$key eq $checked" }selected{/if}>{$option}</option>
|
||||
{/volist}
|
||||
{/if}
|
||||
</select>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} clearfix">
|
||||
<select class="form-control {$class}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{if condition="$group"}
|
||||
{volist name="options" id="group"}
|
||||
<optgroup label="{$group.label}">
|
||||
{volist name="group.options" id="option"}
|
||||
<option value="{$key}" {if condition="$key eq $checked"
|
||||
}selected{/if}>{$option}</option>
|
||||
{/volist}
|
||||
</optgroup>
|
||||
{/volist}
|
||||
{else/}
|
||||
{volist name="options" id="option"}
|
||||
<option value="{$key}" {if condition="$key eq $checked" }selected{/if}>{$option}</option>
|
||||
{/volist}
|
||||
{/if}
|
||||
</select>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,5 +1,5 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} field-show">
|
||||
{$value}
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} field-show">
|
||||
{$value}
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,9 +1,9 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<label class="lyear-switch {$class}">
|
||||
<input type="checkbox" name="{$name}" id="{$id}" {if
|
||||
condition="$checked"}checked{/if} {$attr|raw}>
|
||||
<span></span>
|
||||
</label>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<label class="lyear-switch {$class}">
|
||||
<input type="checkbox" name="{$name}" id="{$id}" {if
|
||||
condition="$checked"}checked{/if} {$attr|raw}>
|
||||
<span></span>
|
||||
</label>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<input type="text" class="form-control js-tags-input {$class}"
|
||||
placeholder="请输入{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<input type="text" class="form-control js-tags-input {$class}"
|
||||
placeholder="请输入{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,11 +1,11 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="input-group col-md-12">
|
||||
{$befor|raw}
|
||||
<input type="text" class="form-control {$class}"
|
||||
placeholder="请输入{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{$after|raw}
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="input-group col-md-12">
|
||||
{$befor|raw}
|
||||
<input type="text" class="form-control {$class}"
|
||||
placeholder="请输入{$label}"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{$after|raw}
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value}</textarea>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value}</textarea>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value|raw}</textarea>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<textarea class="form-control {$class}" placeholder="请输入{$label}"
|
||||
rows="{$options.rows|default=3}"
|
||||
name="{$name}" id="{$id}" {$attr|raw}>{$value|raw}</textarea>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,6 +1,6 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<script name="{$name}" id="{$id}" type="text/plain">{$value|raw}</script>
|
||||
<script type="text/javascript">window.uploadUrl = '{$uploadUrl}'</script>
|
||||
{include file="$helptempl" /}
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<script name="{$name}" id="{$id}" type="text/plain">{$value|raw}</script>
|
||||
<script type="text/javascript">window.uploadUrl = '{$uploadUrl}'</script>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div id="{$id}-div" style="width: 100%; height: 100%;">
|
||||
<p>{$value|raw}</p>
|
||||
</div>
|
||||
<input type="hidden" name="{$name}" id="{$id}" {$attr|raw}
|
||||
value="{$value|raw}">
|
||||
{include file="$helptempl" /}
|
||||
|
||||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div id="{$id}-div" style="width: 100%; height: 100%;">
|
||||
<p>{$value|raw}</p>
|
||||
</div>
|
||||
<input type="hidden" name="{$name}" id="{$id}" {$attr|raw}
|
||||
value="{$value|raw}">
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue