有些時候上傳了個測試的文件,但fckeditor原版又沒有刪除的功能,於是我寫了一個fckeditor的擴展功能,具有:查看/重命名/刪除文件的功能,下面的方法不存在中文亂碼的問題(至少我用IE6,IE8,FF3沒測出來)。
看圖:
1。 第一步 找到這個文件 /fckeditor\editor\filemanager\browser\default\frmresourceslist.html
將已經存在的代碼修改為:
復制內容到剪貼板代碼:
oListManager.GetFolderRowHtml = function( folderName, folderPath )
{
// Build the link to view the folder.
var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath( folderPath ) + '\');return false;"><img alt="" src="images/Folder.gif" width="16" height="16" border="0"> ' ;
var rLink = '<a href="#" title="Rename Folder" onclick="RenameFolder(\'' + folderName + '\');return false;"><img src="images/rename.gif" width="16" height="16" border="0" alt="Rename Folder" title="Rename Folder"></a>' ;
var dLink = '<a href="#" title="Delete Folder" onclick="DeleteFolder(\'' + folderName + '\');return false;"><img src="images/delete.gif" width="16" height="16" border="0" alt="Delete Folder" title="Delete Folder">' ;
var ssLink = rLink + dLink;
return '<tr>' +
'<td width="16"><\/td><td nowrap> ' +
sLink +
folderName +
'<\/a></td><td align="right" nowrap>' + ssLink +
'<\/td><\/tr>' ;
}
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
{
var sIcon = oIcons.GetIcon( fileName ) ;
// Build the link to view the file.
var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;"><img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"> ' ;
var vLink = '<a href="' + ProtectPath( fileUrl ) + '" target="_blank"" title="View file"><img src="images/view.gif" width="16" height="16" border="0" alt="View File" title="View File"></a>' ;
var rLink = '<a href="#" title="Rename file" onclick="RenameFile(\'' + fileName + '\');return false;"><img src="images/rename.gif" width="16" height="16" border="0" alt="Rename File" title="Rename File"></a>' ;
var dLink = '<a href="#" title="Delete file" onclick="DeleteFile(\'' + fileName + '\');return false;"><img src="images/delete.gif" width="16" height="16" border="0" alt="Delete File" title="Delete File"></a>' ;
// Get the file icon.
var ssLink = vLink + rLink + dLink;
return '<tr>' +
'<td width="16"><\/td><td> ' +
sLink +
fileName +
'<\/a>' +
'<\/td><td align="right" nowrap> ' +
fileSize +
' KB' + ssLink +
'<\/td><\/tr>' ;
}
function OpenFolder( folderPath )
{
// Load the resources list for this folder.
window.parent.frames['frmFolders'].LoadFolders( (folderPath) ) ;
}
function OpenFile( fileUrl )
{
window.top.opener.SetUrl( fileUrl.replace( '#', '%23' ) ) ;
window.top.close() ;
window.top.opener.focus() ;
}
function DeleteFolder( folderUrl )
{
if ( !confirm( 'Do you really delete the folder "' + folderUrl + '" ?' ) ) return false;
oConnector.SendCommand( 'DeleteFolder', 'FolderName=' + ( encodeURI(folderUrl) ) , DeleteFolderCallBack ) ;
}
function DeleteFolderCallBack( fckXml )
{
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;
switch ( iErrorNumber )
{
case 0 :
Refresh() ;
break ;
case 201 :
alert( 'You have no permissions to delete the folder' ) ;
break ;
case 202 :
alert( 'Invalid folder name' + sErrorDescription ) ;
break ;
case 203 :
alert( 'Folder not exists' + sErrorDescription ) ;
break ;
default :
alert( 'Error deleting folder. \nError number: ' + iErrorNumber + ' \nError description: ' + sErrorDescription ) ;
break ;
}
}
function DeleteFile(fileUrl)
{
if ( !confirm( 'Do you really delete the file "' + fileUrl + '" ?' ) ) return false;
oConnector.SendCommand( 'DeleteFile', 'FileName=' + encodeURI( fileUrl ) , DeleteFileCallBack ) ;
}
function DeleteFileCallBack( fckXml )
{
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;
switch ( iErrorNumber )
{
case 0 :
Refresh() ;
break ;
case 301 :
alert( 'You have no permissions to delete the file' ) ;
break ;
case 302 :
alert( 'Invalid file name' + sErrorDescription ) ;
break ;
case 303 :
alert( 'File not exists' + sErrorDescription ) ;
break ;
default :
alert( 'Error deleting file. \nError number: ' + iErrorNumber + ' \nError description: ' + sErrorDescription ) ;
break ;
}
}
function RenameFolder( folderName )
{
var newName = prompt('Please enter the new folder name for "' + folderName + '":', folderName);
if ((newName != null) && (newName != '') && (newName != folderName)) {
oConnector.SendCommand( 'RenameFolder', "FolderName=" + encodeURI(folderName) + "&NewName=" + encodeURI ( newName ), RenameFolderCallBack ) ;
}
}
function RenameFolderCallBack( fckXml )
{
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescr