[原創]讓FCKeditor的File manager支援”刪除” (php),該怎麼處理

來源:互聯網
上載者:User
[原創]讓FCKeditor的File manager支援”刪除” (php)
FCKeditor是一款很好用的所見即所得 (WYSIWYG)編輯器, 內建的File manager也實現了基本的檔案管理功能, 唯一遺憾的是, 不支援刪除…

沒關係, 其實只需以下幾步就可以實現刪除檔案和檔案夾:

1, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 編輯:
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, 編輯:
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, 增加:
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, 編輯:
PHP code
oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/", sCurrentFolderUrl ) ) ;



5, 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);}
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.