private void LoadSettings() { config = new SharedFilesConfiguration(Settings); EditContentImage = WebConfigSettings.EditContentImage; lblError.Text = String.Empty; FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p == null) { return; } fileSystem = p.GetFileSystem(); if (fileSystem == null) { return; } siteUser = SiteUtils.GetCurrentSiteUser(); newWindowMarkup = displaySettings.NewWindowLinkMarkup; if (BrowserHelper.IsIE()) { //this is a needed hack because IE 8 doesn't work correctly with window.open // a "security feature" of IE 8 // unfortunately this is not valid xhtml to use target but it works in IE newWindowMarkup = displaySettings.IeNewWindowLinkMarkup; } if (!SharedFilesConfiguration.DownloadLinksOpenNewWindow) { newWindowMarkup = string.Empty; } TimeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); fileVirtualBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/SharedFiles/"; try { // this keeps the action from changing during ajax postback in folder based sites SiteUtils.SetFormAction(Page, Request.RawUrl); } catch (MissingMethodException) { //this method was introduced in .NET 3.5 SP1 } btnUpload2.Visible = IsEditable; uploader.Visible = IsEditable; uploader.MaxFilesAllowed = SharedFilesConfiguration.MaxFilesToUploadAtOnce; uploader.ServiceUrl = SiteRoot + "/SharedFiles/upload.ashx?pageid=" + PageId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString(); uploader.FormFieldClientId = hdnCurrentFolderId.ClientID; uploader.UploadButtonClientId = btnUpload2.ClientID; if (IsEditable) { string refreshFunction = "function refresh" + ModuleId.ToInvariantString() + " () { $('#" + btnRefresh.ClientID + "').click(); } "; uploader.UploadCompleteCallback = "refresh" + ModuleId.ToInvariantString(); ScriptManager.RegisterClientScriptBlock( this, this.GetType(), "refresh" + ModuleId.ToInvariantString(), refreshFunction, true); } if ((dgFile.TableCssClass.Contains("jqtable")) && (!WebConfigSettings.DisablejQuery)) { StringBuilder script = new StringBuilder(); script.Append("function setupJTable" + ModuleId.ToInvariantString() + "() {"); script.Append("$('#" + dgFile.ClientID + " th').each(function(){ "); script.Append("$(this).addClass('ui-state-default'); "); script.Append("}); "); script.Append("$('table.jqtable td').each(function(){ "); script.Append("$(this).addClass('ui-widget-content'); "); script.Append("}); "); script.Append("$('table.jqtable tr').hover( "); script.Append("function() {"); script.Append("$(this).children('td').addClass('ui-state-hover'); "); script.Append("},function() {"); script.Append("$(this).children('td').removeClass('ui-state-hover'); "); script.Append("} "); script.Append("); "); script.Append("$('table.jqtable tr').click(function() { "); script.Append("$(this).children('td').toggleClass('ui-state-highlight'); "); script.Append("}); "); script.Append("} "); // end function script.Append("Sys.WebForms.PageRequestManager.getInstance().add_endRequest(setupJTable" + ModuleId.ToInvariantString() + "); "); ScriptManager.RegisterStartupScript( this, this.GetType(), "jTable" + ModuleId.ToInvariantString(), script.ToString(), true); } trObjectCount.Visible = config.ShowObjectCount; if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if (WebConfigSettings.ForceLegacyFileUpload) { ScriptManager.GetCurrent(Page).RegisterPostBackControl(btnUpload2); } }
private void LoadSettings() { timeZone = SiteUtils.GetUserTimeZone(); virtualSourcePath = $"~/Data/Sites/{siteSettings.SiteId.ToInvariantString()}/SharedFiles/"; virtualHistoryPath = $"~/Data/Sites/{siteSettings.SiteId.ToInvariantString()}/SharedFiles/History/"; lnkCancelFile.NavigateUrl = SiteUtils.GetCurrentPageUrl(); lnkCancelFolder.NavigateUrl = lnkCancelFile.NavigateUrl; //this page handles both folders and files //expected strItem examples are 23~folder and 13~file //the number portion is the ItemID of the folder or file if (strItem.IndexOf("~") > -1) { try { char[] separator = { '~' }; string[] args = strItem.Split(separator); itemId = int.Parse(args[0]); type = args[1]; } catch { }; } Hashtable moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new SharedFilesConfiguration(moduleSettings); divHistory.Visible = config.EnableVersioning; uploader.UploadButtonClientId = btnUpload.ClientID; uploader.ServiceUrl = SiteRoot + "/SharedFiles/upload.ashx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&ItemID=" + itemId.ToInvariantString(); uploader.FormFieldClientId = hdnCurrentFolderId.ClientID; string refreshFunction = "function refresh" + moduleId.ToInvariantString() + " () { window.location.reload(true); } "; uploader.UploadCompleteCallback = $"refresh{moduleId.ToInvariantString()}"; ScriptManager.RegisterClientScriptBlock( this, GetType(), $"refresh{moduleId.ToInvariantString()}", refreshFunction, true ); AddClassToBody("sharedfilesedit"); FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p == null) { return; } fileSystem = p.GetFileSystem(); }
public static void DeleteAllFiles(SharedFileFolder folder, IFileSystem fileSystem, string fileVirtualBasePath, SharedFilesConfiguration config) { // method implemented by Jean-Michel 2008-07-31 // TODO: implement check whether versioning is enabled before calling this method // if we are keeping versions we should not delete the files if (folder == null) { return; } if (fileSystem == null) { return; } if (string.IsNullOrEmpty(fileVirtualBasePath)) { return; } if (folder.FolderId == -1) { return; } ArrayList folders = new ArrayList(); ArrayList files = new ArrayList(); using (IDataReader reader = SharedFile.GetSharedFiles(folder.ModuleId, folder.FolderId)) { while (reader.Read()) { files.Add(Convert.ToInt32(reader["ItemID"])); } } using (IDataReader reader = SharedFileFolder.GetSharedFolders(folder.ModuleId, folder.FolderId)) { while (reader.Read()) { folders.Add(Convert.ToInt32(reader["FolderID"])); } } foreach (int id in files) { SharedFile sharedFile = new SharedFile(folder.ModuleId, id); sharedFile.Delete(); if (!config.EnableVersioning) { fileSystem.DeleteFile(VirtualPathUtility.Combine(fileVirtualBasePath, sharedFile.ServerFileName)); } } foreach (int id in folders) { SharedFileFolder subFolder = new SharedFileFolder(folder.ModuleId, id); DeleteAllFiles(subFolder, fileSystem, fileVirtualBasePath, config); SharedFileFolder.DeleteSharedFileFolder(id); } }
private void LoadSettings() { timeZone = SiteUtils.GetUserTimeZone(); virtualSourcePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/SharedFiles/"; virtualHistoryPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/SharedFiles/History/"; lnkCancelFile.NavigateUrl = SiteUtils.GetCurrentPageUrl(); lnkCancelFolder.NavigateUrl = lnkCancelFile.NavigateUrl; //if (BrowserHelper.IsIE()) //{ // //this is a needed hack because IE 8 doesn't work correctly with window.open // // a "security feature" of IE 8 // // unfortunately this is not valid xhtml to use target but it works in IE // newWindowMarkup = " target='_blank' "; //} //this page handles both folders and files //expected strItem examples are 23~folder and 13~file //the number portion is the ItemID of the folder or file if (strItem.IndexOf("~") > -1) { try { char[] separator = { '~' }; string[] args = strItem.Split(separator); this.itemId = int.Parse(args[0]); type = args[1]; } catch { }; } Hashtable moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new SharedFilesConfiguration(moduleSettings); divHistory.Visible = config.EnableVersioning; uploader.UploadButtonClientId = btnUpload.ClientID; uploader.ServiceUrl = SiteRoot + "/SharedFiles/upload.ashx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&ItemID=" + itemId.ToInvariantString(); uploader.FormFieldClientId = hdnCurrentFolderId.ClientID; string refreshFunction = "function refresh" + moduleId.ToInvariantString() + " () { window.location.reload(true); } "; uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString(); ScriptManager.RegisterClientScriptBlock( this, this.GetType(), "refresh" + moduleId.ToInvariantString(), refreshFunction, true); AddClassToBody("sharedfilesedit"); FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p == null) { return; } fileSystem = p.GetFileSystem(); }