国内流行的内容管理系统(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.

211 lines
9.1KB

  1. <?php
  2. /**
  3. * 栏目添加
  4. *
  5. * @version $id:catalog_add.php 14:31 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. require_once(DEDEINC."/typelink/typelink.class.php");
  13. if (empty($listtype)) $listtype = '';
  14. if (empty($dopost)) $dopost = '';
  15. if (empty($upinyin)) $upinyin = 0;
  16. if (empty($channelid)) $channelid = 1;
  17. if (isset($channeltype)) $channelid = $channeltype;
  18. $id = empty($id) ? 0 : intval($id);
  19. $reid = empty($reid) ? 0 : intval($reid);
  20. $nid = 'article';
  21. if ($id == 0 && $reid == 0) {
  22. CheckPurview('t_New');
  23. } else {
  24. $checkID = empty($id) ? $reid : $id;
  25. CheckPurview('t_AccNew');
  26. CheckCatalog($checkID, '您无权在本栏目下创建子类');
  27. }
  28. if (empty($myrow)) $myrow = array();
  29. $dsql->SetQuery("SELECT id,typename,nid FROM `#@__channeltype` WHERE id<>-1 AND isshow=1 ORDER BY id");
  30. $dsql->Execute();
  31. while ($row = $dsql->GetObject()) {
  32. $channelArray[$row->id]['typename'] = $row->typename;
  33. $channelArray[$row->id]['nid'] = $row->nid;
  34. if ($row->id == $channelid) {
  35. $nid = $row->nid;
  36. }
  37. }
  38. if ($dopost == 'quick') {
  39. $tl = new TypeLink(0);
  40. $typeOptions = $tl->GetOptionArray(0, 0, $channelid);
  41. include DedeInclude('templets/catalog_add_quick.htm');
  42. exit();
  43. }
  44. /*---------------------
  45. function action_savequick(){ }
  46. ---------------------*/
  47. else if ($dopost == 'savequick') {
  48. if (!isset($savetype)) $savetype = '';
  49. $isdefault = isset($isdefault) ? $isdefault : 0;
  50. $tempindex = "{style}/index_{$nid}.htm";
  51. $templist = "{style}/list_{$nid}.htm";
  52. $temparticle = "{style}/article_{$nid}.htm";
  53. $queryTemplate = "INSERT INTO `#@__arctype` (reid,topid,sortrank,typename,cnoverview,enname,enoverview,bigpic,litimg,typedir,isdefault,defaultname,issend,channeltype,tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`) VALUES ('~reid~','~topid~','~rank~','~typename~','','','','','','~typedir~','$isdefault','$defaultname','$issend','$channeltype','$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','')";
  54. if (empty($savetype)) {
  55. foreach ($_POST as $k => $v) {
  56. if (preg_match("#^posttype#", $k)) {
  57. $k = str_replace('posttype', '', $k);
  58. } else {
  59. continue;
  60. }
  61. $rank = ${'rank'.$k};
  62. $toptypename = trim(${'toptype'.$k});
  63. $sontype = trim(${'sontype'.$k});
  64. $toptypedir = GetPinyin(stripslashes($toptypename));
  65. $toptypedir = $referpath == 'parent' ? $nextdir.'/'.$toptypedir : '/'.$toptypedir;
  66. if (empty($toptypename)) {
  67. continue;
  68. }
  69. $sql = str_replace('~reid~', '0', $queryTemplate);
  70. $sql = str_replace('~topid~', '0', $sql);
  71. $sql = str_replace('~rank~', $rank, $sql);
  72. $sql = str_replace('~typename~', $toptypename, $sql);
  73. $sql = str_replace('~typedir~', $toptypedir, $sql);
  74. $dsql->ExecuteNoneQuery($sql);
  75. $tid = $dsql->GetLastID();
  76. if ($tid > 0 && $sontype != '') {
  77. $sontypes = explode(',', $sontype);
  78. foreach ($sontypes as $k => $v) {
  79. $v = trim($v);
  80. if ($v == '') {
  81. continue;
  82. }
  83. $typedir = $toptypedir.'/'.GetPinyin(stripslashes($v));
  84. $sql = str_replace('~reid~', $tid, $queryTemplate);
  85. $sql = str_replace('~topid~', $tid, $sql);
  86. $sql = str_replace('~rank~', $k, $sql);
  87. $sql = str_replace('~typename~', $v, $sql);
  88. $sql = str_replace('~typedir~', $typedir, $sql);
  89. $dsql->ExecuteNoneQuery($sql);
  90. }
  91. }
  92. }
  93. } else {
  94. $row = $dsql->GetOne("SELECT `typedir` FROM `#@__arctype` WHERE `id`={$reid}");
  95. foreach ($_POST as $k => $v) {
  96. if (preg_match("#^posttype#", $k)) {
  97. $k = str_replace('posttype', '', $k);
  98. } else {
  99. continue;
  100. }
  101. $rank = ${'rank'.$k};
  102. $toptypename = trim(${'reltype'.$k});
  103. $toptypedir = GetPinyin(stripslashes($toptypename));
  104. switch ($referpath) {
  105. case 'parent':
  106. $toptypedir = $nextdir.'/'.$toptypedir;
  107. break;
  108. case 'typepath':
  109. $toptypedir = isset($row['typedir']) ? $row['typedir'].'/'.$toptypedir : '/'.$toptypedir;
  110. break;
  111. default:
  112. $toptypedir = '/'.$toptypedir;
  113. break;
  114. }
  115. if (empty($toptypename)) {
  116. continue;
  117. }
  118. $sql = str_replace('~reid~', $reid, $queryTemplate);
  119. $sql = str_replace('~topid~', $reid, $sql);
  120. $sql = str_replace('~rank~', $rank, $sql);
  121. $sql = str_replace('~typename~', $toptypename, $sql);
  122. $sql = str_replace('~typedir~', $toptypedir, $sql);
  123. $dsql->ExecuteNoneQuery($sql);
  124. }
  125. }
  126. UpDateCatCache();
  127. ShowMsg('成功增加指定栏目', 'catalog_main.php');
  128. exit();
  129. }
  130. /*---------------------
  131. function action_save(){ }
  132. ---------------------*/
  133. else if ($dopost == 'save') {
  134. $smalltypes = '';
  135. if (empty($smalltype)) $smalltype = '';
  136. if (is_array($smalltype)) $smalltypes = join(',', $smalltype);
  137. if (!isset($sitepath)) $sitepath = '';
  138. if ($topid == 0 && $reid > 0) $topid = $reid;
  139. if ($ispart != 0) $cross = 0;
  140. $description = Html2Text($description, 1);
  141. $keywords = Html2Text($keywords, 1);
  142. if ($ispart != 2) {
  143. //栏目的参照目录
  144. if ($referpath == 'cmspath') $nextdir = '{cmspath}';
  145. if ($referpath == 'basepath') $nextdir = '';
  146. //用拼音命名
  147. if ($upinyin == 1 || $typedir == '') {
  148. $typedir = GetPinyin(stripslashes($typename));
  149. }
  150. $typedir = $nextdir.'/'.$typedir;
  151. $typedir = preg_replace("#\/{1,}#", "/", $typedir);
  152. }
  153. //开启多站点时的设置(仅针对顶级栏目)
  154. if ($reid == 0 && $moresite == 1) {
  155. $sitepath = $typedir;
  156. //检测二级网址
  157. if ($siteurl != '') {
  158. $siteurl = preg_replace("#\/$#", "", $siteurl);
  159. if (!preg_match("#http:\/\/#i", $siteurl)) {
  160. ShowMsg("您绑定的二级域名无效,请用(http://host)的形式", "-1");
  161. exit();
  162. }
  163. if (preg_match("#".$cfg_basehost."#i", $siteurl)) {
  164. ShowMsg("您绑定的二级域名与当前站点是同一个域,不需要绑定", "-1");
  165. exit();
  166. }
  167. }
  168. }
  169. //创建目录
  170. if ($ispart != 2) {
  171. $true_typedir = str_replace("{cmspath}", $cfg_cmspath, $typedir);
  172. $true_typedir = preg_replace("#\/{1,}#", "/", $true_typedir);
  173. if (!CreateDir($true_typedir)) {
  174. ShowMsg("创建目录 {$true_typedir} 失败,请检查您的路径是否存在问题", "-1");
  175. exit();
  176. }
  177. }
  178. $in_query = "INSERT INTO `#@__arctype` (reid,topid,sortrank,typename,cnoverview,enname,enoverview,bigpic,litimg,typedir,isdefault,defaultname,issend,channeltype,tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`) VALUES ('$reid','$topid','$sortrank','$typename','$cnoverview','$enname','$enoverview','$bigpic','$litimg','$typedir','$isdefault','$defaultname','$issend','$channeltype','$tempindex','$templist','$temparticle','default','$namerule','$namerule2','$ispart','$corank','$description','$keywords','$seotitle','$moresite','$siteurl','$sitepath','$ishidden','$cross','$crossid','$content','$smalltypes')";
  179. if (!$dsql->ExecuteNoneQuery($in_query)) {
  180. ShowMsg("保存目录数据时失败,请检查您的输入资料是否存在问题", "-1");
  181. exit();
  182. }
  183. UpDateCatCache();
  184. if ($reid > 0) {
  185. PutCookie('lastCid', GetTopid($reid), 3600 * 24, '/');
  186. }
  187. ShowMsg("成功创建一个分类", "catalog_main.php");
  188. exit();
  189. }//End dopost==save
  190. //获取从父目录继承的默认参数
  191. if ($dopost == '') {
  192. $channelid = 1;
  193. $issend = 1;
  194. $corank = 0;
  195. $reid = 0;
  196. $topid = 0;
  197. $typedir = '';
  198. $moresite = 0;
  199. if ($id > 0) {
  200. $myrow = $dsql->GetOne("SELECT tp.*,ch.typename AS ctypename FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id=$id ");
  201. $channelid = $myrow['channeltype'];
  202. $issennd = $myrow['issend'];
  203. $corank = $myrow['corank'];
  204. $topid = $myrow['topid'];
  205. $typedir = $myrow['typedir'];
  206. }
  207. //父栏目是否为二级站点
  208. $moresite = empty($myrow['moresite']) ? 0 : $myrow['moresite'];
  209. }
  210. include DedeInclude('templets/catalog_add.htm');
  211. ?>