17 using System.Runtime.CompilerServices;
19 using erminas.SmartAPI.Exceptions;
20 using erminas.SmartAPI.Utils;
21 using erminas.SmartAPI.Utils.CachedCollections;
23 namespace erminas.SmartAPI.CMS.Project.ContentClasses
27 string BorderColor {
get;
set; }
29 string BorderStyle {
get;
set; }
31 string BorderWidth {
get;
set; }
35 bool IsUsingBorderDefinitionFromProjectSetting {
get;
set; }
37 bool IsUsingBordersToHighlightPages {
get;
set; }
43 internal class CCEditableAreaSettings : AbstractAttributeContainer, IContentClassEditableAreaSettings
45 private readonly IContentClass _parent;
47 internal CCEditableAreaSettings(IContentClass parent) : base(parent.Session)
52 [RedDot(
"bordercolor")]
53 public string BorderColor
55 get {
return GetAttributeValue<string>(); }
56 set { SetAttributeValue(value); }
59 [RedDot(
"borderstyle")]
60 public string BorderStyle
64 EnsureInitialization();
65 return GetAttributeValue<string>();
67 set { SetAttributeValue(value); }
70 [RedDot(
"borderwidth")]
71 public string BorderWidth
75 EnsureInitialization();
76 return GetAttributeValue<string>();
80 EnsureInitialization();
81 SetAttributeValue(value);
87 EnsureInitialization();
88 const string SAVE_CC_SETTINGS =
@"<TEMPLATE guid=""{0}"">{1}</TEMPLATE>";
89 var query = SAVE_CC_SETTINGS.RQLFormat(_parent, RedDotObject.GetSaveString(_readWriteWrapper.MergedElement));
91 var result = _parent.Project.ExecuteRQL(query,
RqlType.SessionKeyInProject);
93 if (result.GetElementsByTagName(
"SETTINGS").Count != 1)
96 String.Format(
"Could not save settings for content class {0}", _parent));
100 public void InvalidateCache()
105 [RedDot(
"usedefaultrangesettings")]
106 public bool IsUsingBorderDefinitionFromProjectSetting
108 get {
return GetAttributeValue<bool>(); }
109 set { SetAttributeValue(value); }
112 [RedDot(
"showpagerange")]
113 public bool IsUsingBordersToHighlightPages
115 get {
return GetAttributeValue<bool>(); }
116 set { SetAttributeValue(value); }
119 public IProject Project
121 get {
return _parent.Project; }
124 public void Refresh()
127 XmlElement = RetrieveWholeObject();
130 public override XmlElement XmlElement
132 get {
return base.XmlElement ?? (XmlElement = RetrieveWholeObject()); }
133 protected internal set { base.XmlElement = value; }
136 protected override T GetAttributeValue<T>([CallerMemberName]
string callerName =
"")
138 EnsureInitialization();
139 return base.GetAttributeValue<T>(callerName);
142 protected override void SetAttributeValue<T>(T value, [CallerMemberName]
string callerName =
"")
144 EnsureInitialization();
145 base.SetAttributeValue(value, callerName);
148 private void EnsureInitialization()
150 if (_readWriteWrapper == null)
156 private XmlElement RetrieveWholeObject()
158 const string LOAD_CC_SETTINGS =
@"<TEMPLATE guid=""{0}""><SETTINGS action=""load""/></TEMPLATE>";
159 var xmlDoc = _parent.Project.ExecuteRQL(LOAD_CC_SETTINGS.RQLFormat(_parent));
160 var node = xmlDoc.GetSingleElement(
"SETTINGS");
164 String.Format(
"Could not load settings for content class {0}", _parent));