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