group_store.php
3.86 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
<?php
/**
* 圈子分类设置
*
* @version $Id: group_store.php 1 15:34 2011-1-21 tianya $
* @package DedeCMS.Administrator
* @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('group_Store');
require_once(DEDEINC.'/datalistcp.class.php');
setcookie("ENV_GOBACK_URL",$dedeNowurl,time()+3600,"/");
$id = isset($id) && is_numeric($id) ? $id : 0;
$action = isset($action) ? trim($action) : '';
if($action=="add")
{
$storename = cn_substrR(HtmlReplace($storename, 2),20);
$tops = preg_replace("#[^0-9]#","",$tops);
$orders = preg_replace("#[^0-9]#","",$orders);
if($tops < 1)
{
$tops = 0;
}
if($orders < 1)
{
$orders = 0;
}
if(empty($storename))
{
$msg = "错误,分类名不能为空!";
}
else
{
$db->ExecuteNoneQuery("INSERT INTO #@__store_groups(storename,tops,orders) VALUES('".$storename."','".$tops."','".$orders."');");
$msg = "成功添加分类";
}
}
else if($action=="del"&&isset($id))
{
$db->ExecuteNoneQuery("DELETE FROM #@__store_groups WHERE storeid='$id'");
$msg = "删除分类:{$id} !";
}
$btypes = array();
$db->SetQuery("SELECT * FROM #@__store_groups WHERE tops=0");
$db->Execute();
$options = '';
while($rs = $db->GetArray())
{
array_push ($btypes,$rs);
}
foreach($btypes as $k=>$v)
{
$options .= "<option value='".$v['storeid']."'>".$v['storename']."</option>\r\n";
}
/*
function LoadEdit();
*/
if($action=='editload')
{
$row = $db->GetOne("Select * From #@__store_groups where storeid='$catid'");
AjaxHead();
?>
<form name='editform' action='group_store.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="storename" type="text" id="storename" value="<?php echo $row['storename']; ?>" /></td>
<td width="20" align="right" valign="top"></td>
</tr>
<tr>
<td height="28">隶属栏目:</td>
<td colspan="2">
<select name="tops" id="tops">
<option value="0">顶级栏目</option>
<?php
foreach($btypes as $k=>$v)
{
if($row['tops']==$v['storeid'])
{
echo "<option value='".$v['storeid']."' selected>".$v['storename']."</option>\r\n";
}
else
{
echo "<option value='".$v['storeid']."'>".$v['storename']."</option>\r\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td height="28">排序级别:</td>
<td colspan="2"><input name="orders" type="text" id="orders" size="5" value="<?php echo $row['orders']; ?>" />
(数值小靠前)</td>
</tr>
<tr>
<td height="43"> </td>
<td colspan="2"><input type="submit" name="Submit" value="保存更改" class="np coolbg" style="width:80px"/></td>
</tr>
</table>
</form>
<?php
exit();
}
else if($action=='editsave')
{
$db->ExecuteNoneQuery("UPDATE #@__store_groups SET storename='$storename',tops='$tops',orders='$orders' WHERE storeid='$catid'");
$msg = "成功修改栏目:{$catid} = {$storename} !";
}
else if($action=='uprank')
{
foreach($_POST as $rk=>$rv)
{
if(preg_match('#rank#i',$rk))
{
$catid = str_replace('rank_','',$rk);
$db->ExecuteNoneQuery("UPDATE #@__store_groups SET orders='{$rv}' WHERE storeid='{$catid}'");
}
}
$msg = "成功更改排序 !";
}
$sql = "SELECT storeid,storename,tops,orders FROM #@__store_groups WHERE tops=0 ORDER BY orders ASC";
$dl = new DataListCP();
$dl->pageSize = 20;
//这两句的顺序不能更换
$dl->SetTemplate(DEDEADMIN."/templets/group_store.htm"); //载入模板
$dl->SetSource($sql); //设定查询SQL
$dl->Display(); //显示
?>