国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

136 linhas
5.6KB

  1. <?php
  2. /**
  3. * 发布分类文档模型
  4. *
  5. * @version $id:archives_sg_add.php 8:26 2010年7月12日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('a_New,a_AccNew');
  13. require_once(DEDEINC."/customfields.func.php");
  14. require_once(DEDEADMIN."/inc/inc_archives_functions.php");
  15. if (empty($dopost)) $dopost = '';
  16. if ($dopost != 'save') {
  17. require_once(DEDEINC."/dedetag.class.php");
  18. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  19. ClearMyAddon();
  20. $channelid = empty($channelid) ? 0 : intval($channelid);
  21. $cid = empty($cid) ? 0 : intval($cid);
  22. //获得栏目模型id
  23. if ($cid > 0 && $channelid == 0) {
  24. $row = $dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id='$cid';");
  25. $channelid = $row['channeltype'];
  26. } else {
  27. if ($channelid == 0) {
  28. ShowMsg("无法识别模型信息,因此无法操作", "-1");
  29. exit();
  30. }
  31. }
  32. //获得栏目模型信息
  33. $cInfos = $dsql->GetOne(" SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  34. $channelid = $cInfos['id'];
  35. include DedeInclude("templets/archives_sg_add.htm");
  36. exit();
  37. } else if ($dopost == 'save') {
  38. require_once(DEDEINC.'/image.func.php');
  39. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  40. if ($typeid == 0) {
  41. ShowMsg("请指定文档的栏目", "-1");
  42. exit();
  43. }
  44. if (empty($channelid)) {
  45. ShowMsg("文档为非指定类型,请检查您发布文档是否正确", "-1");
  46. exit();
  47. }
  48. if (!CheckChannel($typeid, $channelid)) {
  49. ShowMsg("您所选择的栏目与当前模型不相符,请重新选择", "-1");
  50. exit();
  51. }
  52. if (!TestPurview('a_New')) {
  53. CheckCatalog($typeid, "您没有操作栏目<span class='text-primary'>{$typeid}</span>权限");
  54. }
  55. //对保存的文档进行处理
  56. if (empty($writer)) $writer = $cuserLogin->getUserName();
  57. if (empty($source)) $source = '未知';
  58. if (empty($flags)) $flag = '';
  59. else $flag = join(',', $flags);
  60. $senddate = time();
  61. $title = cn_substrR($title, $cfg_title_maxlen);
  62. $isremote = 0;
  63. $serviterm = empty($serviterm) ? "" : $serviterm;
  64. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  65. $adminid = $cuserLogin->getUserID();
  66. $userip = GetIP();
  67. if (empty($ddisremote)) $ddisremote = 0;
  68. $litpic = GetDDImage('none', $picname, $ddisremote);
  69. //生成文档id
  70. $arcID = GetIndexKey($arcrank, $typeid, $senddate, $channelid, $senddate, $adminid);
  71. if (empty($arcID)) {
  72. ShowMsg("获取主键失败,无法进行后续操作", "-1");
  73. exit();
  74. }
  75. //分析处理附加表数据
  76. $inadd_f = '';
  77. $inadd_v = '';
  78. if (!empty($dede_addonfields)) {
  79. $addonfields = explode(';', $dede_addonfields);
  80. $inadd_f = '';
  81. $inadd_v = '';
  82. if (is_array($addonfields)) {
  83. foreach ($addonfields as $v) {
  84. if ($v == '') {
  85. continue;
  86. }
  87. $vs = explode(',', $v);
  88. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //网页文本特殊处理
  89. {
  90. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  91. } else {
  92. if (!isset(${$vs[0]})) {
  93. ${$vs[0]} = '';
  94. }
  95. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  96. }
  97. $inadd_f .= ','.$vs[0];
  98. $inadd_v .= " ,'".${$vs[0]}."' ";
  99. }
  100. }
  101. }
  102. //处理图片文档的自定义属性
  103. if ($litpic != '' && !preg_match("#p#", $flag)) {
  104. $flag = ($flag == '' ? 'p' : $flag.',p');
  105. }
  106. //保存到附加表
  107. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  108. $addtable = trim($cts['addtable']);
  109. if (!empty($addtable)) {
  110. $query = "INSERT INTO `{$addtable}` (aid,typeid,channel,arcrank,mid,click,title,senddate,flag,litpic,userip{$inadd_f}) VALUES ('$arcID','$typeid','$channelid','$arcrank','$adminid','0','$title','$senddate','$flag','$litpic','$userip'{$inadd_v})";
  111. if (!$dsql->ExecuteNoneQuery($query)) {
  112. $gerr = $dsql->GetError();
  113. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  114. ShowMsg("数据保存到数据库附加表出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  115. exit();
  116. }
  117. }
  118. //生成网页
  119. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  120. if ($artUrl == '') {
  121. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  122. }
  123. ClearMyAddon($arcID, $title);
  124. //返回成功信息
  125. $msg = "<tr>
  126. <td bgcolor='#f5f5f5' align='center'><a href='archives_sg_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布分类文档</a><a href='archives_do.php?aid=".$arcID."&dopost=editArchives' class='btn btn-success btn-sm'>修改分类文档</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>浏览分类文档</a><a href='content_sg_list.php?cid=$typeid&channelid={$channelid}&dopost=listArchives' class='btn btn-success btn-sm'>管理分类文档</a></td>
  127. </tr>";
  128. $wintitle = "成功发布分类文档";
  129. $wecome_info = "文档管理 - 发布分类文档";
  130. $win = new OxWindow();
  131. $win->AddTitle("成功发布分类文档");
  132. $win->AddMsgItem($msg);
  133. $winform = $win->GetWindow("hand", false);
  134. $win->Display();
  135. }
  136. ?>