20 using erminas.SmartAPI.CMS.Project.Folder;
21 using erminas.SmartAPI.Utils;
23 namespace erminas.SmartAPI.CMS.Project.Pages.Elements
34 : base(project, guid, languageVariant)
38 protected AbstractMediaElement(
IProject project, XmlElement xmlElement) : base(project, xmlElement)
40 LoadWholePageElement();
46 @"<ELT action=""save"" reddotcacheguid="""" guid=""{0}"" value=""{1}"" folderguid=""{3}"" {2} extendedinfo=""""></ELT>";
52 Project.ExecuteRQL(
string.Format(COMMIT, Guid.ToRQLString(), RQL.SESSIONKEY_PLACEHOLDER,
"",
""));
56 var isInSubFolder = !Project.Folders.ContainsGuid(Value.Folder.Guid);
58 var rqlStr = COMMIT.RQLFormat(
this, HttpUtility.HtmlEncode(Value.Name),
59 isInSubFolder ?
"subdirguid=\"{0}\"".RQLFormat(Value.Folder) :
"",
62 Project.ExecuteRQL(rqlStr);
67 get {
return LazyLoad(ref _file); }
68 set { _file = value; }
71 protected override sealed
void LoadWholePageElement()
73 var folder = GetFolder();
78 InitFileValue(folder);
84 if (!XmlElement.TryGetGuid(
"folderguid", out folderGuid))
91 var folderList = Project.Folders.AllIncludingSubFolders;
92 return XmlElement.TryGetGuid(
"subdirguid", out subFolderGuid)
93 ? folderList.FirstOrDefault(folder => folder.Guid == subFolderGuid)
94 : folderList.FirstOrDefault(folder => folder.Guid == folderGuid);
97 private void InitFileValue(
IFolder folder)
99 var fileName = XmlElement.GetAttributeValue(
"value");
100 if (
string.IsNullOrEmpty(fileName))
107 _file = files.FirstOrDefault(file => file.Name == fileName);
110 private bool IsFileInSubFolder
114 EnsureInitialization();
119 var folderGuid = XmlElement.GetGuid(
"folderguid");
120 return folderGuid != Value.Folder.Guid;