[Original] Let FCKeditor's file Manager support "delete" (PHP)
FCKeditor is a very useful WYSIWYG editor, the built-in File Manager also implements the basic document management functions, the only regret is that the deletion is not supported ...
It doesn't matter, in fact, you can delete files and folders in just the following steps:
1, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, editor:
PHP Code
olistmanager.getfolderrowhtml = function (FolderName, FolderPath, FolderUrl) {//Build the link to view the Folder.var sLi NK = '; return ' + ' +slink + ' <\/a> ' + ' <\/td> ' +slink +foldername + ' <\/a> ' + ' <\/td>-delete< \/tr> ';}
2, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, editor:
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, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, added:
PHP Code
function DeleteFile (filename, fileUrl) {if (Confirm (' is sure you wish to delete ' + FileName + '? ')) {Oconnector.sendcommand (' DeleteFile ', "fileurl=" + Escape (FILEURL), Refresh);}} function DeleteFolder (folderName, FolderPath) {if (Confirm (' is ' sure you wish to delete \ ' + folderName + ' \ ' and Al l files in it? ')) {Oconnector.sendcommand (' DeleteFolder ', "foldername=" + Escape (FolderPath + FolderName), Refresh);}}
4, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, editor:
PHP Code
Ohtml.append (olistmanager.getfolderrowhtml (sfoldername, Scurrentfolderpath + sfoldername + "/", SCURRENTFOLDERURL));
5, fckeditor\editor\filemanager\connectors\php\commands.php, add:
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 ($d irname)) $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);}