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

  1. <?php
  2. /**
  3. * @version $Id: story_catalog.php 1 9:02 2010年9月25日Z 蓝色随想 $
  4. * @package DedeCMS.Module.Book
  5. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  6. * @license http://help.dedecms.com/usersguide/license.html
  7. * @link http://www.dedecms.com
  8. */
  9. require_once(dirname(__FILE__). "/config.php");
  10. CheckPurview('story_Catalog');
  11. if(!isset($action)) $action = '';
  12. if(!isset($stypes)) $stypes = '';
  13. //统计图书数量
  14. function TjBookNum($cid,&$dsql)
  15. {
  16. $row = $dsql->GetOne("SELECT count(bid) AS dd FROM #@__story_books WHERE catid='$cid' OR bcatid='$cid' ");
  17. return $row['dd'];
  18. }
  19. //增加栏目
  20. /*
  21. function SaveNew();
  22. */
  23. if($action=='add')
  24. {
  25. $inQuery = "INSERT INTO #@__story_catalog(classname,pid,rank,listrule,viewrule,booktype,keywords,description)
  26. VALUES('$classname','$pid','$rank','','','$booktype','$keywords','$description')";
  27. $rs = $dsql->ExecuteNoneQuery($inQuery);
  28. if($rs)
  29. {
  30. $msg = "成功增加一个栏目:{$classname} !";
  31. }
  32. else
  33. {
  34. $msg = "增加栏目时失败:{$classname} !";
  35. }
  36. }
  37. //保存修改
  38. /*
  39. function SaveEdit();
  40. */
  41. else if($action=='editsave')
  42. {
  43. $inQuery = "UPDATE #@__story_catalog SET
  44. classname='$classname',pid='$pid',rank='$rank',booktype='$booktype',
  45. keywords='$keywords',description='$description'
  46. WHERE id='$catid' ";
  47. $dsql->ExecuteNoneQuery($inQuery);
  48. $msg = "成功修改栏目:{$catid} = {$classname} !";
  49. if(isset($ranks[$catid]))
  50. {
  51. $ranks[$catid] = $rank;
  52. }
  53. if(isset($btypes[$catid]))
  54. {
  55. $btypes[$catid] = $classname;
  56. }
  57. else
  58. {
  59. if(is_array($stypes))
  60. {
  61. foreach($stypes as $kk=>$vv)
  62. {
  63. if(isset($vv[$catid]))
  64. {
  65. $stypes[$kk][$catid] = $classname;
  66. break;
  67. }
  68. }
  69. }
  70. }
  71. }
  72. //删除栏目
  73. /*---------------------
  74. function DelCatalog()
  75. -----------------------*/
  76. else if($action=='del')
  77. {
  78. $dsql->SetQuery("SELECT id FROM #@__story_catalog WHERE pid='{$catid}' ");
  79. $dsql->Execute();
  80. $ids = $catid;
  81. while($row = $dsql->GetArray())
  82. {
  83. $ids .= ','.$row['id'];
  84. }
  85. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_books WHERE catid in ($ids) ");
  86. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_chapter WHERE catid in ($ids) ");
  87. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_content WHERE catid in ($ids) ");
  88. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_catalog WHERE id in ($ids) ");
  89. $msg = "删除栏目:{$catid} !OK";
  90. }
  91. //更新排序
  92. /*---------------------
  93. function UpRanks();
  94. -----------------------*/
  95. else if($action=='uprank')
  96. {
  97. foreach($_POST as $rk=>$rv)
  98. {
  99. if(ereg('rank',$rk))
  100. {
  101. $catid = str_replace('rank_','',$rk);
  102. $dsql->ExecuteNoneQuery("UPDATE #@__story_catalog SET rank='{$rv}' WHERE id='$catid' ");
  103. $ranks[$catid] = $rv;
  104. }
  105. }
  106. ShowMsg("成功更新排序!","story_catalog.php");
  107. exit();
  108. }
  109. //读取所有栏目
  110. $dsql->SetQuery("SELECT id,classname,pid,rank FROM #@__story_catalog ORDER BY rank ASC");
  111. $dsql->Execute();
  112. $ranks = Array();
  113. $btypes = Array();
  114. $stypes = Array();
  115. while($row = $dsql->GetArray())
  116. {
  117. if($row['pid']==0)
  118. {
  119. $btypes[$row['id']] = $row['classname'];
  120. }
  121. else
  122. {
  123. $stypes[$row['pid']][$row['id']] = $row['classname'];
  124. }
  125. $ranks[$row['id']] = $row['rank'];
  126. }
  127. $lastid = $row['id'];
  128. $msg = '';
  129. //载入栏目(用于修改,Ajax模式载入)
  130. /*
  131. function LoadEdit();
  132. */
  133. if($action=='editload')
  134. {
  135. $row = $dsql->GetOne("SELECT * FROM #@__story_catalog WHERE id='$catid'");
  136. AjaxHead();
  137. ?>
  138. <form name='editform' action='story_catalog.php' method='get'>
  139. <input type='hidden' name='action' value='editsave' />
  140. <input type='hidden' name='catid' value='<?php echo $catid; ?>' />
  141. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  142. <tr>
  143. <td width="90" height="28">栏目名称:</td>
  144. <td width="101"><input name="classname" type="text" id="classname" value="<?php echo $row['classname']; ?>" /></td>
  145. <td width="20" align="right" valign="top"><a href="javascript:CloseEditCatalog()"><img src="images/close.gif" width="12" height="12" border="0" /></a></td>
  146. </tr>
  147. <tr>
  148. <td height="28">隶属栏目:</td>
  149. <td colspan="2">
  150. <select name="pid" id="pid">
  151. <option value="0">顶级栏目</option>
  152. <?php
  153. foreach($btypes as $k=>$v)
  154. {
  155. if($row['pid']==$k)
  156. {
  157. echo "<option value='$k' selected>{$v}</option>\r\n";
  158. }
  159. elseif($v != $row['classname'])
  160. {
  161. echo "<option value='$k'>{$v}</option>\r\n";
  162. }
  163. }
  164. ?>
  165. </select>
  166. </td>
  167. </tr>
  168. <tr>
  169. <td height="28">排序级别:</td>
  170. <td colspan="2"><input name="rank" type="text" id="rank" size="5" value="<?php echo $row['rank']; ?>" />
  171. (数值小靠前)</td>
  172. </tr>
  173. <tr>
  174. <td height="28">连载类型:</td>
  175. <td colspan="2">
  176. <input name="booktype" type="radio" value="0"<?php if($row['booktype']==0) echo " checked='checked'";?> />
  177. 小说
  178. <input type="radio" name="booktype" value="1" <?php if($row['booktype']==1) echo " checked='checked'";?> />
  179. 漫画
  180. </td>
  181. </tr>
  182. <tr>
  183. <td height="28">关键字:</td>
  184. <td colspan="2"><input name="keywords" type="text" id="keywords" value="<?php echo $row['keywords']; ?>" /></td>
  185. </tr>
  186. <tr>
  187. <td>摘 要:</td>
  188. <td colspan="2">
  189. <textarea name="description" id="description" style="width:180px;height:45px"><?php echo $row['description']; ?></textarea>
  190. </td>
  191. </tr>
  192. <tr>
  193. <td height="43">&nbsp;</td>
  194. <td colspan="2"><input type="submit" name="Submit" value="保存更改" style="width:80px"/></td>
  195. </tr>
  196. </table>
  197. </form>
  198. <?php
  199. exit();
  200. }
  201. require_once(dirname(__FILE__). "/templets/story_catalog.htm");