From 54bc71e94d806da6495e0d10ab18d1adccd14c17 Mon Sep 17 00:00:00 2001 From: tianya Date: Thu, 2 Mar 2023 21:22:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=B8=AD=E5=9B=BE=E7=89=87=E3=80=81=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apps/diy.php | 3 ++- src/static/web/js/diy.js | 38 +++++++++++++++++++++++++++++++ src/static/web/js/user.js | 39 ++++++++++++++++++++++++++++++++ src/system/customfields.func.php | 34 ++++++++++------------------ src/theme/plus/post_diyform.htm | 3 ++- src/user/api.php | 14 ++++-------- src/user/archives_edit.php | 2 +- 7 files changed, 99 insertions(+), 34 deletions(-) create mode 100644 src/static/web/js/diy.js diff --git a/src/apps/diy.php b/src/apps/diy.php index 615a5a31..84c0b98f 100755 --- a/src/apps/diy.php +++ b/src/apps/diy.php @@ -77,8 +77,9 @@ if ($action == 'post') { $bkmsg = '发布成功,请等待管理员处理'; //提交后返回提交页面 echo""; + exit; } - showmsg($bkmsg, $goto); + ShowMsg($bkmsg, $goto); } } } else if ($action == 'list') { diff --git a/src/static/web/js/diy.js b/src/static/web/js/diy.js new file mode 100644 index 00000000..533ddc14 --- /dev/null +++ b/src/static/web/js/diy.js @@ -0,0 +1,38 @@ +function SelectImage(sform,stype) { + let s = sform.split("."); + if (s.length === 2) { + let frm = document.getElementsByName(s[0]); + let ipt = document.getElementsByName(s[1]); + let tmp = document.createElement("input"); + tmp.id = 'field'+s[1]; + tmp.type = "file"; + tmp.style.display = 'none'; + if ($(`#${tmp.id}`).length === 0) { + $(frm).append(tmp); + } + $(`#${tmp.id}`).click(); + $(`#${tmp.id}`).off('change').change(function (val) { + const f = val.target.files[0]; + var formData = new FormData(); + var fileData = f; + formData.append('file', fileData); + $.ajax({ + url: '../user/api.php?action=upload&type=litpic', + type: 'POST', + data: formData, + processData: false, + contentType: false, + success: function (result) { + if (result.code === 0) { + $(ipt).val(result.data); + } else { + ShowMsg("文件上传失败,错误原因:"+result.msg); + } + }, + error: function (xhr, status, error) { + ShowMsg("文件上传失败");//处理上传失败后的回调 + } + }); + }) + } +} \ No newline at end of file diff --git a/src/static/web/js/user.js b/src/static/web/js/user.js index 44acbe71..abe94bed 100644 --- a/src/static/web/js/user.js +++ b/src/static/web/js/user.js @@ -8,4 +8,43 @@ function checkSubmit(t) { ShowMsg("请您选择文档所属栏目"); return false; } +} + +function SelectImage(sform,stype) { + let s = sform.split("."); + if (s.length === 2) { + let frm = document.getElementsByName(s[0]); + let ipt = document.getElementsByName(s[1]); + let tmp = document.createElement("input"); + tmp.id = 'field'+s[1]; + tmp.type = "file"; + tmp.style.display = 'none'; + if ($(`#${tmp.id}`).length === 0) { + $(frm).append(tmp); + } + $(`#${tmp.id}`).click(); + $(`#${tmp.id}`).off('change').change(function (val) { + const f = val.target.files[0]; + var formData = new FormData(); + var fileData = f; + formData.append('file', fileData); + $.ajax({ + url: 'api.php?action=upload&type=litpic', + type: 'POST', + data: formData, + processData: false, + contentType: false, + success: function (result) { + if (result.code === 0) { + $(ipt).val(result.data); + } else { + ShowMsg("文件上传失败,错误原因:"+result.msg); + } + }, + error: function (xhr, status, error) { + ShowMsg("文件上传失败");//处理上传失败后的回调 + } + }); + }) + } } \ No newline at end of file diff --git a/src/system/customfields.func.php b/src/system/customfields.func.php index 367d7cf8..c8cf3782 100755 --- a/src/system/customfields.func.php +++ b/src/system/customfields.func.php @@ -104,23 +104,11 @@ function GetFormItem($ctag, $admintype = 'admin') $nowtime = GetDateTimeMk(time()); $innertext = ""; } else if ($fieldType == 'img' || $fieldType == 'imgfile') { - if ($admintype == 'diy') { - $innertext = ""; - } else { - $innertext = " "; - } + $innertext = " "; } else if ($fieldType == 'media') { - if ($admintype == 'diy') { - $innertext = " 不支持类型"; - } else { - $innertext = " "; - } + $innertext = ""; } else if ($fieldType == 'addon') { - if ($admintype == 'diy') { - $innertext = ""; - } else { - $innertext = " "; - } + $innertext = ""; } else if ($fieldType == 'int' || $fieldType == 'float') { $dfvalue = ($ctag->GetAtt('default') != '' ? $ctag->GetAtt('default') : '0'); $innertext = ""; @@ -230,7 +218,7 @@ function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '', $a CloseFtp(); return $filename; } else if ($dtype == 'img' || $dtype == 'imgfile') { - if (preg_match("#[\\|/]uploads[\\|/]userup#", $dvalue)) return $dvalue; + if (preg_match("#[\\|/]static[\\|/]userup#", $dvalue)) return $dvalue; if ($admintype == 'diy') { $iurl = MemberUploads($fieldname, '', 0, 'image', '', -1, -1, false); return $iurl; @@ -413,20 +401,22 @@ function GetFormItemValue($ctag, $fvalue, $admintype = 'admin', $fieldname = '') $fvalue = ""; } else { $ntag = $ndtp->GetTag("img"); - $fvalue = trim($ntag->GetInnerText()); + if (!empty($ntag)) { + $fvalue = trim($ntag->GetInnerText()); + } } - $innertext = " "; + $innertext = " "; } else if ($ftype == "imgfile") { - $innertext = " "; + $innertext = " "; } else if ($ftype == "media") { - $innertext = " "; + $innertext = " "; } else if ($ftype == "addon") { - $innertext = " "; + $innertext = " "; } else if ($ftype == "int" || $ftype == "float") { $innertext = ""; } else if ($ftype == "relation") { $channel = ($ctag->GetAtt('channel') == "") ? "1" : $ctag->GetAtt('channel'); - $innertext = "
"; + $innertext = "
"; if ($ctag->GetAtt('automake') == 1) { $innertext .= ""; } diff --git a/src/theme/plus/post_diyform.htm b/src/theme/plus/post_diyform.htm index 22caeee8..5eabd0de 100644 --- a/src/theme/plus/post_diyform.htm +++ b/src/theme/plus/post_diyform.htm @@ -8,6 +8,7 @@ + @@ -15,7 +16,7 @@

name;?>发布

-
+ diff --git a/src/user/api.php b/src/user/api.php index 26e796a9..dee074fa 100755 --- a/src/user/api.php +++ b/src/user/api.php @@ -60,15 +60,11 @@ if ($action === 'is_need_check_code') { )); } else if ($action === 'upload') { if (!$cfg_ml->IsLogin()) { - if ($format === 'json') { - echo json_encode(array( - "code" => -1, - "msg" => "未登录", - "data" => null, - )); - } else { - echo ""; - } + echo json_encode(array( + "code" => -1, + "msg" => "未登录", + "data" => null, + )); exit; } $target_dir = "uploads/";//上传目录 diff --git a/src/user/archives_edit.php b/src/user/archives_edit.php index 29be3b41..e21d4562 100755 --- a/src/user/archives_edit.php +++ b/src/user/archives_edit.php @@ -95,7 +95,7 @@ if (empty($dopost)) { $artUrl = MakeArt($aid, TRUE); if ($artUrl == '') $artUrl = $cfg_phpurl."/view.php?aid=$aid"; //返回成功信息 - $msg = "请选择您的后续操作:发布自定义文档修改自定义文档浏览自定义文档管理自定义文档"; + $msg = "请选择您的后续操作:发布自定义文档修改自定义文档浏览自定义文档管理自定义文档"; $wintitle = "成功修改自定义文档"; $wecome_info = "文档管理::修改自定义文档"; $win = new OxWindow();