国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

401 lines
18KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  6. <title>修改文档</title>
  7. <link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
  8. <link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
  9. <link rel="stylesheet" href="/static/web/css/admin.css">
  10. <link rel="stylesheet" href="/static/web/css/daterangepicker.css">
  11. <link rel="stylesheet" href="/static/web/css/cropper.min.css">
  12. <script>const cfg_uplitpic_cut = '<?php echo $cfg_uplitpic_cut;?>';</script>
  13. <script src="/static/web/js/jquery.min.js"></script>
  14. <script src="/static/web/js/bootstrap.min.js"></script>
  15. <script src="/static/web/js/webajax.js"></script>
  16. <script src="/static/web/js/moment.min.js"></script>
  17. <script src="/static/web/js/daterangepicker.js"></script>
  18. <script src="/static/web/js/cropper.min.js"></script>
  19. <script src="/static/web/js/admin.main.js"></script>
  20. </head>
  21. <body>
  22. <div class="container-fluid">
  23. <ol class="breadcrumb">
  24. <li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
  25. <?php $cid=isset($cid) ? $cid : '';$channelid=isset($channelid) ? $channelid : '';?><li class="breadcrumb-item"><a href="catalog_do.php?cid=<?php echo $cid?>&channelid=<?php echo $channelid?>&dopost=listArchives">文档列表</a></li>
  26. <li class="breadcrumb-item active">修改文档</li>
  27. </ol>
  28. <div class="card shadow-sm">
  29. <div class="card-header d-flex justify-content-between align-items-center">修改<?php echo $arcRow['title'];?>文档<?php if($cfg_ai_enabled == 'Y'){;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">小德AI助手</button><?php };?></div>
  30. <div class="card-body">
  31. <form name="form1" action="article_edit.php" method="post" enctype="multipart/form-data">
  32. <input type="hidden" name="dopost" value="save">
  33. <input type="hidden" name="channelid" value="<?php echo $channelid?>">
  34. <input type="hidden" name="id" value="<?php echo $aid?>">
  35. <div class="table-responsive">
  36. <table class="table table-borderless">
  37. <tbody>
  38. <tr>
  39. <td width="160">文档标题</td>
  40. <td width="650"><input type="text" name="title" id="title" value="<?php echo $arcRow['title'];?>" class="admin-input-lg" required></td>
  41. <td width="160">简略标题</td>
  42. <td><input type="text" name="shorttitle" id="shorttitle" value="<?php echo $arcRow['shorttitle'];?>" class="admin-input-sm"></td>
  43. </tr>
  44. <tr>
  45. <td>自定义属性</td>
  46. <td colspan="3">
  47. <?php
  48. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  49. $dsql->Execute();
  50. while($trow = $dsql->GetObject())
  51. {
  52. if ($trow->att=='j') {
  53. $jumpclick = " onclick='ShowUrlTr()'";
  54. } else {
  55. $jumpclick = '';
  56. }
  57. if (preg_match("#".$trow->att."#", $arcRow['flag'])) {
  58. echo "<label><input type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' {$jumpclick} checked> {$trow->attname}[{$trow->att}]</label> ";
  59. } else {
  60. echo "<label><input type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' {$jumpclick}> {$trow->attname}[{$trow->att}]</label> ";
  61. }
  62. }
  63. ?>
  64. </td>
  65. </tr>
  66. <tr id="redirecturltr" style="display:<?php echo (empty($addRow['redirecturl']) ? 'none' : 'table-row');?>">
  67. <td>跳转网址</td>
  68. <td colspan="3"><input type="text" name="redirecturl" id="redirecturl" value="<?php echo $addRow['redirecturl']?>" class="admin-input-lg"></td>
  69. </tr>
  70. <tr>
  71. <td>标签</td>
  72. <td><input type="text" name="tags" id="tags" value="<?php echo $tags;?>" class="admin-input-lg">(英文逗号隔开,如:DedeBIZ,得德)</td>
  73. <td>权重</td>
  74. <td><input type="text" name="weight" id="weight" value="<?php echo $arcRow['weight'];?>" class="admin-input-sm">(越小越靠前)</td>
  75. </tr>
  76. <tr id="pictable">
  77. <td>缩略图</td>
  78. <td colspan="3">
  79. <input type="text" name="picname" id="picname" value="<?php echo $arcRow['litpic']?>" class="admin-input-lg">
  80. <label><input type="checkbox" name="ddisremote" value="1" id="ddisremote"> 远程图片</label>
  81. <span class="btn btn-success btn-sm opt-button">上传<input type="file" name="files[]" id="iptAddImages"></span>
  82. <button type="button" onclick="SelectImage('form1.picname','');" class="btn btn-success btn-sm">选择</button>
  83. <button id="btnClearAll" type="button" class="btn btn-success btn-sm">清空</button>
  84. <img src="<?php if ($arcRow['litpic']!='') echo $arcRow['litpic']; else echo '/static/web/img/thumbnail.jpg';?>" id="litPic" class="thumbnail-md ml-3">
  85. </td>
  86. </tr>
  87. <tr>
  88. <td>来源</td>
  89. <td>
  90. <input type="text" name="source" id="source" value="<?php echo $arcRow['source']?>" class="admin-input-sm">
  91. <button type="button" name="selsource" id="selsource" class="btn btn-success btn-sm">选择</button>
  92. </td>
  93. <td>编辑</td>
  94. <td>
  95. <input type="text" name="writer" id="writer" value="<?php echo $arcRow['writer']?>" class="admin-input-sm">
  96. <button type="button" name="selwriter" id="selwriter" class="btn btn-success btn-sm">选择</button>
  97. </td>
  98. </tr>
  99. <tr>
  100. <td>发布栏目</td>
  101. <td>
  102. <?php
  103. $typeOptions = GetOptionList($arcRow['typeid'],$cuserLogin->getUserChannel(),$channelid);
  104. echo "<select name='typeid' id='typeid' class='admin-input-sm'>";
  105. if ($arcRow["typeid"]=="0") echo "<option value='0' selected>请选择文档栏目</option>";
  106. echo $typeOptions;
  107. echo "</select>";
  108. ?>
  109. <a href="javascript:ShowCatMap(event,this,<?php echo $channelid;?>,'typeid','<?php echo $arcRow['typeid'];?>');" class="btn btn-success btn-sm">选择</a>
  110. </td>
  111. <td>金币</td>
  112. <td><input type="text" name="money" id="money" value="<?php echo $arcRow['money']?>" class="admin-input-sm"></td>
  113. </tr>
  114. <?php if ($cfg_need_typeid2=='Y') {?>
  115. <tr>
  116. <td>副栏目</td>
  117. <td colspan="3">
  118. <span id="typeid2ct"></span>
  119. <input type="text" name="typeid2" id="typeid2" value="<?php echo ($arcRow['typeid2']=='0'?'':$arcRow['typeid2']);?>" class="admin-input-sm">
  120. <a href="javascript:ShowCatMap(event,this,<?php echo $channelid;?>,'typeid2','<?php echo $arcRow['typeid2'];?>');" class="btn btn-success btn-sm">选择</a>
  121. </td>
  122. </tr>
  123. <?php }?>
  124. <tr>
  125. <td>关键词</td>
  126. <td colspan="3"><input type="text" name="keywords" id="keywords" value="<?php echo $arcRow['keywords']?>" class="admin-input-lg"></td>
  127. </tr>
  128. <tr>
  129. <td>描述</td>
  130. <td colspan="3"><textarea name="description" id="description" class="admin-textarea-sm"><?php echo $arcRow['description']?></textarea></td>
  131. </tr>
  132. <tr>
  133. <td>附加选项</td>
  134. <td colspan="3">
  135. <label><input type="checkbox" name="remote" id="remote" value="1" <?php if ($cfg_rm_remote=='Y') echo 'checked';?>> 下载远程图片和资源</label>
  136. <label><input type="checkbox" name="autolitpic" id="autolitpic" value="1" <?php if ($cfg_arc_autopic=='Y') echo 'checked';?>> 提取第一个图片为缩略图</label>
  137. </td>
  138. </tr>
  139. <?php PrintAutoFieldsEdit($cInfos['fieldset'],$addRow,'autofield');?>
  140. <tr>
  141. <td colspan="4"><?php GetEditor('body',stripcslashes($addRow['body']),350);?></td>
  142. </tr>
  143. <tr>
  144. <td>评论选项</td>
  145. <td>
  146. <label><input type="radio" name="notpost" value="0" <?php if ($arcRow['notpost']==0) echo 'checked';?>> 允许评论</label>
  147. <label><input type="radio" name="notpost" value="1" <?php if ($arcRow['notpost']==1) echo 'checked';?>> 禁止评论</label>
  148. </td>
  149. <td>发布选项</td>
  150. <td>
  151. <label><input name="ishtml" type="radio" value="1" <?php if ($arcRow["ismake"]!=-1) echo 'checked';?>> 静态浏览</label>
  152. <label><input type="radio" name="ishtml" value="0" <?php if ($arcRow["ismake"]==-1) echo 'checked';?>> 动态浏览</label>
  153. </td>
  154. </tr>
  155. <tr>
  156. <td>文档排序</td>
  157. <td>
  158. <select name="sortup" id="sortup" class="admin-input-sm">
  159. <?php
  160. $subday = SubDay($arcRow["sortrank"],$arcRow["pubdate"]);
  161. echo "<option value='0'>正常排序</option>";
  162. if ($subday>0) echo "<option value='$subday' selected>置顶".$subday."天</option>";
  163. ?>
  164. <option value="7">置顶一周</option>
  165. <option value="30">置顶一个月</option>
  166. <option value="90">置顶三个月</option>
  167. <option value="180">置顶半年</option>
  168. <option value="360">置顶一年</option>
  169. </select>
  170. </td>
  171. <td>标题颜色</td>
  172. <td>
  173. <input type="text" name="color" id="color" value="<?php echo $arcRow['color']?>" class="admin-input-sm">
  174. <button type="button" name="modcolor" id="modcolor" onclick="ShowColor(event,this);" class="btn btn-success btn-sm">选择</button>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td>浏览权限</td>
  179. <td>
  180. <select name="arcrank" id="arcrank" class="admin-input-sm">
  181. <option value='<?php echo $arcRow["arcrank"]?>'><?php echo $arcRow["rankname"]?> </option>
  182. <?php
  183. $urank = $cuserLogin->getUserRank();
  184. $dsql->SetQuery("SELECT * FROM `#@__arcrank` where adminrank<='$urank' ORDER BY `rank` ASC");
  185. $dsql->Execute();
  186. while($row = $dsql->GetObject()){
  187. echo "<option value='".$row->rank."'>".$row->membername."</option>";
  188. }
  189. ?>
  190. </select>
  191. <span>(暂不支持静态)</span>
  192. </td>
  193. <td>文件名称</td>
  194. <td><input type="text" name="filename" id="filename" value="<?php echo $arcRow['filename']?>" class="admin-input-sm">(不包括文件扩展名)</td>
  195. <td><?php echo "<input type='hidden' name='templet' value='{$addRow['templet']}'>";?></td>
  196. </tr>
  197. <tr>
  198. <td>发布时间</td>
  199. <td>
  200. <?php
  201. $notime = GetDateTimeMk($arcRow["pubdate"]);
  202. echo "<input type='text' name='pubdate' value='$notime' id='pubdate' class='datepicker admin-input-sm'>";
  203. ?>
  204. </td>
  205. <td>更新时间</td>
  206. <td>
  207. <?php
  208. $nowtime = GetDateTimeMk(time());
  209. echo "<input type='text' name='senddate' value='$nowtime' id='senddate' class='datepicker admin-input-sm'>";
  210. ?>
  211. </td>
  212. </tr>
  213. <tr>
  214. <td>浏览次数</td>
  215. <td><input type="text" name="click" value="<?php echo $arcRow['click'];?>" class="admin-input-sm"></td>
  216. </tr>
  217. <tr>
  218. <td align="center" colspan="4">
  219. <button type="submit" class="btn btn-success btn-sm">保存</button>
  220. <button type="reset" class="btn btn-outline-success btn-sm">重置</button>
  221. </td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. </div>
  226. </form>
  227. </div>
  228. </div>
  229. </div>
  230. <div id="mdlAI" class="modal fade" tabindex="-1" aria-hidden="true">
  231. <div class="modal-dialog modal-xl">
  232. <div class="modal-content">
  233. <div class="modal-header">
  234. <h5 class="modal-title">小德AI助手:修改文档</h5>
  235. <button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button>
  236. </div>
  237. <div class="modal-body">
  238. <form>
  239. <div class="form-group">
  240. <textarea id="prompt" class="form-control" style="height:160px" placeholder="请输入修改文档要求,例如:我需要对当前文章就行润色,内容轻松活泼些,不要出现错别字。"></textarea>
  241. </div>
  242. <div class="form-group">
  243. <label for="modelid" class="form-label">选择模型</label>
  244. <select id="modelid" class="form-control">
  245. <?php
  246. $dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC");
  247. $dsql->Execute();
  248. while ($row = $dsql->GetObject()) {
  249. ?>
  250. <option value="<?php echo $row->id;?>"<?php echo $row->isdefault==1?' selected' : '';?>><?php echo $row->model;?>(<?php echo $row->aititle;?>)</option>
  251. <?php
  252. }
  253. ?>
  254. </select>
  255. </div>
  256. </form>
  257. </div>
  258. <div class="modal-footer">
  259. <button id="btnAIAction" class="btn btn-success btn-sm">确定</button>
  260. </div>
  261. </div>
  262. </div>
  263. </div>
  264. <script>InitPage();</script>
  265. <script>
  266. let eventSource; //保存EventSource实例
  267. let modelid = 0;
  268. function showAI() {
  269. $("#mdlAI").modal('show');
  270. }
  271. $("#btnAIAction").click(async function() {
  272. let prompt = document.getElementById("prompt").value;
  273. let modelid = document.getElementById("modelid").value;
  274. let req = await fetch(`api.php?action=get_ai_server&pname=article_edit&aid=<?php echo $aid?>&modelid=${modelid}&prompt=${prompt}`);
  275. let resp = await req.json();
  276. if (resp.code !== 0) {
  277. ShowMsg("获取服务器地址失败");
  278. return
  279. }
  280. let eventSource = new EventSource(resp.data);
  281. //新增状态跟踪变量
  282. let currentKey = null;
  283. let tagBuffer = "";
  284. let isClosingTag = false;
  285. $("#mdlAI").modal('hide');
  286. $("#btnAI").attr("disabled", "disabled");
  287. prompt = "";
  288. let lastChar = "";
  289. let bodyHtml = "";
  290. let typeid = "";
  291. eventSource.onmessage = (event) => {
  292. const chars = event.data.split('');
  293. chars.forEach(char => {
  294. if (lastChar === '\\' && char === 'r') {
  295. char = '<br>'; //替换为br标签
  296. lastChar = ""; //清空追踪字符
  297. } else {
  298. lastChar = char; //记录当前字符
  299. }
  300. if (char === '\\') {
  301. return; //如果是反斜杠,跳过处理
  302. }
  303. if (currentKey) {
  304. if (char === '{') {
  305. isClosingTag = true;
  306. tagBuffer = '{';
  307. return;
  308. }
  309. if (isClosingTag) {
  310. tagBuffer += char;
  311. if (tagBuffer === `{/${currentKey}}`) {
  312. if (currentKey == "body") {
  313. CKEDITOR.instances["body"].setReadOnly(false);
  314. bodyHtml = "";
  315. } else if (currentKey == "typeid") {
  316. const input = document.querySelector(`[name="${currentKey}"]`);
  317. if (input) {
  318. $(input).val(typeid);
  319. $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态
  320. }
  321. } else {
  322. const input = document.querySelector(`[name="${currentKey}"]`);
  323. if (input) $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态
  324. }
  325. currentKey = null;
  326. isClosingTag = false;
  327. tagBuffer = "";
  328. return;
  329. }
  330. if (!`{/${currentKey}}`.startsWith(tagBuffer)) {
  331. if (currentKey == "body") {
  332. bodyHtml += tagBuffer;
  333. CKEDITOR.instances["body"].setData(bodyHtml)
  334. } else if (currentKey == "typeid") {
  335. typeid += char;
  336. } else {
  337. const input = document.querySelector(`[name="${currentKey}"]`);
  338. if (input) input.value += tagBuffer;
  339. }
  340. isClosingTag = false;
  341. tagBuffer = "";
  342. }
  343. } else {
  344. if (currentKey == "body") {
  345. //CKEDITOR.instances["body"].insertHtml(char);
  346. bodyHtml += char;
  347. CKEDITOR.instances["body"].setData(bodyHtml)
  348. } else if (currentKey == "typeid") {
  349. typeid += char;
  350. } else {
  351. const input = document.querySelector(`[name="${currentKey}"]`);
  352. if (input) {
  353. input.value += char;
  354. input.scrollTop = input.scrollHeight; //滚动到底部
  355. }
  356. }
  357. }
  358. } else {
  359. if (char === '{') {
  360. tagBuffer = '{';
  361. } else if (tagBuffer.startsWith('{')) {
  362. tagBuffer += char;
  363. if (char === '}') {
  364. const match = tagBuffer.match(/{([^>]+)}/);
  365. if (match) {
  366. currentKey = match[1];
  367. if (currentKey == "body") {
  368. CKEDITOR.instances["body"].setReadOnly(true);
  369. } else {
  370. const input = document.querySelector(`[name="${currentKey}"]`);
  371. if (input) {
  372. $(input).prop("disabled", true).addClass("disabled"); //仅禁用当前输入框
  373. input.value = "";
  374. }
  375. }
  376. }
  377. tagBuffer = "";
  378. }
  379. }
  380. }
  381. });
  382. };
  383. eventSource.onerror = (error) => {
  384. if (error.target.readyState === EventSource.CONNECTING) {
  385. ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>");
  386. } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) {
  387. ShowMsg(error.data);
  388. }
  389. $("#btnAI").prop("disabled", false);
  390. eventSource.close();
  391. };
  392. //监听特定事件 "close"
  393. eventSource.addEventListener('close', (event) => {
  394. console.log('SSE connection closed:', event.data);
  395. $("#btnAI").prop("disabled", false);
  396. eventSource.close(); //关闭连接
  397. });
  398. });
  399. </script>
  400. </body>
  401. </html>