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

212 lines
9.1KB

  1. <?php
  2. /**
  3. * 栏目添加
  4. *
  5. * @version $Id: catalog_add.php 1 14:31 2010年7月12日Z 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,namegk,enname,ennamegk,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`)
  54. VALUES('~reid~','~topid~','~rank~','~typename~','','','','','','~typedir~','$isdefault','$defaultname','$issend','$channeltype','$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','')";
  55. if (empty($savetype)) {
  56. foreach ($_POST as $k => $v) {
  57. if (preg_match("#^posttype#", $k)) {
  58. $k = str_replace('posttype', '', $k);
  59. } else {
  60. continue;
  61. }
  62. $rank = ${'rank'.$k};
  63. $toptypename = trim(${'toptype'.$k});
  64. $sontype = trim(${'sontype'.$k});
  65. $toptypedir = GetPinyin(stripslashes($toptypename));
  66. $toptypedir = $referpath == 'parent' ? $nextdir.'/'.$toptypedir : '/'.$toptypedir;
  67. if (empty($toptypename)) {
  68. continue;
  69. }
  70. $sql = str_replace('~reid~', '0', $queryTemplate);
  71. $sql = str_replace('~topid~', '0', $sql);
  72. $sql = str_replace('~rank~', $rank, $sql);
  73. $sql = str_replace('~typename~', $toptypename, $sql);
  74. $sql = str_replace('~typedir~', $toptypedir, $sql);
  75. $dsql->ExecuteNoneQuery($sql);
  76. $tid = $dsql->GetLastID();
  77. if ($tid > 0 && $sontype != '') {
  78. $sontypes = explode(',', $sontype);
  79. foreach ($sontypes as $k => $v) {
  80. $v = trim($v);
  81. if ($v == '') {
  82. continue;
  83. }
  84. $typedir = $toptypedir.'/'.GetPinyin(stripslashes($v));
  85. $sql = str_replace('~reid~', $tid, $queryTemplate);
  86. $sql = str_replace('~topid~', $tid, $sql);
  87. $sql = str_replace('~rank~', $k, $sql);
  88. $sql = str_replace('~typename~', $v, $sql);
  89. $sql = str_replace('~typedir~', $typedir, $sql);
  90. $dsql->ExecuteNoneQuery($sql);
  91. }
  92. }
  93. }
  94. } else {
  95. $row = $dsql->GetOne("SELECT `typedir` FROM `#@__arctype` WHERE `id`={$reid}");
  96. foreach ($_POST as $k => $v) {
  97. if (preg_match("#^posttype#", $k)) {
  98. $k = str_replace('posttype', '', $k);
  99. } else {
  100. continue;
  101. }
  102. $rank = ${'rank'.$k};
  103. $toptypename = trim(${'reltype'.$k});
  104. $toptypedir = GetPinyin(stripslashes($toptypename));
  105. switch ($referpath) {
  106. case 'parent':
  107. $toptypedir = $nextdir.'/'.$toptypedir;
  108. break;
  109. case 'typepath':
  110. $toptypedir = isset($row['typedir']) ? $row['typedir'].'/'.$toptypedir : '/'.$toptypedir;
  111. break;
  112. default:
  113. $toptypedir = '/'.$toptypedir;
  114. break;
  115. }
  116. if (empty($toptypename)) {
  117. continue;
  118. }
  119. $sql = str_replace('~reid~', $reid, $queryTemplate);
  120. $sql = str_replace('~topid~', $reid, $sql);
  121. $sql = str_replace('~rank~', $rank, $sql);
  122. $sql = str_replace('~typename~', $toptypename, $sql);
  123. $sql = str_replace('~typedir~', $toptypedir, $sql);
  124. $dsql->ExecuteNoneQuery($sql);
  125. }
  126. }
  127. UpDateCatCache();
  128. ShowMsg('成功增加指定栏目', 'catalog_main.php');
  129. exit();
  130. }
  131. /*---------------------
  132. function action_save(){ }
  133. ---------------------*/
  134. else if ($dopost == 'save') {
  135. $smalltypes = '';
  136. if (empty($smalltype)) $smalltype = '';
  137. if (is_array($smalltype)) $smalltypes = join(',', $smalltype);
  138. if (!isset($sitepath)) $sitepath = '';
  139. if ($topid == 0 && $reid > 0) $topid = $reid;
  140. if ($ispart != 0) $cross = 0;
  141. $description = Html2Text($description, 1);
  142. $keywords = Html2Text($keywords, 1);
  143. if ($ispart != 2) {
  144. //栏目的参照目录
  145. if ($referpath == 'cmspath') $nextdir = '{cmspath}';
  146. if ($referpath == 'basepath') $nextdir = '';
  147. //用拼音命名
  148. if ($upinyin == 1 || $typedir == '') {
  149. $typedir = GetPinyin(stripslashes($typename));
  150. }
  151. $typedir = $nextdir.'/'.$typedir;
  152. $typedir = preg_replace("#\/{1,}#", "/", $typedir);
  153. }
  154. //开启多站点时的设置(仅针对顶级栏目)
  155. if ($reid == 0 && $moresite == 1) {
  156. $sitepath = $typedir;
  157. //检测二级网址
  158. if ($siteurl != '') {
  159. $siteurl = preg_replace("#\/$#", "", $siteurl);
  160. if (!preg_match("#http:\/\/#i", $siteurl)) {
  161. ShowMsg("您绑定的二级域名无效,请用(http://host)的形式", "-1");
  162. exit();
  163. }
  164. if (preg_match("#".$cfg_basehost."#i", $siteurl)) {
  165. ShowMsg("您绑定的二级域名与当前站点是同一个域,不需要绑定", "-1");
  166. exit();
  167. }
  168. }
  169. }
  170. //创建目录
  171. if ($ispart != 2) {
  172. $true_typedir = str_replace("{cmspath}", $cfg_cmspath, $typedir);
  173. $true_typedir = preg_replace("#\/{1,}#", "/", $true_typedir);
  174. if (!CreateDir($true_typedir)) {
  175. ShowMsg("创建目录 {$true_typedir} 失败,请检查您的路径是否存在问题", "-1");
  176. exit();
  177. }
  178. }
  179. $in_query = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,namegk,enname,ennamegk,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`)
  180. VALUES('$reid','$topid','$sortrank','$typename','$namegk','$enname','$ennamegk','$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')";
  181. if (!$dsql->ExecuteNoneQuery($in_query)) {
  182. ShowMsg("保存目录数据时失败,请检查您的输入资料是否存在问题", "-1");
  183. exit();
  184. }
  185. UpDateCatCache();
  186. if ($reid > 0) {
  187. PutCookie('lastCid', GetTopid($reid), 3600 * 24, '/');
  188. }
  189. ShowMsg("成功创建一个分类", "catalog_main.php");
  190. exit();
  191. }//End dopost==save
  192. //获取从父目录继承的默认参数
  193. if ($dopost == '') {
  194. $channelid = 1;
  195. $issend = 1;
  196. $corank = 0;
  197. $reid = 0;
  198. $topid = 0;
  199. $typedir = '';
  200. $moresite = 0;
  201. if ($id > 0) {
  202. $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 ");
  203. $channelid = $myrow['channeltype'];
  204. $issennd = $myrow['issend'];
  205. $corank = $myrow['corank'];
  206. $topid = $myrow['topid'];
  207. $typedir = $myrow['typedir'];
  208. }
  209. //父栏目是否为二级站点
  210. $moresite = empty($myrow['moresite']) ? 0 : $myrow['moresite'];
  211. }
  212. include DedeInclude('templets/catalog_add.htm');