-
Notifications
You must be signed in to change notification settings - Fork 1
/
articlescatalogue.php
167 lines (165 loc) · 5.21 KB
/
articlescatalogue.php
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
<?php
error_reporting(0);
//演示数据
$catalogue = array(
0=>array(
'id'=>1,
'name'=>'webscript',
'title'=>'网页编程语言',
'subclasses'=>array(
0=>array(
'id'=>4,
'name'=>'php',
'title'=>'php语言',
'subclasses'=>array()
),
1=>array(
'id'=>5,
'name'=>'asp',
'title'=>'asp语言',
'subclasses'=>array()
),
2=>array(
'id'=>6,
'name'=>'javascript',
'title'=>'javascript语言',
'subclasses'=>array(
0=>array(
'id'=>7,
'name'=>'jQuery',
'title'=>'jQuery框架',
'subclasses'=>array()
),
)
),
)
),
1=>array(
'id'=>2,
'name'=>'os',
'title'=>'操作系统'
),
2=>array(
'id'=>3,
'name'=>'others',
'title'=>'其它'
),
);
$table=getListString($catalogue);
//获取无限级分类表格
function getListString($catalogue,$tab=NULL){
foreach($catalogue as $row){
$action="<span articleid=$row[id] articletitle=$row[title] class='ui-icon ui-icon-trash' title='删除'></span><span articleid=$row[id] articletitle=$row[title] title='修改' class='ui-icon ui-icon-wrench'></span><span articleid=$row[id] articletitle=$row[title] title='分配权限' class='ui-icon ui-icon-key'></span>";
$action.="<span articleid=$row[id] articletitle=$row[title] class='ui-icon ui-icon-trash' title='添加子分类'></span>";
$string.=<<< STRING
<tr>
<td>$tab$row[title]</td>
<td>$row[name]</td>
<td>$action</td>
</tr>
STRING;
if(!empty($row['subclasses'])){
$tab.=' |-- ';
$string.=getListString($row['subclasses'],$tab);
$tab=NULL;
}
}
return $string;
}
?>
<script type="text/javascript">
$(function(){
$('#dialog').dialog('destroy');
//删除确认
$('.ui-icon-trash').bind('click',function(){
if(confirm('确定要删除'+$(this).attr('articletitle')+'吗?')){
alert($(this).attr('articletitle')+'删除成功');
}
});
bindModify();
bindResource();
});
//修改分类
function bindModify(){
var doSubmit=function(){
panelId=$('#panelId').attr('value');
formId='#articleedit';
var options={
target:panelId
};
$(formId).ajaxSubmit(options);//dialog弹出表单暂不支持表单验证
$('#dialog').dialog('close');
};
var doCancel=function(){
$('#dialog').dialog('close');
};
$('.ui-icon-wrench').click(function(){
$('#dialog').load('articlecatalogueedit.php?id='+$(this).attr('articleid'));
var dialogOpts={
title:'修改文章分类',
modal:true,
buttons:{
'取消':doCancel,
'修改':doSubmit
},
height:450,
width:350,
top:100
}
$('#dialog').dialog(dialogOpts);
});
}
//修改分类
function bindResource(){
var doSubmit=function(){
panelId=$('#panelId').attr('value');
formId='#articleedit';
var options={
target:panelId
};
$(formId).ajaxSubmit(options);//dialog弹出表单暂不支持表单验证
$('#dialog').dialog('close');
};
var doCancel=function(){
$('#dialog').dialog('close');
};
$('.ui-icon-key').click(function(){
$('#dialog').load('articlesresourcelevel.php?id='+$(this).attr('articleid'));
var dialogOpts={
title:'分配文章分类权限',
modal:true,
buttons:{
'取消':doCancel,
'修改':doSubmit
},
height:450,
width:350,
top:100
}
$('#dialog').dialog(dialogOpts);
});
}
</script>
<fieldset>
<legend>文章分类管理</legend>
<table class="sl-table">
<thead>
<tr><td>分类标题</td><td>分类名称</td><td>操作</td></tr>
</thead>
<tbody>
<?=$table?>
</tbody>
</table>
</fieldset>
<br/>
<fieldset>
<legend>添加顶级分类</legend>
<form id="form-articlescatalogue" name="form-articlescatalogue" method="POST" action="articlescatalogue.php">
<input name="formId" type="hidden" value="form-addAddress"/>
<ul id="sl-addAddress" class="sl-table">
<li><label>分类名称(英文字符)</label><input type="text" name="name" class="required"/></li>
<li><label>分类标题</label><input type="text" name="title" class="required"/></li>
<li><label> </label><input type="submit" id="addAddress-submit" name="addAddress-subimt" value="添加"/></li>
</ul>
</form>
</fieldset>