国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

405 řádky
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"><span>修改<?php echo $arcRow['title'];?>文档</span><?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">
  127. <input type="text" name="keywords" id="keywords" value="<?php echo $arcRow['keywords']?>" class="admin-input-lg">
  128. <label><input type="checkbox" name="autokey" id="autokey" value="1" <?php if ($cfg_arc_autokeyword=='Y') echo 'checked';?>> 自动获取</label>
  129. <button type="button" onclick="SelectKeywords('form1.keywords');" class="btn btn-success btn-sm">选择</button>
  130. </td>
  131. </tr>
  132. <tr>
  133. <td>描述</td>
  134. <td colspan="3"><textarea name="description" id="description" class="admin-textarea-sm"><?php echo $arcRow['description']?></textarea></td>
  135. </tr>
  136. <tr>
  137. <td>附加选项</td>
  138. <td colspan="3">
  139. <label><input type="checkbox" name="remote" id="remote" value="1" <?php if ($cfg_rm_remote=='Y') echo 'checked';?>> 下载远程图片和资源</label>
  140. <label><input type="checkbox" name="autolitpic" id="autolitpic" value="1" <?php if ($cfg_arc_autopic=='Y') echo 'checked';?>> 提取第一个图片为缩略图</label>
  141. </td>
  142. </tr>
  143. <?php PrintAutoFieldsEdit(stripslashes($cInfos['fieldset']),$addRow,'autofield');?>
  144. <tr>
  145. <td colspan="4"><?php GetEditor('body',stripcslashes($addRow['body']),350);?></td>
  146. </tr>
  147. <tr>
  148. <td>评论选项</td>
  149. <td>
  150. <label><input type="radio" name="notpost" value="0" <?php if ($arcRow['notpost']==0) echo 'checked';?>> 允许评论</label>
  151. <label><input type="radio" name="notpost" value="1" <?php if ($arcRow['notpost']==1) echo 'checked';?>> 禁止评论</label>
  152. </td>
  153. <td>发布选项</td>
  154. <td>
  155. <label><input name="ishtml" type="radio" value="1" <?php if ($arcRow["ismake"]!=-1) echo 'checked';?>> 静态浏览</label>
  156. <label><input type="radio" name="ishtml" value="0" <?php if ($arcRow["ismake"]==-1) echo 'checked';?>> 动态浏览</label>
  157. </td>
  158. </tr>
  159. <tr>
  160. <td>文档排序</td>
  161. <td>
  162. <select name="sortup" id="sortup" class="admin-input-sm">
  163. <?php
  164. $subday = SubDay($arcRow["sortrank"],$arcRow["pubdate"]);
  165. echo "<option value='0'>正常排序</option>";
  166. if ($subday>0) echo "<option value='$subday' selected>置顶".$subday."天</option>";
  167. ?>
  168. <option value="7">置顶一周</option>
  169. <option value="30">置顶一个月</option>
  170. <option value="90">置顶三个月</option>
  171. <option value="180">置顶半年</option>
  172. <option value="360">置顶一年</option>
  173. </select>
  174. </td>
  175. <td>标题颜色</td>
  176. <td>
  177. <input type="text" name="color" id="color" value="<?php echo $arcRow['color']?>" class="admin-input-sm">
  178. <button type="button" name="modcolor" id="modcolor" onclick="ShowColor(event,this);" class="btn btn-success btn-sm">选择</button>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td>浏览权限</td>
  183. <td>
  184. <select name="arcrank" id="arcrank" class="admin-input-sm">
  185. <option value='<?php echo $arcRow["arcrank"]?>'><?php echo $arcRow["rankname"]?> </option>
  186. <?php
  187. $urank = $cuserLogin->getUserRank();
  188. $dsql->SetQuery("SELECT * FROM `#@__arcrank` where adminrank<='$urank' ORDER BY `rank` ASC");
  189. $dsql->Execute();
  190. while($row = $dsql->GetObject()){
  191. echo "<option value='".$row->rank."'>".$row->membername."</option>";
  192. }
  193. ?>
  194. </select>
  195. <span>(暂不支持静态)</span>
  196. </td>
  197. <td>文件名称</td>
  198. <td><input type="text" name="filename" id="filename" value="<?php echo $arcRow['filename']?>" class="admin-input-sm">(不包括文件扩展名)</td>
  199. <td><?php echo "<input type='hidden' name='templet' value='{$addRow['templet']}'>";?></td>
  200. </tr>
  201. <tr>
  202. <td>发布时间</td>
  203. <td>
  204. <?php
  205. $notime = GetDateTimeMk($arcRow["pubdate"]);
  206. echo "<input type='text' name='pubdate' value='$notime' id='pubdate' class='datepicker admin-input-sm'>";
  207. ?>
  208. </td>
  209. <td>更新时间</td>
  210. <td>
  211. <?php
  212. $nowtime = GetDateTimeMk(time());
  213. echo "<input type='text' name='senddate' value='$nowtime' id='senddate' class='datepicker admin-input-sm'>";
  214. ?>
  215. </td>
  216. </tr>
  217. <tr>
  218. <td>浏览次数</td>
  219. <td><input type="text" name="click" value="<?php echo $arcRow['click'];?>" class="admin-input-sm"></td>
  220. </tr>
  221. <tr>
  222. <td align="center" colspan="4">
  223. <button type="submit" class="btn btn-success btn-sm">保存</button>
  224. <button type="reset" class="btn btn-outline-success btn-sm">重置</button>
  225. </td>
  226. </tr>
  227. </tbody>
  228. </table>
  229. </div>
  230. </form>
  231. </div>
  232. </div>
  233. </div>
  234. <div id="mdlAI" class="modal fade" tabindex="-1" aria-hidden="true">
  235. <div class="modal-dialog modal-xl">
  236. <div class="modal-content">
  237. <div class="modal-header">
  238. <h5 class="modal-title">小德AI助手:修改<?php echo $arcRow['title'];?>文档</h5>
  239. <button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button>
  240. </div>
  241. <div class="modal-body">
  242. <form>
  243. <div class="form-group">
  244. <textarea id="prompt" class="form-control" style="height:160px" placeholder="请输入修改文档要求,例如:我需要对当前文章就行润色,内容轻松活泼些,不要出现错别字。"></textarea>
  245. </div>
  246. <div class="form-group">
  247. <label for="modelid" class="form-label">选择模型</label>
  248. <select id="modelid" class="form-control">
  249. <?php
  250. $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");
  251. $dsql->Execute();
  252. while ($row = $dsql->GetObject()) {
  253. ?>
  254. <option value="<?php echo $row->id;?>" <?php echo $row->isdefault==1?' selected' : '';?>><?php echo $row->model;?> <?php echo $row->aititle;?></option>
  255. <?php
  256. }
  257. ?>
  258. </select>
  259. </div>
  260. </form>
  261. </div>
  262. <div class="modal-footer">
  263. <button id="btnAIAction" class="btn btn-success btn-sm">确定</button>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. <script>InitPage();</script>
  269. <script>
  270. let eventSource; //保存EventSource实例
  271. let modelid = 0;
  272. function showAI() {
  273. $("#mdlAI").modal('show');
  274. }
  275. $("#btnAIAction").click(async function() {
  276. let prompt = document.getElementById("prompt").value;
  277. let modelid = document.getElementById("modelid").value;
  278. let req = await fetch(`api.php?action=get_ai_server&pname=article_edit&aid=<?php echo $aid?>&modelid=${modelid}&prompt=${prompt}`);
  279. let resp = await req.json();
  280. if (resp.code !== 0) {
  281. ShowMsg("获取服务器地址失败");
  282. return
  283. }
  284. let eventSource = new EventSource(resp.data);
  285. //新增状态跟踪变量
  286. let currentKey = null;
  287. let tagBuffer = "";
  288. let isClosingTag = false;
  289. $("#mdlAI").modal('hide');
  290. $("#btnAI").attr("disabled", "disabled");
  291. prompt = "";
  292. let lastChar = "";
  293. let bodyHtml = "";
  294. let typeid = "";
  295. eventSource.onmessage = (event) => {
  296. const chars = event.data.split('');
  297. chars.forEach(char => {
  298. if (lastChar === '\\' && char === 'r') {
  299. char = '<br>'; //替换为br标签
  300. lastChar = ""; //清空追踪字符
  301. } else {
  302. lastChar = char; //记录当前字符
  303. }
  304. if (char === '\\') {
  305. return; //如果是反斜杠,跳过处理
  306. }
  307. if (currentKey) {
  308. if (char === '{') {
  309. isClosingTag = true;
  310. tagBuffer = '{';
  311. return;
  312. }
  313. if (isClosingTag) {
  314. tagBuffer += char;
  315. if (tagBuffer === `{/${currentKey}}`) {
  316. if (currentKey == "body") {
  317. CKEDITOR.instances["body"].setReadOnly(false);
  318. bodyHtml = "";
  319. } else if (currentKey == "typeid") {
  320. const input = document.querySelector(`[name="${currentKey}"]`);
  321. if (input) {
  322. $(input).val(typeid);
  323. $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态
  324. }
  325. } else {
  326. const input = document.querySelector(`[name="${currentKey}"]`);
  327. if (input) $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态
  328. }
  329. currentKey = null;
  330. isClosingTag = false;
  331. tagBuffer = "";
  332. return;
  333. }
  334. if (!`{/${currentKey}}`.startsWith(tagBuffer)) {
  335. if (currentKey == "body") {
  336. bodyHtml += tagBuffer;
  337. CKEDITOR.instances["body"].setData(bodyHtml)
  338. } else if (currentKey == "typeid") {
  339. typeid += char;
  340. } else {
  341. const input = document.querySelector(`[name="${currentKey}"]`);
  342. if (input) input.value += tagBuffer;
  343. }
  344. isClosingTag = false;
  345. tagBuffer = "";
  346. }
  347. } else {
  348. if (currentKey == "body") {
  349. //CKEDITOR.instances["body"].insertHtml(char);
  350. bodyHtml += char;
  351. CKEDITOR.instances["body"].setData(bodyHtml)
  352. } else if (currentKey == "typeid") {
  353. typeid += char;
  354. } else {
  355. const input = document.querySelector(`[name="${currentKey}"]`);
  356. if (input) {
  357. input.value += char;
  358. input.scrollTop = input.scrollHeight; //滚动到底部
  359. }
  360. }
  361. }
  362. } else {
  363. if (char === '{') {
  364. tagBuffer = '{';
  365. } else if (tagBuffer.startsWith('{')) {
  366. tagBuffer += char;
  367. if (char === '}') {
  368. const match = tagBuffer.match(/{([^>]+)}/);
  369. if (match) {
  370. currentKey = match[1];
  371. if (currentKey == "body") {
  372. CKEDITOR.instances["body"].setReadOnly(true);
  373. } else {
  374. const input = document.querySelector(`[name="${currentKey}"]`);
  375. if (input) {
  376. $(input).prop("disabled", true).addClass("disabled"); //仅禁用当前输入框
  377. input.value = "";
  378. }
  379. }
  380. }
  381. tagBuffer = "";
  382. }
  383. }
  384. }
  385. });
  386. };
  387. eventSource.onerror = (error) => {
  388. if (error.target.readyState === EventSource.CONNECTING) {
  389. ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>");
  390. } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) {
  391. ShowMsg(error.data);
  392. }
  393. $("#btnAI").prop("disabled", false);
  394. eventSource.close();
  395. };
  396. //监听特定事件 "close"
  397. eventSource.addEventListener('close', (event) => {
  398. console.log('SSE connection closed:', event.data);
  399. $("#btnAI").prop("disabled", false);
  400. eventSource.close(); //关闭连接
  401. });
  402. });
  403. </script>
  404. </body>
  405. </html>