温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:
PozhuCMS/admin/Categories/PropertyDefinitions.ascx.cs,打开代码结构图
PozhuCMS/admin/Categories/PropertyDefinitions.ascx.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.UI.Utilities; 12
using Pozhu.CMS.Categories; 13
using Pozhu.CMS; 14
using Pozhu.UI.WebControls; 15
using Pozhu.CMS.PropertyDefinitions; 16
using Pozhu.Sites; 17
using Pozhu.Common.Utilities; 18
using Pozhu.CMS.Documents; 19
using Pozhu.CMS.PropertyDefinitions.PropertyControls; 20
21
public partial class admin_Categories_PropertyDefinitions : System.Web.UI.UserControl 22
{ 23
protected override void CreateChildControls() 24
{ 25
BindPropertyCategories(); 26
} 27
28
public string Identify 29
{ 30
get 31
{ 32
if (ViewState["Identify"] == null) 33
throw new Exception("没有设定Identify的值"); 34
35
return ViewState["Identify"].ToString(); 36
} 37
set 38
{ 39
ViewState["Identify"] = value; 40
} 41
} 42
43
PropertyDefinitionControllerBase _pdController = null; 44
PropertyDefinitionControllerBase pdController 45
{ 46
get 47
{ 48
if (_pdController == null) 49
{ 50
if (Identify.ToLower() == "category") 51
{ 52
_pdController = new CategoryPropertyDefinitionController(); 53
} 54
else if (Identify.ToLower() == "document") 55
{ 56
_pdController = new DocumentPropertyDefinitionController(); 57
} 58
} 59
return _pdController; 60
} 61
} 62
63
ProfileBase _profile = null; 64
ProfileBase PropertyProfile 65
{ 66
get 67
{ 68
if (_profile == null) 69
{ 70
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 71
int siteID = SiteController.GetCurrentSite().SiteID; 72
Category category = CategoryController.GetCategory(siteID, path); 73
74
if (Identify.ToLower() == "category") 75
{ 76
if (Request.QueryString["action"].ToLower() == "edit") 77
{ 78
_profile = category.Profile; 79
} 80
81
if (_profile == null) 82
{ 83
_profile = new CategoryProfile(); 84
_profile.Initialise(category.CategoryID); 85
} 86
} 87
else if (Identify.ToLower() == "document") 88
{ 89
if (Request.QueryString["action"].ToLower() == "edit") 90
{ 91
int documentID = int.Parse(Request.QueryString["documentID"]); 92
Document document = DocumentController.GetDocument(category.CategoryID, documentID); 93
_profile = document.Profile; 94
} 95
96
if (_profile == null) 97
{ 98
_profile = new DocumentProfile(); ; 99
_profile.Initialise(category.CategoryID); 100
} 101
} 102
103
} 104
105
return _profile; 106
} 107
} 108
109
void BindPropertyCategories() 110
{ 111
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 112
int siteID = SiteController.GetCurrentSite().SiteID; 113
114
//获取当前栏目 115
Category c = CategoryController.GetCategory(siteID, path); 116
117
//邦定 118
PropertyCategoryCollection pcc = pdController.GetPropertyCategories(c.CategoryID); 119
PropertyCategoryCollection pccClone = (PropertyCategoryCollection)pcc.Clone(); 120
121
if (pdController.GetProperties(c.CategoryID, Null.NullInteger).Count > 0) 122
{ 123
// 124
PropertyCategory noCategory = new PropertyCategory(); 125
noCategory.CategoryID = c.CategoryID; 126
noCategory.PropertyCategoryID = Null.NullInteger; 127
noCategory.Title = "其他属性"; 128
pccClone.Add(noCategory); 129
} 130
131
// 132
this.rptPropertyCategories.DataSource = pccClone; 133
this.rptPropertyCategories.DataBind(); 134
} 135
136
protected void rptPropertyCategories_ItemDataBound(object sender, RepeaterItemEventArgs e) 137
{ 138
139
//邦定该分类下的属性 140
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 141
int siteID = SiteController.GetCurrentSite().SiteID; 142
143
//获取当前栏目 144
Category c = CategoryController.GetCategory(siteID, path); 145
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) 146
{ 147
WrappedRepeater rptProperties = (WrappedRepeater)e.Item.FindControl("rptProperties"); 148
rptProperties.DataSource = (PropertyDefinitionCollection)pdController.GetProperties(c.CategoryID, ((PropertyCategory)(e.Item.DataItem)).PropertyCategoryID).Clone(); 149
rptProperties.DataBind(); 150
} 151
} 152
153
protected void rptProperties_ItemDataBound(object sender, RepeaterItemEventArgs e) 154
{ 155
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) 156
{ 157
PropertyDefinition property = (PropertyDefinition)e.Item.DataItem; 158
PlaceHolder phControl = (PlaceHolder)e.Item.FindControl("phControl"); 159
PropertyControlSetting pcSetting = PropertyDefinitionControllerBase.GetPropertyControlSettingByPropertyID(property.PropertyDefinitionID); 160
// 161
if (pcSetting != null) 162
{ 163
PropertyControl pcControl = PropertyDefinitionControllerBase.GetPropertyControl(pcSetting.PropertyControlID); 164
165
PropertyControlBase propertyControl = Activator.CreateInstance(Type.GetType(pcControl.ControlClass), pcSetting.SettingXmlData, PropertyProfile.GetProperty(property.Name)) as PropertyControlBase; 166
phControl.Controls.Add(propertyControl); 167
} 168
else 169
{ 170
object value = PropertyProfile.GetPropertyValue(property.Name); 171
if (value != null) 172
{ 173
phControl.Controls.Add(new LiteralControl(value.ToString())); 174
} 175
else 176
{ 177
phControl.Controls.Add(new LiteralControl("<span style=\"color:red;\">没有设置控件!</span>")); 178
} 179
} 180
} 181
} 182
} 183





}
}