[Original] let FCKeditor's Filemanager support "delete" (php) FCKeditor is a very useful WYSIWYG editor. the built-in Filemanager also implements basic file management functions, the only pity is that deletion is not supported... It doesn't matter. In fact, you can delete files and folders in the following steps: 1. fcked [original] allows FCKeditor's File manager to support "delete" (php)
FCKeditor is a good WYSIWYG editor. the built-in File manager also implements the basic File management function. The only pity is that it does not support deletion...
It doesn't matter. you can delete files and folders in the following steps:
1. fckeditor \ editor \ filemanager \ browser \ default \ frmresourceslist.html. edit:
PHP code
oListManager.GetFolderRowHtml = function( folderName, folderPath, folderUrl ){// Build the link to view the folder.var sLink = '' ;return '' +'' +sLink +'<\/a>' +'<\/td> ' +sLink +folderName +'<\/a>' +'<\/td>- Delete<\/tr>' ;}
2. fckeditor \ editor \ filemanager \ browser \ default \ frmresourceslist.html. edit:
PHP code
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize ){// Build the link to view the folder.var sLink = '' ;// Get the file icon.var sIcon = oIcons.GetIcon( fileName ) ;return '' +'' +sLink +'<\/a>' +'<\/td> ' +sLink +fileName +'<\/a>' +'<\/td> ' +fileSize +' KB' +'<\/td>- Delete<\/tr>' ;}
3. Add: fckeditor \ editor \ filemanager \ browser \ default \ frmresourceslist.html:
PHP code
function DeleteFile( fileName, fileUrl ){if (confirm('Are you sure you wish to delete ' + fileName + '?')) {oConnector.SendCommand( 'DeleteFile', "FileUrl=" + escape( fileUrl ), Refresh ) ;}}function DeleteFolder( folderName, folderPath ){if (confirm('Are you sure you wish to delete \'' + folderName + '\' and all files in it?')) {oConnector.SendCommand( 'DeleteFolder', "FolderName=" + escape( folderPath + folderName ), Refresh ) ;}}
4. fckeditor \ editor \ filemanager \ browser \ default \ frmresourceslist.html. edit:
PHP code
oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/", sCurrentFolderUrl ) ) ;
5. add fckeditor \ editor \ filemanager \ connectors \ php \ commands. php:
PHP code
function DeleteFile( $resourceType, $currentFolder ) {$file = $_SERVER['DOCUMENT_ROOT'].$_GET['FileUrl'];if (is_file($file)) {unlink($file);} else {echo '
';}}function DeleteFolder( $resourceType, $currentFolder ) {$folder = $_SERVER['DOCUMENT_ROOT'].$_GET['FolderName'];if (is_dir($folder) ) {DELETE_RECURSIVE_DIRS($folder);} else {echo '
';}}function DELETE_RECURSIVE_DIRS($dirname) { // recursive function to delete// all subdirectories and contents:if(is_dir($dirname))$dir_handle=opendir($dirname);while($file=readdir($dir_handle)) {if($file!="." && $file!="..") {if(!is_dir($dirname."/".$file)) {unlink ($dirname."/".$file);} else {DELETE_RECURSIVE_DIRS($dirname."/".$file);}}}closedir($dir_handle);rmdir($dirname);}