/// <summary> /// Returns URL of item according specified conditions. /// </summary> /// <param name="data">Data object holding information on item</param> /// <param name="isPreview">Indicates whether the URL is requested for item preview</param> /// <param name="height">Image height</param> /// <param name="width">Image width</param> /// <param name="maxSideSize">Specifies maximum size of the image</param> /// <param name="notAttachment">Indicates whether the file is attachment</param> private IconParameters innermedia_GetThumbsItemUrl(IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { IconParameters parameters = new IconParameters(); if (LibraryInfo != null) { // get argument set string arg = GetArgumentSet(data); // Get extension string ext = data.GetValue((data.ContainsColumn("FileExtension") ? "FileExtension" : "Extension")).ToString(); // If image is requested for preview if (isPreview) { if (ext.ToLowerCSafe() == "<dir>") { parameters.IconClass = "icon-folder"; } else { // Check if file has a preview if (!ImageHelper.IsSupportedByImageEditor(ext)) { // File isn't image and no preview exists - get the default file icon parameters.IconClass = UIHelper.GetFileIconClass(ext); } else { // Files are obtained from the FS if (!data.ContainsColumn("FileURL")) { parameters.Url = GetItemUrl(arg, true, height, width, maxSideSize); } else { parameters.IconClass = UIHelper.GetFileIconClass(ext); } } } // Setup icon size for fon icons if (!string.IsNullOrEmpty(parameters.IconClass)) { parameters.IconSize = FontIconSizeEnum.Dashboard; } } else { // Get item URL parameters.Url = GetItemUrlInternal(arg, data, false, height, width, maxSideSize, notAttachment); } } return(parameters); }
/// <summary> /// Returns argument set for the passed file data row. /// </summary> /// <param name="data">Data row object holding all the data on current file</param> public string GetArgumentSet(IDataContainer data) { string className = ValidationHelper.GetString(data.GetValue("ClassName"), String.Empty).ToLower(); string name = (SourceType == MediaSourceEnum.DocumentAttachments) ? AttachmentHelper.GetFullFileName(Path.GetFileNameWithoutExtension(data.GetValue("AttachmentName").ToString()), data.GetValue("AttachmentExtension").ToString()) : data.GetValue("DocumentName").ToString(); StringBuilder sb = new StringBuilder(); // Common information for both content & attachments sb.Append("name|" + CMSDialogHelper.EscapeArgument(name)); // Load attachment info only for CMS.File document type if ((SourceType != MediaSourceEnum.Content) || (className == "cms.file")) { sb.Append("|AttachmentExtension|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentExtension"))); sb.Append("|AttachmentImageWidth|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentImageWidth"))); sb.Append("|AttachmentImageHeight|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentImageHeight"))); sb.Append("|AttachmentSize|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentSize"))); sb.Append("|AttachmentGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentGUID"))); } else { sb.Append("|AttachmentExtension||AttachmentImageWidth||AttachmentImageHeight||AttachmentSize||AttachmentGUID|"); } // Get source type specific information if (SourceType == MediaSourceEnum.Content) { sb.Append("|NodeSiteID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeSiteID"))); sb.Append("|SiteName|" + CMSDialogHelper.EscapeArgument(data.GetValue("SiteName"))); sb.Append("|NodeGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeGUID"))); sb.Append("|NodeID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeID"))); sb.Append("|NodeAlias|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeAlias"))); sb.Append("|NodeAliasPath|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeAliasPath"))); sb.Append("|DocumentUrlPath|" + CMSDialogHelper.EscapeArgument(data.GetValue("DocumentUrlPath"))); sb.Append("|DocumentExtensions|" + CMSDialogHelper.EscapeArgument(data.GetValue("DocumentExtensions"))); sb.Append("|ClassName|" + CMSDialogHelper.EscapeArgument(data.GetValue("ClassName"))); sb.Append("|NodeLinkedNodeID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeLinkedNodeID"))); } else { string formGuid = data.ContainsColumn("AttachmentFormGUID") ? data.GetValue("AttachmentFormGUID").ToString() : Guid.Empty.ToString(); string siteId = data.ContainsColumn("AttachmentSiteID") ? data.GetValue("AttachmentSiteID").ToString() : "0"; sb.Append("|SiteID|" + CMSDialogHelper.EscapeArgument(siteId)); sb.Append("|FormGUID|" + CMSDialogHelper.EscapeArgument(formGuid)); sb.Append("|AttachmentDocumentID|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentDocumentID"))); } return(sb.ToString()); }
/// <summary> /// Returns argument set for the passed file data row. /// </summary> /// <param name="data">Data object holding all the data on the current file</param> public static string GetArgumentSet(IDataContainer data) { StringBuilder sb = new StringBuilder(); if (data.ContainsColumn("FileGUID")) { sb.Append("FileName|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileName"))); sb.Append("|FileGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileGUID"))); sb.Append("|FilePath|" + CMSDialogHelper.EscapeArgument(data.GetValue("FilePath"))); sb.Append("|FileExtension|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileExtension"))); sb.Append("|FileImageWidth|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileImageWidth"))); sb.Append("|FileImageHeight|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileImageHeight"))); sb.Append("|FileTitle|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileTitle"))); sb.Append("|FileSize|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileSize"))); sb.Append("|FileID|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileID"))); } else { sb.Append("FileName|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileName"))); sb.Append("|Extension|" + CMSDialogHelper.EscapeArgument(data.GetValue("Extension"))); sb.Append("|FileURL|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileURL"))); sb.Append("|Size|" + CMSDialogHelper.EscapeArgument(data.GetValue("Size"))); } return(sb.ToString()); }
/// <summary> /// Loads the other fields values to the state of the form control /// </summary> public override void LoadOtherValues() { if ((Form != null) && (Form.Data != null)) { // Check if the schema information is available IDataContainer data = Form.Data; if (data.ContainsColumn("ParametersXmlSchema") && data.ContainsColumn("ParametersXmlData")) { // Get xml schema and data string schema = Convert.ToString(Form.GetFieldValue("ParametersXmlSchema")); string xml = Convert.ToString(Form.GetFieldValue("ParametersXmlData")); LoadFromXML(xml, schema); } } }
/// <summary> /// Returns URL of item according specified conditions. /// </summary> /// <param name="dr">Data row holding information on item</param> /// <param name="isPreview">Indicates whether the URL is requested for item preview</param> /// <param name="maxSideSize">Specifies maximum size of the image</param> private string innermedia_GetTilesThumbsItemUrl(IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { if (LibraryInfo != null) { // get argument set string arg = GetArgumentSet(data); // Get extension string ext = data.GetValue((data.ContainsColumn("FileExtension") ? "FileExtension" : "Extension")).ToString(); // If image is requested for preview if (isPreview) { if (ext.ToLowerCSafe() == "<dir>") { return(GetDocumentTypeIconUrl("CMS.Folder", "48x48")); } else { // Check if file has a preview if (!ImageHelper.IsSupportedByImageEditor(ext)) { // File isn't image and no preview exists - get the default file icon return(GetFileIconUrl(ext, "")); } else { // Files are obtained from the FS return(!data.ContainsColumn("FileURL") ? GetItemUrl(arg, isPreview, height, width, maxSideSize) : GetFileIconUrl(ext, "")); } } } else { // Get item url return(GetItemUrlInternal(arg, data, isPreview, height, width, maxSideSize, notAttachment)); } } return(null); }
/// <summary> /// Returns updated IFrame URL when required. /// </summary> /// <param name="dr">Data row holding information on imported media file</param> public string GetUpdateIFrameUrl(IDataContainer data) { string result = null; // Uploader is displayed only for imported files - have FileIDs if ((data != null) && data.ContainsColumn("FileID")) { DirectFileUploader dfuElem = (Page.LoadUserControl("~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploader.ascx") as DirectFileUploader); innermedia.GetLibraryUpdateControl(ref dfuElem, data); result = dfuElem.IFrameUrl; } return(result); }
/// <summary> /// Returns URL of the media item according site settings. /// </summary> /// <param name="argument">Argument containing information on current media item</param> /// <param name="data">Data row object holding all the data on the current file</param> /// <param name="isPreview">Indicates whether the file has a preview file or not</param> /// <param name="height">Specifies height of the image</param> /// <param name="width">Specifies width of the image</param> /// <param name="maxSideSize">Specifies maximum size of the image</param> private string GetItemUrlInternal(string argument, IDataContainer data, bool isPreview, int height, int width, int maxSideSize) { MediaFileInfo mfi = null; // Get filename with extension string fileName; if (data.ContainsColumn("FileExtension")) { string ext = ValidationHelper.GetString(data.GetValue("FileExtension"), ""); // In format 'name' fileName = ValidationHelper.GetString(data.GetValue("FileName"), ""); fileName = AttachmentHelper.GetFullFileName(fileName, ext); } else { // In format 'name.ext' fileName = data.GetValue("FileName").ToString(); } // Try to get imported data row DataRow importedRow = GetInformationInternal("fileisnotindatabase", fileName) as DataRow; if (importedRow != null) { mfi = new MediaFileInfo(importedRow); } // If data row is not from DB check external library if (!data.ContainsColumn("FileGUID")) { bool isExternal = false; // Check if is external media library if (data.ContainsColumn("FilePath")) { // Get file path string filePath = ValidationHelper.GetString(data.GetValue("FilePath"), String.Empty); if (!String.IsNullOrEmpty(filePath)) { // Test if file path is inside system root folder string rootPath = Server.MapPath("~/"); if (!filePath.StartsWithCSafe(rootPath)) { isExternal = true; } } } if (isExternal && data.ContainsColumn("FileName")) { return(mfi != null ? GetItemUrl(mfi, isPreview, height, width, maxSideSize) : String.Empty); } } // Files are obtained from the FS if (data.ContainsColumn("FileURL")) { // Information comming from FileSystem (FS) return(URLHelper.GetAbsoluteUrl(data.GetValue("FileURL").ToString())); } else { return(mfi != null ? GetItemUrl(mfi, isPreview, height, width, maxSideSize) : GetItemUrl(argument, isPreview, height, width, maxSideSize)); } }
/// <summary> /// Returns correct ID for the given item (for colorizing the item when selected). /// </summary> /// <param name="data">Item to get the ID of</param> protected string GetColorizeID(IDataContainer data) { string id = data.ContainsColumn(FileIdColumn) ? data.GetValue(FileIdColumn).ToString() : EnsureFileName(data.GetValue("FileName").ToString()); if (String.IsNullOrEmpty(id)) { // Content file id = data.GetValue("NodeGUID").ToString(); } return id.ToLowerCSafe(); }
/// <summary> /// Returns the sitename according to item info. /// </summary> /// <param name="data">Row containing information on the current item</param> /// <param name="isMediaFile">Indicates whether the file is media file</param> private string GetSiteName(IDataContainer data, bool isMediaFile) { int siteId = 0; string result = ""; if (isMediaFile) { if (data.ContainsColumn("FileSiteID")) { // Imported media file siteId = ValidationHelper.GetInteger(data.GetValue("FileSiteID"), 0); } else { // Npt imported yet siteId = RaiseOnSiteIdRequired(); } } else { if (data.ContainsColumn("SiteName")) { // Content file result = ValidationHelper.GetString(data.GetValue("SiteName"), ""); } else { if (data.ContainsColumn("AttachmentSiteID")) { // Non-versioned attachment siteId = ValidationHelper.GetInteger(data.GetValue("AttachmentSiteID"), 0); } else if (TreeNodeObj != null) { // Versioned attachment siteId = TreeNodeObj.NodeSiteID; } else if (data.ContainsColumn("MetaFileSiteID")) { // Metafile siteId = ValidationHelper.GetInteger(data.GetValue("MetaFileSiteID"), 0); } } } if (result == "") { if (String.IsNullOrEmpty(siteName) || (mLastSiteId != siteId)) { SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if (si != null) { mLastSiteId = si.SiteID; result = si.SiteName; siteName = result; } } else { result = siteName; } } return result; }
/// <summary> /// Gets file name according available columns. /// </summary> /// <param name="data">DataRow containing data</param> private string GetFileName(IDataContainer data) { string fileName = ""; if (data != null) { if (data.ContainsColumn("FileExtension")) { fileName = String.Concat(data.GetValue("FileName"), data.GetValue("FileExtension")); } else { fileName = data.GetValue(FileNameColumn).ToString(); } } return fileName; }
/// <summary> /// Initializes attachment update control according current attachment data. /// </summary> /// <param name="dfuElem">Direct file uploader</param> /// <param name="data">Data container holding attachment data</param> private void GetAttachmentUpdateControl(ref DirectFileUploader dfuElem, IDataContainer data) { if (dfuElem != null) { string refreshType = CMSDialogHelper.GetMediaSource(SourceType); Guid formGuid = Guid.Empty; int documentId = ValidationHelper.GetInteger(data.GetValue("AttachmentDocumentID"), 0); // If attachment is related to the workflow 'AttachmentFormGUID' information isn't present if (data.ContainsColumn("AttachmentFormGUID")) { formGuid = ValidationHelper.GetGuid(data.GetValue("AttachmentFormGUID"), Guid.Empty); } if (SourceType == MediaSourceEnum.MetaFile) { dfuElem.ObjectID = Config.MetaFileObjectID; dfuElem.ObjectType = Config.MetaFileObjectType; dfuElem.Category = Config.MetaFileCategory; dfuElem.SiteID = GetObjectSiteID(Config.MetaFileObjectType, Config.MetaFileObjectID); dfuElem.SourceType = MediaSourceEnum.MetaFile; dfuElem.MetaFileID = ValidationHelper.GetInteger(data.GetValue("MetaFileID"), 0); } else { dfuElem.SourceType = MediaSourceEnum.DocumentAttachments; dfuElem.FormGUID = formGuid; dfuElem.DocumentID = documentId; if (TreeNodeObj != null) { // if attachment node exists dfuElem.NodeParentNodeID = TreeNodeObj.NodeParentID; dfuElem.NodeClassName = TreeNodeObj.NodeClassName; } else { // if attachment node doesn't exist dfuElem.NodeParentNodeID = NodeParentID; dfuElem.NodeClassName = "cms.file"; } dfuElem.CheckPermissions = true; dfuElem.AttachmentGUID = ValidationHelper.GetGuid(data.GetValue("AttachmentGUID"), Guid.Empty); dfuElem.ResizeToWidth = ResizeToWidth; dfuElem.ResizeToHeight = ResizeToHeight; dfuElem.ResizeToMaxSideSize = ResizeToMaxSideSize; dfuElem.AllowedExtensions = AllowedExtensions; } dfuElem.ParentElemID = refreshType; dfuElem.ID = "dfuElem"; dfuElem.ForceLoad = true; dfuElem.ControlGroup = "MediaView"; dfuElem.ShowIconMode = true; dfuElem.InsertMode = false; dfuElem.IncludeNewItemInfo = true; dfuElem.IsLiveSite = IsLiveSite; // Setting of the direct single mode dfuElem.UploadMode = MultifileUploaderModeEnum.DirectSingle; dfuElem.MaxNumberToUpload = 1; } }
/// <summary> /// Returns URL of item according specified conditions. /// </summary> /// <param name="data">Data object holding information on item</param> /// <param name="isPreview">Indicates whether the URL is requested for item preview</param> /// <param name="height">Image height</param> /// <param name="width">Image width</param> /// <param name="maxSideSize">Specifies maximum size of the image</param> /// <param name="notAttachment">Indicates whether the file is attachment</param> private IconParameters innermedia_GetThumbsItemUrl(IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { IconParameters parameters = new IconParameters(); if (LibraryInfo != null) { // get argument set string arg = GetArgumentSet(data); // Get extension string ext = data.GetValue((data.ContainsColumn("FileExtension") ? "FileExtension" : "Extension")).ToString(); // If image is requested for preview if (isPreview) { if (ext.ToLowerCSafe() == "<dir>") { parameters.IconClass = "icon-folder"; } else { // Check if file has a preview if (!ImageHelper.IsSupportedByImageEditor(ext)) { // File isn't image and no preview exists - get the default file icon parameters.IconClass = UIHelper.GetFileIconClass(ext); } else { // Files are obtained from the FS if (!data.ContainsColumn("FileURL")) { parameters.Url = GetItemUrl(arg, true, height, width, maxSideSize); } else { parameters.IconClass = UIHelper.GetFileIconClass(ext); } } } // Setup icon size for fon icons if (!string.IsNullOrEmpty(parameters.IconClass)) { parameters.IconSize = FontIconSizeEnum.Dashboard; } } else { // Get item URL parameters.Url = GetItemUrlInternal(arg, data, false, height, width, maxSideSize, notAttachment); } } return parameters; }
/// <summary> /// Returns argument set for the passed file data row. /// </summary> /// <param name="data">Data object holding all the data on the current file</param> public static string GetArgumentSet(IDataContainer data) { StringBuilder sb = new StringBuilder(); if (data.ContainsColumn("FileGUID")) { sb.Append("FileName|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileName"))); sb.Append("|FileGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileGUID"))); sb.Append("|FilePath|" + CMSDialogHelper.EscapeArgument(data.GetValue("FilePath"))); sb.Append("|FileExtension|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileExtension"))); sb.Append("|FileImageWidth|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileImageWidth"))); sb.Append("|FileImageHeight|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileImageHeight"))); sb.Append("|FileTitle|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileTitle"))); sb.Append("|FileSize|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileSize"))); sb.Append("|FileID|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileID"))); } else { sb.Append("FileName|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileName"))); sb.Append("|Extension|" + CMSDialogHelper.EscapeArgument(data.GetValue("Extension"))); sb.Append("|FileURL|" + CMSDialogHelper.EscapeArgument(data.GetValue("FileURL"))); sb.Append("|Size|" + CMSDialogHelper.EscapeArgument(data.GetValue("Size"))); } return sb.ToString(); }
/// <summary> /// Returns URL of item according specified conditions. /// </summary> /// <param name="dr">Data row holding information on item</param> /// <param name="isPreview">Indicates whether the URL is requested for item preview</param> /// <param name="maxSideSize">Specifies maximum size of the image</param> private string innermedia_GetTilesThumbsItemUrl(IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { if (LibraryInfo != null) { // get argument set string arg = GetArgumentSet(data); // Get extension string ext = data.GetValue((data.ContainsColumn("FileExtension") ? "FileExtension" : "Extension")).ToString(); // If image is requested for preview if (isPreview) { if (ext.ToLower() == "<dir>") { return GetDocumentTypeIconUrl("CMS.Folder", "48x48"); } else { // Check if file has a preview if (!ImageHelper.IsSupportedByImageEditor(ext)) { // File isn't image and no preview exists - get the default file icon return GetFileIconUrl(ext, ""); } else { // Files are obtained from the FS return !data.ContainsColumn("FileURL") ? GetItemUrl(arg, isPreview, height, width, maxSideSize) : GetFileIconUrl(ext, ""); } } } else { // Get item url return GetItemUrlInternal(arg, data, isPreview, height, width, maxSideSize, notAttachment); } } return null; }
/// <summary> /// Returns updated IFrame URL when required. /// </summary> /// <param name="dr">Data row holding information on imported media file</param> public string GetUpdateIFrameUrl(IDataContainer data) { string result = null; // Uploader is displayed only for imported files - have FileIDs if ((data != null) && data.ContainsColumn("FileID")) { DirectFileUploader dfuElem = (Page.LoadControl("~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploader.ascx") as DirectFileUploader); innermedia.GetLibraryUpdateControl(ref dfuElem, data); result = dfuElem.IFrameUrl; } return result; }
/// <summary> /// Returns URL of the media item according site settings. /// </summary> /// <param name="argument">Argument containing information on current media item</param> /// <param name="data">Data row object holding all the data on the current file</param> /// <param name="isPreview">Indicates whether the file has a preview file or not</param> /// <param name="height">Specifies height of the image</param> /// <param name="width">Specifies width of the image</param> /// <param name="maxSideSize">Specifies maximum size of the image</param> /// <param name="notAttachment">Indicates whether the file is attachment</param> private string GetItemUrlInternal(string argument, IDataContainer data, bool isPreview, int height, int width, int maxSideSize, bool notAttachment) { MediaFileInfo mfi = null; // Get filename with extension string fileName; if (data.ContainsColumn("FileExtension")) { string ext = ValidationHelper.GetString(data.GetValue("FileExtension"), ""); // In format 'name' fileName = ValidationHelper.GetString(data.GetValue("FileName"), ""); fileName = AttachmentHelper.GetFullFileName(fileName, ext); } else { // In format 'name.ext' fileName = data.GetValue("FileName").ToString(); } // Try to get imported data row DataRow importedRow = GetInformationInternal("fileisnotindatabase", fileName) as DataRow; if (importedRow != null) { mfi = new MediaFileInfo(importedRow); } // If data row is not from DB check external library if (!data.ContainsColumn("FileGUID")) { bool isExternal = false; // Check if is external media library if (data.ContainsColumn("FilePath")) { // Get file path string filePath = ValidationHelper.GetString(data.GetValue("FilePath"), String.Empty); if (!String.IsNullOrEmpty(filePath)) { // Test if file path is inside system root folder string rootPath = Server.MapPath("~/"); if (!filePath.StartsWithCSafe(rootPath)) { isExternal = true; } } } if (isExternal && data.ContainsColumn("FileName")) { return (mfi != null ? GetItemUrl(mfi, isPreview, height, width, maxSideSize) : String.Empty); } } // Files are obtained from the FS if (data.ContainsColumn("FileURL")) { // Information comming from FileSystem (FS) return URLHelper.GetAbsoluteUrl(data.GetValue("FileURL").ToString()); } else { return (mfi != null ? GetItemUrl(mfi, isPreview, height, width, maxSideSize) : GetItemUrl(argument, isPreview, height, width, maxSideSize)); } }
/// <summary> /// Returns argument set for the passed file data row. /// </summary> /// <param name="data">Data row object holding all the data on current file</param> public string GetArgumentSet(IDataContainer data) { string className = ValidationHelper.GetString(data.GetValue("ClassName"), String.Empty).ToLowerCSafe(); string name = string.Empty; // Get file name with extension switch (SourceType) { case MediaSourceEnum.DocumentAttachments: name = AttachmentHelper.GetFullFileName(Path.GetFileNameWithoutExtension(data.GetValue("AttachmentName").ToString()), data.GetValue("AttachmentExtension").ToString()); break; case MediaSourceEnum.MetaFile: name = MetaFileInfoProvider.GetFullFileName(Path.GetFileNameWithoutExtension(data.GetValue("MetaFileName").ToString()), data.GetValue("MetaFileExtension").ToString()); break; default: name = data.GetValue("DocumentName").ToString(); break; } StringBuilder sb = new StringBuilder(); // Common information for both content & attachments sb.Append("name|" + CMSDialogHelper.EscapeArgument(name)); // Load attachment info only for CMS.File document type if (((SourceType != MediaSourceEnum.Content) && (SourceType != MediaSourceEnum.MetaFile)) || (className == "cms.file")) { sb.Append("|AttachmentExtension|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentExtension"))); sb.Append("|AttachmentImageWidth|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentImageWidth"))); sb.Append("|AttachmentImageHeight|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentImageHeight"))); sb.Append("|AttachmentSize|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentSize"))); sb.Append("|AttachmentGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentGUID"))); } else if (SourceType == MediaSourceEnum.MetaFile) { sb.Append("|MetaFileExtension|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileExtension"))); sb.Append("|MetaFileImageWidth|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileImageWidth"))); sb.Append("|MetaFileImageHeight|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileImageHeight"))); sb.Append("|MetaFileSize|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileSize"))); sb.Append("|MetaFileGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileGUID"))); sb.Append("|SiteID|" + CMSDialogHelper.EscapeArgument(data.GetValue("MetaFileSiteID"))); } else { sb.Append("|AttachmentExtension||AttachmentImageWidth||AttachmentImageHeight||AttachmentSize||AttachmentGUID|"); } // Get source type specific information if (SourceType == MediaSourceEnum.Content) { sb.Append("|NodeSiteID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeSiteID"))); sb.Append("|SiteName|" + CMSDialogHelper.EscapeArgument(data.GetValue("SiteName"))); sb.Append("|NodeGUID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeGUID"))); sb.Append("|NodeID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeID"))); sb.Append("|NodeAlias|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeAlias"))); sb.Append("|NodeAliasPath|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeAliasPath"))); sb.Append("|DocumentUrlPath|" + CMSDialogHelper.EscapeArgument(data.GetValue("DocumentUrlPath"))); sb.Append("|DocumentExtensions|" + CMSDialogHelper.EscapeArgument(data.GetValue("DocumentExtensions"))); sb.Append("|ClassName|" + CMSDialogHelper.EscapeArgument(data.GetValue("ClassName"))); sb.Append("|NodeLinkedNodeID|" + CMSDialogHelper.EscapeArgument(data.GetValue("NodeLinkedNodeID"))); } else if (SourceType != MediaSourceEnum.MetaFile) { string formGuid = data.ContainsColumn("AttachmentFormGUID") ? data.GetValue("AttachmentFormGUID").ToString() : Guid.Empty.ToString(); string siteId = data.ContainsColumn("AttachmentSiteID") ? data.GetValue("AttachmentSiteID").ToString() : "0"; sb.Append("|SiteID|" + CMSDialogHelper.EscapeArgument(siteId)); sb.Append("|FormGUID|" + CMSDialogHelper.EscapeArgument(formGuid)); sb.Append("|AttachmentDocumentID|" + CMSDialogHelper.EscapeArgument(data.GetValue("AttachmentDocumentID"))); } return sb.ToString(); }
/// <summary> /// Initializes attachment update control according current attachment data. /// </summary> /// <param name="dfuElem">Direct file uploader</param> /// <param name="data">Data container holding attachment data</param> private void GetAttachmentUpdateControl(ref DirectFileUploader dfuElem, IDataContainer data) { if (dfuElem != null) { string refreshType = CMSDialogHelper.GetMediaSource(SourceType); Guid formGuid = Guid.Empty; int documentId = ValidationHelper.GetInteger(data.GetValue("AttachmentDocumentID"), 0); // If attachment is related to the workflow 'AttachmentFormGUID' information isn't present if (data.ContainsColumn("AttachmentFormGUID")) { formGuid = ValidationHelper.GetGuid(data.GetValue("AttachmentFormGUID"), Guid.Empty); } dfuElem.ID = "dfuElem"; dfuElem.SourceType = MediaSourceEnum.DocumentAttachments; dfuElem.ForceLoad = true; dfuElem.FormGUID = formGuid; dfuElem.DocumentID = documentId; dfuElem.EnableSilverlightUploader = false; if (TreeNodeObj != null) { // if attachment node exists dfuElem.NodeParentNodeID = TreeNodeObj.NodeParentID; dfuElem.NodeClassName = TreeNodeObj.NodeClassName; } else { // if attachment node doesn't exist dfuElem.NodeParentNodeID = NodeParentID; dfuElem.NodeClassName = "cms.file"; } dfuElem.CheckPermissions = true; dfuElem.ControlGroup = "MediaView"; dfuElem.AttachmentGUID = ValidationHelper.GetGuid(data.GetValue("AttachmentGUID"), Guid.Empty); dfuElem.ResizeToWidth = ResizeToWidth; dfuElem.ResizeToHeight = ResizeToHeight; dfuElem.ResizeToMaxSideSize = ResizeToMaxSideSize; dfuElem.AllowedExtensions = AllowedExtensions; dfuElem.ImageUrl = ResolveUrl(GetImageUrl("Design/Controls/DirectUploader/upload.png")); dfuElem.LoadingImageUrl = GetImageUrl("Design/Preloaders/preload16.gif"); dfuElem.ImageHeight = 16; dfuElem.ImageWidth = 16; dfuElem.InsertMode = false; dfuElem.ParentElemID = refreshType; dfuElem.IncludeNewItemInfo = true; dfuElem.IsLiveSite = IsLiveSite; // Setting of the direct single mode dfuElem.UploadMode = MultifileUploaderModeEnum.DirectSingle; dfuElem.Width = 16; dfuElem.Height = 16; dfuElem.MaxNumberToUpload = 1; } }