17 using System.Collections.Generic;
20 using erminas.SmartAPI.CMS.Project.Folder;
21 using erminas.SmartAPI.CMS.Project.Publication;
22 using erminas.SmartAPI.Utils;
23 using erminas.SmartAPI.Utils.CachedCollections;
25 namespace erminas.SmartAPI.CMS.Project
71 IRDEnumerable<IFolder> AllIncludingSubFolders {
get; }
72 IRDEnumerable<IAssetManagerFolder> AssetManagerFolders {
get; }
83 public bool AreAttributesMandatory {
get;
set; }
84 public string Description {
get;
set; }
85 public bool IsFolderNotAvailableInEditor {
get;
set; }
86 public bool IsPublishingPersonalizationAttributes {
get;
set; }
87 public int MaximumNumberOfAssetsDisplayed {
get;
set; }
88 public string Name {
get;
set; }
106 public bool IsTransmittingCredentials {
get;
set; }
107 public bool IsVersioningActive {
get;
set; }
108 public string Path {
get;
set; }
110 public string UserName {
get;
set; }
111 public string UserPassword {
get;
set; }
114 internal class Folders : NameIndexedRDList<IFolder>, IFolders
116 private readonly IProject _project;
118 internal Folders(IProject project,
Caching caching) : base(caching)
121 RetrieveFunc = GetFolders;
124 public IRDEnumerable<IFolder> AllIncludingSubFolders
131 .Cast<IAssetManagerFolder>()
132 .SelectMany(folder => folder.SubFolders)).ToRDEnumerable();
136 public IRDEnumerable<IAssetManagerFolder> AssetManagerFolders
138 get {
return this.Where(folder => folder is IAssetManagerFolder).Cast<IAssetManagerFolder>().ToRDEnumerable(); }
141 public void CreateFolder(DatabaseAssetFolderConfiguration config)
143 const string CREATE_FOLDER =
144 @"<PROJECT><FOLDER shared=""0"" name=""{0}"" description=""{1}"" foldertype=""0"" catalog=""1"" savetype=""0"" action=""addnew"" webfolder=""{2}"" exportfolder="""" obligatoryattributes=""{3}"" personalization=""{4}"" maxlistcount=""{5}"" hideintexteditor=""{6}""></FOLDER></PROJECT>";
146 Project.ExecuteRQL(CREATE_FOLDER.SecureRQLFormat(config.Name, config.Description, config.PublicationFolder,
147 config.AreAttributesMandatory,
148 config.IsPublishingPersonalizationAttributes,
149 config.MaximumNumberOfAssetsDisplayed,
150 config.IsFolderNotAvailableInEditor));
153 public IFolder GetByGuidIncludingSubFolders(Guid folderGuid)
155 return AllIncludingSubFolders.First(folder => folder.Guid == folderGuid);
158 public IProject Project
160 get {
return _project; }
163 public ISession Session
165 get {
return _project.
Session; }
168 public bool TryGetByGuidIncludingSubFolders(Guid folderGuid, out
IFolder folder)
170 folder = AllIncludingSubFolders.FirstOrDefault(folder2 => folder2.Guid == folderGuid);
171 return folder != null;
174 private List<IFolder> GetFolders()
176 const string LIST_FILE_FOLDERS =
@"<PROJECT><FOLDERS action=""list"" withsubfolders=""0""/></PROJECT>";
177 var xmlDoc = Project.
ExecuteRQL(LIST_FILE_FOLDERS);
179 return (from XmlElement curNode in xmlDoc.GetElementsByTagName(
"FOLDER")
180 where InternalFolderFactory.HasSupportedFolderType(curNode)
181 select InternalFolderFactory.CreateFolder(_project, curNode)).ToList();