19 using erminas.SmartAPI.Exceptions;
20 using erminas.SmartAPI.Utils;
22 namespace erminas.SmartAPI.CMS.Project.Publication
30 string ContentGroup {
get;
set; }
33 string ContextTags {
get;
set; }
34 void CreateInProject(
IProject project, Guid parentFolderGuid);
35 bool DoCreateLog {
get;
set; }
36 bool DoIndexForFulltextSearch {
get;
set; }
37 bool DoReleaseAfterImport {
get;
set; }
38 bool DoReplaceExistingContent {
get;
set; }
39 bool DoReplaceGroupAssignment {
get;
set; }
40 bool IsPublishedPagesFolder {
get; }
41 string RealName {
get;
set; }
42 string RealVirtualName {
get;
set; }
44 string VirtualName {
get;
set; }
47 internal class PublicationFolder : PartialRedDotProjectObject, IPublicationFolder
49 public static readonly Guid ROOT_LEVEL_GUID = Guid.Parse(
"9BBF210F7923406291BE7AE47B4CA571");
50 public static readonly Guid PUBLISHED_PAGES_GUID;
51 private static readonly XmlElement PUBLISHED_PAGES_NODE;
52 private string _contentgroup;
55 private string _contexttags;
56 private bool _doArchivePreviousVersion;
57 private bool _doCreateLog;
58 private bool _doIgnoreMetadata;
59 private bool _doIndexing;
60 private bool _doOverwriteContent;
61 private bool _doOverwriteGroupAssignment;
62 private bool _doReleasePublishedFiles;
63 private string _inlineFunctionName;
64 private string _prefix;
65 private string _realName;
66 private string _realVirtualName;
67 private string _script;
69 private bool _usePrefix;
70 private string _virtualName;
72 static PublicationFolder()
74 var doc =
new XmlDocument();
75 PUBLISHED_PAGES_NODE = doc.CreateElement(
"EXPORTFOLDER");
76 const string PUBLISHED_PAGES_GUID_STRING =
"00000000000000000000000000000100";
77 PUBLISHED_PAGES_GUID = Guid.Parse(PUBLISHED_PAGES_GUID_STRING);
78 PUBLISHED_PAGES_NODE.SetAttributeValue(
"name",
"Published pages");
79 PUBLISHED_PAGES_NODE.SetAttributeValue(
"guid", PUBLISHED_PAGES_GUID_STRING);
89 public PublicationFolder(IProject project, Guid guid) : base(project, guid)
96 const string SAVE_STRING =
97 @"<PROJECT><EXPORTFOLDER action=""save"" guid=""{0}"" type=""{1}"" name=""{2}"" {3} /></PROJECT>";
100 Project.ExecuteRQL(
string.Format(SAVE_STRING, Guid.ToRQLString(), ((int) _type), Name, SaveParameters()));
102 if (reply.GetElementsByTagName(
"EXPORTFOLDER").Count != 1)
105 string.Format(
"Could not save publication folder {0}",
this));
109 public string ContentGroup
111 get {
return LazyLoad(ref _contentgroup); }
112 set { _contentgroup = value; }
117 get {
return LazyLoad(ref _contenttype); }
118 set { _contenttype = value; }
123 get {
return LazyLoad(ref _contextInfoPreparationType); }
124 set { _contextInfoPreparationType = value; }
127 public string ContextTags
129 get {
return LazyLoad(ref _contexttags); }
130 set { _contexttags = value; }
133 public void CreateInProject(IProject project, Guid parentFolderGuid)
135 const string CREATE_STRING =
136 @"<PROJECT><EXPORTFOLDER action=""assign"" guid=""{0}""><EXPORTFOLDER action=""addnew"" name=""{1}"" type=""{2}"" {3} /></EXPORTFOLDER></PROJECT>";
139 project.ExecuteRQL(
string.Format(CREATE_STRING, parentFolderGuid.ToRQLString(), Name, ((int) _type),
142 reply.GetElementsByTagName(
"EXPORTFOLDER");
147 const string DELETE =
@"<PROJECT><EXPORTFOLDER action=""delete"" guid=""{0}""/> </PROJECT>";
148 Project.ExecuteRQL(
string.Format(DELETE, Guid.ToRQLString()));
152 public bool DoCreateLog
154 get {
return LazyLoad(ref _doCreateLog); }
155 set { _doCreateLog = value; }
158 public bool DoIndexForFulltextSearch
160 get {
return LazyLoad(ref _doIndexing); }
161 set { _doIndexing = value; }
164 public bool DoReleaseAfterImport
166 get {
return LazyLoad(ref _doReleasePublishedFiles); }
167 set { _doReleasePublishedFiles = value; }
170 public bool DoReplaceExistingContent
172 get {
return LazyLoad(ref _doOverwriteContent); }
173 set { _doOverwriteContent = value; }
176 public bool DoReplaceGroupAssignment
178 get {
return LazyLoad(ref _doOverwriteGroupAssignment); }
179 set { _doOverwriteGroupAssignment = value; }
182 public bool IsPublishedPagesFolder
184 get {
return Guid == PUBLISHED_PAGES_GUID; }
187 public string RealName
189 get {
return LazyLoad(ref _realName); }
190 set { _realName = value; }
193 public string RealVirtualName
195 get {
return LazyLoad(ref _realVirtualName); }
196 set { _realVirtualName = value; }
199 public override ISession Session
201 get {
return Project != null ? Project.Session : null; }
206 get {
return LazyLoad(ref _type); }
207 set { _type = value; }
210 public string VirtualName
212 get {
return LazyLoad(ref _virtualName); }
213 set { _virtualName = value; }
216 protected override void LoadWholeObject()
221 protected override XmlElement RetrieveWholeObject()
223 if (Guid != PUBLISHED_PAGES_GUID)
225 const string LOAD_PUBLICATION_FOLDER =
226 @"<PROJECT><EXPORTFOLDER action=""load"" guid=""{0}""/></PROJECT>";
230 Project.ExecuteRQL(
string.Format(LOAD_PUBLICATION_FOLDER, Guid.ToRQLString()))
231 .GetElementsByTagName(
"EXPORTFOLDER")[0];
234 return PUBLISHED_PAGES_NODE;
237 private static string BoolToString(
bool value)
239 return value ?
"1" :
"0";
242 private void LoadXml()
244 if (Guid == PUBLISHED_PAGES_GUID)
248 EnsuredInit(ref _realName,
"realname", x => x ??
"");
251 InitIfPresent(ref _realVirtualName,
"realvirtualname", x => x ??
"");
252 InitIfPresent(ref _virtualName,
"virtualname", x => x ??
"");
255 InitIfPresent(ref _contentgroup,
"contentgroup", x => x);
256 EnsuredInit(ref _contenttype,
"contenttype",
258 InitIfPresent(ref _contexttags,
"contexttags", x => x);
259 InitIfPresent(ref _contextInfoPreparationType,
"contextinfo",
263 EnsuredInit(ref _doArchivePreviousVersion,
"flag_archive_prev_version", BoolConvert);
264 InitIfPresent(ref _doCreateLog,
"flag_create_log", BoolConvert);
265 InitIfPresent(ref _doIndexing,
"flag_indexing", BoolConvert);
266 InitIfPresent(ref _doOverwriteContent,
"flag_overwrite_content", BoolConvert);
267 InitIfPresent(ref _doOverwriteGroupAssignment,
"flag_overwrite_group_assignment", BoolConvert);
268 InitIfPresent(ref _doReleasePublishedFiles,
"flag_set_final", BoolConvert);
269 InitIfPresent(ref _doIgnoreMetadata,
"ignore_metadata", BoolConvert);
270 InitIfPresent(ref _inlineFunctionName,
"inlinefunctionname", x => x);
271 InitIfPresent(ref _prefix,
"prefix", x => x);
272 InitIfPresent(ref _script,
"script", x => x);
273 InitIfPresent(ref _usePrefix,
"useprefix", BoolConvert);
277 private string SaveParameters()
279 string optionalParameters = String.IsNullOrEmpty(_virtualName)
281 :
"virtualname=\"" + HttpUtility.HtmlEncode(_virtualName) +
"\" ";
284 if (!String.IsNullOrEmpty(_contentgroup))
286 optionalParameters +=
"contentgroup=\"" + HttpUtility.HtmlEncode(_contentgroup) +
"\" ";
288 optionalParameters +=
"contenttype=\"" + _contenttype +
"\" ";
290 if (!String.IsNullOrEmpty(_contexttags))
292 optionalParameters +=
"contexttags=\"" + HttpUtility.HtmlEncode(_contexttags) +
"\" ";
297 optionalParameters +=
"contextinfo=\"" + HttpUtility.HtmlEncode(_contextInfoPreparationType) +
"\" ";
300 if (_doArchivePreviousVersion)
302 optionalParameters +=
"flag_archive_prev_version=\"1\" ";
307 optionalParameters +=
"flag_create_log=\"1\" ";
312 optionalParameters +=
"flag_indexing=\"1\" ";
315 if (_doOverwriteContent)
317 optionalParameters +=
"flag_overwrite_content=\"1\" ";
320 if (_doOverwriteGroupAssignment)
322 optionalParameters +=
"flag_overwrite_group_assignment=\"1\" ";
325 if (_doReleasePublishedFiles)
327 optionalParameters +=
"flag_set_final=\"1\" ";
330 optionalParameters +=
"ignore_metadata=\"" + BoolToString(_doIgnoreMetadata) +
"\" ";
332 if (!String.IsNullOrEmpty(_inlineFunctionName))
334 optionalParameters +=
"inlinefunctionname=\"" + HttpUtility.HtmlEncode(_inlineFunctionName) +
"\" ";
337 if (!String.IsNullOrEmpty(_prefix))
339 optionalParameters +=
"prefix=\"" + HttpUtility.HtmlEncode(_prefix) +
"\" ";
342 if (!String.IsNullOrEmpty(_script))
344 optionalParameters +=
"script=\"" + HttpUtility.HtmlEncode(_script) +
"\" ";
349 optionalParameters +=
"useprefix=\"1\" ";
352 return optionalParameters;
367 TextForHighlighting = 2,