Suddenly it came to my mind, how do you delete the files from the "filebrowser"?
- Is it just me, or is that function actually missing?
Ditto with deleting the folders you created?
Best regards,
Jeppe R.
- Is it just me, or is that function actually missing?
Ditto with deleting the folders you created?
Best regards,
Jeppe R.
Re: How to delete files from the "Filebrowser"?
Re: How to delete files from the "Filebrowser"?
- It shouldn't be that difficult to integrate, if you know which file to look in..
Have anybody already made a "patch" for this?
Re: How to delete files from the "Filebrowser"?
Change file "fckeditor\editor\filemanager\browser\default\frmresourceslist.html"
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
{
// Build the link to view the folder.
var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;
var sLinkDelete = '<a href="#" onclick="DeleteFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;
// Get the file icon.
var sIcon = oIcons.GetIcon( fileName ) ;
return '<tr>' +
'<td width="16">' +
sLink +
'<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' +
'<\/td><td> ' +
sLink +
fileName +
'<\/a>' +
'<\/td><td align="right" nowrap> ' +
fileSize +
' KB ' + sLinkDelete + ' del</a>' +
'<\/td><\/tr>' ;
}
add this function
function DeleteFile( fileUrl )
{
if (confirm("Delete this file ?") == true)
{
oConnector.SendCommand( 'RemoveFile','DeleteFileName=' + encodeURI( fileUrl ).replace( '#', '%23' ) , DeleteFileCallBack ) ;
}
}
function DeleteFileCallBack( fckXml )
{
window.parent.frames['frmResourcesList'].Refresh() ;
}
==========================================
===========================================
============================================
add subrutine file "fckeditor\editor\filemanager\connectors\asp\commands.asp"
'============================
'Modificacion de Jose Bressan
' Para Eliminar un archivo
'============================
Sub RemoveFile(resourceType, currentFolder)
Dim sDeleteFileName
Dim oFS
sDeleteFileName = Request.QueryString( "DeleteFileName" )
sDeleteFileName = Server.MapPath(sDeleteFileName)
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
If oFS.FileExists(sDeleteFileName) = True Then
oFS.DeleteFile sDeleteFileName, True
end if
Set oFS = Nothing
End Sub
==========================================
===========================================
============================================
change file "fckeditor\editor\filemanager\connectors\asp\connector.asp"
' Execute the required command.
Select Case sCommand
Case "GetFolders"
GetFolders sResourceType, sCurrentFolder
Case "GetFoldersAndFiles"
GetFoldersAndFiles sResourceType, sCurrentFolder
Case "CreateFolder"
CreateFolder sResourceType, sCurrentFolder
Case "RemoveFile"
RemoveFile sResourceType, sCurrentFolder
End Select
==========================================
===========================================
============================================
change file "fckeditor\editor\filemanager\connectors\asp\config.asp"
Dim ConfigAllowedCommands
ConfigAllowedCommands = "QuickUpload|FileUpload|GetFolders|GetFoldersAndFiles|CreateFolder|RemoveFile"
==========================================
==========================================
==========================================
that all, enjoy
jbressan
Re: How to delete files from the "Filebrowser"?
Re: How to delete files from the "Filebrowser"?
First of all thanks to all who put these codes to allow deletion. But this does not work for ASP.NET. So I'll tell how you may add file delete functionality to FCKEditor in ASP.NET. I'll use first part of approach for ASP as a beginning:
Change file "fckeditor\editor\filemanager\browser\default\frmresourceslist.html"
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
{
// Build the link to view the folder.
var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;
var sLinkDelete = '<a href="#" onclick="DeleteFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;
// Get the file icon.
var sIcon = oIcons.GetIcon( fileName ) ;
return '<tr>' +
'<td width="16">' +
sLink +
'<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' +
'<\/td><td> ' +
sLink +
fileName +
'<\/a>' +
'<\/td><td align="right" nowrap> ' +
fileSize +
' KB ' + sLinkDelete + ' del</a>' +
'<\/td><\/tr>' ;
}
Then I'll change the next function a little bit.
add this function
function DeleteFile( fileUrl )
{
if (confirm("Delete this file ?") == true)
{
document.location.href = "../../connectors/aspx/foDelete.aspx?Command=DeleteFile&FileName=" + encodeURI( fileUrl ).replace( '#', '%23' );}
}
You can easily see that this results in a simple redirection to an .NET page called foDeleteFile.aspx (you can name it whatever you like). You may put that page anywhere you like in your project but you should not forget to update the URL used in above function accordingly. I prefered to put it under connectors/aspx folder to locate it easily.
The HTML code of that page should only contain a simple panel control between in its body tag to use for javascript embedding:
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="pJava" runat="server">
</asp:Panel>
</div>
</form>
</body>
And the code behind for page load event should be like that:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Check security credentials. Replace this part with your security check code or remove it if you do not want any control at all
SistemAyarlariniAl()
If IsDBNull(Session("sOturumID")) Then Response.Redirect(sSiteURL.Replace(sKokKlasor, sYonetimKlasoru))
Dim sCommand As String = Request.QueryString("Command")
'If command string is empty redirect page
If sCommand = "" Then Response.Redirect(yourdefaultpage or any page you like)
Select Case sCommand
Case "DeleteFile"
Dim sFileName As String = Request.QueryString("FileName")
Dim sSiteURL As String = "http://www.yourwebsite.com"
Dim sRootFolder As String = "yourwebsitesrootfolder" 'Use "" if you are not using a subfolder as your web sites root
Dim sManagementFolder As String = "yourcontentmanagementsystemfolder" 'Use "" if you had put FCKEditor directly under your root folder
'If no filename is defined redirect page
If sFileName = "" Then Response.Redirect(yourdefaultpage or any page you like)
Try
sFileName = Server.MapPath(sFileName)
DeleteFile(sFileName)
Dim sJava As String = "window.onload=function(){window.parent.document.location.href='" & sSiteURL.ToLower(New System.Globalization.CultureInfo("en-US")).Replace(sRootFolder.ToLower(New System.Globalization.CultureInfo("en-US")), sManagementFolder.ToLower(New System.Globalization.CultureInfo("en-US"))) & "/editor/filemanager/browser/default/browser.html?Type=Image&Connector=" & Server.UrlEncode(sSiteURL.ToLower(New System.Globalization.CultureInfo("en-US")).Replace(sRootFolder.ToLower(New System.Globalization.CultureInfo("en-US")), sManagementFolder.ToLower(New System.Globalization.CultureInfo("en-US")))) & "%2Feditor%2Ffilemanager%2Fconnectors%2Faspx%2Fconnector.aspx';};"
ScriptManager.RegisterStartupScript(pJava, pJava.GetType(), "jsRefresh", sJava, True)
Catch ex As Exception
Response.Write(ex.Message)
End Try
Case Else
'Unrecognized command so redirect
Response.Redirect(yourdefaultpage or any page you like)
End Select
End Sub
That is as simple as that and works smoothly. I wrote original code in my native language (Turkish) and tried to translate variable names to English so I may have made some type mistakes. If so sorry.
Re: How to delete files from the "Filebrowser"?
''' <summary>
''' Deletes the submitted file from server
''' </summary>
''' <param name="sFileName">Full name of file to be deleted</param>
''' <returns>true if deleted, false if not</returns>
''' <remarks></remarks>
Function DeleteFile(ByVal sDosyaAdi As String) As Boolean
DeleteFile = False
Try
File.Delete(sFileName)
DeleteFile = True
Catch ex As Exception
End Try
End Function
Re: How to delete files from the "Filebrowser"?
Re: How to delete files from the "Filebrowser"?
YOu can view a detail asp and asp.net solution here: http://www.itjungles.com/dotnet/how-to- ... -fckeditor