Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
cdb0c8f0
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cdb0c8f0
编写于
5月 13, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
应用名称校验优化
上级
4603845f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
14 deletion
+61
-14
application/admin/controller/Pluginsadmin.php
application/admin/controller/Pluginsadmin.php
+12
-1
application/admin/view/default/pluginsadmin/first_step.html
application/admin/view/default/pluginsadmin/first_step.html
+6
-0
application/service/PluginsAdminService.php
application/service/PluginsAdminService.php
+43
-13
未找到文件。
application/admin/controller/Pluginsadmin.php
浏览文件 @
cdb0c8f0
...
...
@@ -127,8 +127,19 @@ class Pluginsadmin extends Common
}
$this
->
assign
(
'data'
,
$data
);
// 名称校验
if
(
!
empty
(
$params
[
'plugins'
]))
{
$ret
=
PluginsAdminService
::
PluginsVerification
(
$params
,
$params
[
'plugins'
]);
if
(
$ret
[
'code'
]
!=
0
)
{
$this
->
assign
(
'verification_msg'
,
$ret
[
'msg'
]);
return
$this
->
fetch
(
'first_step'
);
}
}
// 标记为空或等于view 并且 编辑数据为空则走第一步
if
(
(
empty
(
$params
[
'plugins'
])
||
$params
[
'plugins'
]
==
'view'
)
&&
empty
(
$data
[
'data'
][
0
]))
if
(
empty
(
$params
[
'plugins'
]
)
&&
empty
(
$data
[
'data'
][
0
]))
{
return
$this
->
fetch
(
'first_step'
);
}
else
{
...
...
application/admin/view/default/pluginsadmin/first_step.html
浏览文件 @
cdb0c8f0
...
...
@@ -19,6 +19,12 @@
<div
class=
"am-form-group"
>
<label>
应用唯一标记
<span
class=
"am-form-group-label-tips"
>
以数字、字母小写、下划线
</span></label>
<input
type=
"text"
name=
"plugins"
placeholder=
"名称"
minlength=
"2"
maxlength=
"60"
data-validation-message=
"应用唯一标记格式 2~60 个字符"
pattern=
"^[a-z0-9_]{2,60}$"
class=
"am-radius"
{{
if
!
empty
($
data
)}}
value=
"{{$data.plugins}}"
{{/
if
}}
required
/>
<!-- 校验信息 -->
{{if !empty($verification_msg)}}
<div
class=
"am-alert am-alert-danger"
data-am-alert
>
{{$verification_msg}} , 请重新填写!
</div>
{{/if}}
</div>
<div
class=
"am-form-group am-form-group-refreshing"
>
...
...
application/service/PluginsAdminService.php
浏览文件 @
cdb0c8f0
...
...
@@ -23,6 +23,9 @@ use app\service\SqlconsoleService;
*/
class
PluginsAdminService
{
// 排除不能使用的名称
public
static
$plugins_exclude_verification
=
[
'view'
,
'shopxo'
,
'www'
];
/**
* 列表
* @author Devil
...
...
@@ -807,6 +810,33 @@ php;
return
DataReturn
(
'创建成功'
,
0
);
}
/**
* 名称校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-13T00:00:45+0800
* @param [array] $params [输入参数]
* @param [string] $plugins [应用唯一标记]
*/
public
static
function
PluginsVerification
(
$params
,
$plugins
)
{
// 排除校验
if
(
in_array
(
$plugins
,
self
::
$plugins_exclude_verification
))
{
return
DataReturn
(
'不能使用限制的名称['
.
$plugins
.
']'
,
-
1
);
}
// 应用是否存在
$temp_plugins
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$plugins
])
->
value
(
'plugins'
);
if
(
empty
(
$params
[
'id'
])
&&
$temp_plugins
==
$plugins
)
{
return
DataReturn
(
'应用名称已存在['
.
$plugins
.
']'
,
-
1
);
}
return
DataReturn
(
'校验成功'
,
0
);
}
/**
* 应用添加
* @author Devil
...
...
@@ -819,26 +849,26 @@ php;
*/
private
static
function
PluginsExistInsert
(
$params
,
$plugins
)
{
// 是否非使用的名称
if
(
in_array
(
$plugins
,
[
'view'
,
'shopxo'
]))
// 名称校验
$ret
=
self
::
PluginsVerification
(
$params
,
$plugins
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
DataReturn
(
'不能使用限制的名称['
.
$plugins
.
']'
,
-
1
)
;
return
$ret
;
}
// 应用是否存在
$temp_plugins
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$plugins
])
->
value
(
'plugins'
);
if
(
empty
(
$temp_plugins
))
// 应用添加
if
(
empty
(
$params
[
'id'
]))
{
if
(
Db
::
name
(
'Plugins'
)
->
insertGetId
([
'plugins'
=>
$plugins
,
'is_enable'
=>
0
,
'add_time'
=>
time
()])
<=
0
)
{
return
DataReturn
(
'应用添加失败'
,
-
1
);
}
}
else
{
if
(
empty
(
$params
[
'id'
])
&&
$temp_plugins
==
$plugins
)
$temp_plugins
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$plugins
])
->
value
(
'plugins'
);
if
(
empty
(
$temp_plugins
))
{
return
DataReturn
(
'应用名称已存在['
.
$plugins
.
']'
,
-
1
);
if
(
Db
::
name
(
'Plugins'
)
->
insertGetId
([
'plugins'
=>
$plugins
,
'is_enable'
=>
0
,
'add_time'
=>
time
()])
<=
0
)
{
return
DataReturn
(
'应用添加失败'
,
-
1
);
}
}
}
return
DataReturn
(
'添加成功'
,
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录