温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:
PozhuCMS/admin/Categories/CategoryList.aspx.cs,打开代码结构图
PozhuCMS/admin/Categories/CategoryList.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using Pozhu.CMS.Categories; 12
using Pozhu.CMS; 13
using Pozhu.UI.Utilities; 14
using Pozhu.Sites; 15
using Pozhu.CMS.Documents; 16
using Pozhu.CMS.Common.Utilities; 17
using Pozhu.Services.Personalization; 18
using Pozhu.UI.WebControls; 19
using Pozhu.CMS.Web; 20
using Pozhu.CMS.Rates; 21
22
public partial class admin_Categories_CategoryList : AdminPageBase 23
{ 24
25
protected override bool IsAuthenticated() 26
{ 27
if (base.IsAuthenticated()) 28
return true; 29
30
if (base.IsEditor()) 31
return true; 32
33
return false; 34
} 35
36
protected void Page_Load(object sender, EventArgs e) 37
{ 38
//分页 39
setPageIndex(); 40
41
if (!Page.IsPostBack) 42
{ 43
// 44
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 45
int siteID = this.CurrentSite.SiteID; 46
Category category = CategoryController.GetCategory(siteID, path); 47
48
//添加栏目的权限验证 49
if (category.IsAuthorization(CategoryController.PermissionCreateCategory)) 50
{ 51
hlkCreateCategory.NavigateUrl = Pozhu.Common.Globals.ApplicationPath + "/admin/path" + path + "editCategory.aspx?action=add"; 52
hlkCreateCategory.Enabled = true; 53
} 54
else 55
{ 56
hlkCreateCategory.Enabled = false; 57
} 58
//添加文档的权限验证 59
if (category.IsAuthorization(CategoryController.PermissionCreateDocument)) 60
{ 61
this.hlkCreateDocument.NavigateUrl = Pozhu.Common.Globals.ApplicationPath + "/admin/path" + path + "editDocument.aspx?action=add"; 62
hlkCreateDocument.Enabled = true; 63
} 64
else 65
{ 66
hlkCreateDocument.Enabled = false; 67
} 68
//添加文档的权限验证 69
if (category.IsAuthorization(CategoryController.PermissionDeleteDocument)) 70
{ 71
lbtnDelete.Visible = true; 72
} 73
else 74
{ 75
lbtnDelete.Visible = false; 76
} 77
78
// 79
bool includeChildDocuments = Convert.ToBoolean(Personalization.GetProfile("IncludeChildDocuments", category.CategoryID.ToString())); 80
if (includeChildDocuments) 81
{ 82
lbtnIncludeChildDocuments.CommandArgument = "true"; 83
lbtnIncludeChildDocuments.CssClass = "checked"; 84
lbtnIncludeChildDocuments.Text = "不包含子栏目的文档"; 85
} 86
else 87
{ 88
lbtnIncludeChildDocuments.CommandArgument = "false"; 89
lbtnIncludeChildDocuments.CssClass = "unchecked"; 90
lbtnIncludeChildDocuments.Text = "包含子栏目的文档"; 91
} 92
93
94
// 95
if (Request.QueryString["relationID"] != null) 96
{ 97
//隐藏栏目列表 98
rptCategories.Visible = false; 99
// 100
lbtnIncludeChildDocuments.Visible = false; 101
// 102
hlkGotoPrimaryCategory.Visible = true; 103
104
if (Request.QueryString["PrimaryDocumentID"] != null) 105
{ 106
hlkAddDocument.NavigateUrl = Pozhu.Common.Globals.ApplicationPath + "/admin/path" + CategoryController.GetCategory(category.GetRelation(int.Parse(Request.QueryString["relationID"])).ChildID).Path + "editDocument.aspx?action=add&PrimaryCategoryID=" + Request.QueryString["PrimaryCategoryID"] + "&PrimaryDocumentID=" + Request.QueryString["PrimaryDocumentID"] + "&relationID=" + Request.QueryString["relationID"]; 107
} 108
else 109
{ 110
hlkAddDocument.NavigateUrl = Pozhu.Common.Globals.ApplicationPath + "/admin/path" + CategoryController.GetCategory(category.GetRelation(int.Parse(Request.QueryString["relationID"])).ChildID).Path + "editDocument.aspx?action=add&PrimaryCategoryID=" + Request.QueryString["PrimaryCategoryID"] + "&relationID=" + Request.QueryString["relationID"]; 111
} 112
113
} 114
else if (Request.QueryString["typeID"] != null) 115
{ 116
//隐藏栏目列表 117
rptCategories.Visible = false; 118
// 119
lbtnIncludeChildDocuments.Visible = false; 120
// 121
hlkGotoPrimaryCategory.Visible = false; 122
// 123
hlkAddDocument.Visible = false; 124
125
126
} 127
else 128
{ 129
//邦定栏目 130
this.BindCategory(); 131
132
// 是否包含子栏目下的文档 133
if (!CategoryController.GetCategory(siteID, path).HasChild) 134
{ 135
lbtnIncludeChildDocuments.Visible = false; 136
} 137
138
// 139
hlkGotoPrimaryCategory.Visible = false; 140
// 141
hlkAddDocument.Visible = false; 142
} 143
144
// 145
hlkGotoPrimaryCategory.NavigateUrl = Pozhu.Common.Globals.ApplicationPath + "/admin/path" + path + "categoryList.aspx"; 146
147
//邦定文档 148
this.BindDocument(); 149
150
// 151
if (rptDocuments.Items.Count == 0) 152
{ 153
lbtnDelete.Enabled = false; 154
} 155
else 156
{ 157
lbtnDelete.Enabled = true; 158
ClientAPI.AddButtonConfirm(lbtnDelete, "确定删除选中的文档吗?"); 159
} 160
161
//关联 162
Relations(); 163
} 164
} 165
166
// 167
168
void BindCategory() 169
{ 170
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 171
int siteID = SiteController.GetCurrentSite().SiteID; 172
CategoryCollection categories = CategoryController.GetChildCategories(siteID,path); 173
174
rptCategories.DataSource = categories; 175
rptCategories.DataBind(); 176
177
} 178
179
void BindDocument() 180
{ 181
//文档记录 182
DocumentSet ds =null; 183
184
if (Request.QueryString["relationID"] != null) 185
{ 186
int relationID = Convert.ToInt32(Request.QueryString["relationID"]); 187
if (Request.QueryString["PrimaryDocumentID"] != null) 188
{ 189
int primaryDocumentID = Convert.ToInt32(Request.QueryString["PrimaryDocumentID"]); 190
int primaryCategoryID = Convert.ToInt32(Request.QueryString["PrimaryCategoryID"]); 191
Document parimaryDocument = DocumentController.GetDocument(primaryCategoryID, primaryDocumentID); 192
193
ds = parimaryDocument.GetRelationDocuments(relationID, nlpPager.PageIndex, nlpPager.PageSize,true); 194
195
//关联文档 196
this.rptDocuments.DataSource = ds.Documents; 197
this.rptDocuments.DataBind(); 198
} 199
else if (Request.QueryString["PrimaryCategoryID"] != null) 200
{ 201
Category primaryCategory = null; 202
int primaryCategoryID = Convert.ToInt32(Request.QueryString["PrimaryCategoryID"]); 203
primaryCategory = CategoryController.GetCategory(primaryCategoryID); 204
205
206
ds = primaryCategory.GetRelationDocuments(relationID, nlpPager.PageIndex, nlpPager.PageSize,true); 207
208
//关联文档 209
this.rptDocuments.DataSource = ds.Documents; 210
this.rptDocuments.DataBind(); 211
} 212
} 213
else if (Request.QueryString["typeID"] != null) 214
{ 215
int typeID = int.Parse(Request.QueryString["typeID"]); 216
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 217
SiteInfo site = SiteController.GetCurrentSite(); 218
Category category = CategoryController.GetCategory(site.SiteID, path); 219
ds = DocumentController.GetDocuments(category.CategoryID, nlpPager.PageIndex, nlpPager.PageSize, typeID,true); 220
221
//邦定 222
this.rptDocuments.DataSource = ds.Documents; 223
this.rptDocuments.DataBind(); 224
225
} 226
else 227
{ 228
bool boolChecked = bool.Parse(lbtnIncludeChildDocuments.CommandArgument); 229
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 230
SiteInfo site = SiteController.GetCurrentSite(); 231
Category category = CategoryController.GetCategory(site.SiteID, path); 232
ds = DocumentController.GetDocuments(category.CategoryID, nlpPager.PageIndex, nlpPager.PageSize, boolChecked,true); 233
234
//邦定 235
this.rptDocuments.DataSource = ds.Documents; 236
this.rptDocuments.DataBind(); 237
} 238
239
//分页控件 240
nlpPager.TotalRecords = ds.TotalRecords; 241
} 242
243
void Relations() 244
{ 245
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 246
SiteInfo site = SiteController.GetCurrentSite(); 247
Category category = CategoryController.GetCategory(site.SiteID, path); 248
CategoryRelationCollection relations = category.GetRelations(); 249
if (relations.Count > 0) 250
{ 251
rptCategoryRelations.DataSource = relations; 252
rptCategoryRelations.DataBind(); 253
} 254
else 255
{ 256
rptCategoryRelations.Visible = false; 257
} 258
} 259
260
void setPageIndex() 261
{ 262
if (Request.QueryString["currentPage"] != null) 263
{ 264
nlpPager.CurrentPage = int.Parse(Request.QueryString["currentPage"]); 265
} 266
else 267
{ 268
nlpPager.CurrentPage = 1; 269
} 270
} 271
272
protected void rptCategories_ItemCommand(object source, RepeaterCommandEventArgs e) 273
{ 274
string commandName = e.CommandName; 275
Literal ltlPath = (Literal)e.Item.FindControl("ltlPath"); 276
277
int siteID = SiteController.GetCurrentSite().SiteID; 278
Category c = CategoryController.GetCategory(siteID,ltlPath.Text); 279
280
if (commandName == "delete") 281
{ 282
CategoryController.DeleteCategory(c.SiteID,c.Path); 283
// 284
BindCategory(); 285
286
// 287
BindDocument(); 288
} 289
else if (commandName == "up") 290
{ 291
CategoryController.UpdateCategorySortOrder(c.SiteID, c.Path, MoveOrder.Up); 292
// 293
BindCategory(); 294
} 295
else if (commandName == "down") 296
{ 297
CategoryController.UpdateCategorySortOrder(c.SiteID, c.Path, MoveOrder.Down); 298
// 299
BindCategory(); 300
} 301
} 302
protected void rptCategories_ItemDataBound(object sender, RepeaterItemEventArgs e) 303
{ 304
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) 305
{ 306
Category category = (Category)e.Item.DataItem; 307
LinkButton lbtnDelete = (LinkButton)e.Item.FindControl("lbtnDelete"





}