[原创]让FCKeditor的File manager支持”删除” (php),该怎么处理
Jun 13, 2016 am 10:10 AM
file
gt
lt
quot
[原创]让FCKeditor的File manager支持”删除” (php)
FCKeditor是一款很好用的所见即所得编辑器, 内置的File manager也实现了基本的文件管理功能, 唯一遗憾的是, 不支持删除…
没关系, 其实只需以下几步就可以实现删除文件和文件夹:
1, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 编辑:
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->oListManager.GetFolderRowHtml = function( folderName, folderPath, folderUrl ){// Build the link to view the folder.var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath( folderPath ) + '\');return false;">' ;return '<tr>' +'<td width="16">' +sLink +'<img src="/static/imghw/default1.png" data-src="images/Folder.gif" class="lazy" alt="" style="max-width:90%" style="max-width:90%" border="0">' +'</td> <td nowrap colspan="2"> ' +sLink +folderName +'' +'</td> <td align="right" width="45">- <a href="#" onclick="DeleteFolder(\''+folderName+'\',\''+ folderUrl.replace( /'/g, '\\\'') + '\');return false;">Delete</a> </td>' ;}<br>2, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 编辑:<br><dl class="code">PHP code<pre class="brush:php;toolbar:false"><!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize ){// Build the link to view the folder.var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;// Get the file icon.var sIcon = oIcons.GetIcon( fileName ) ;return '<tr>' +'<td width="16">' +sLink +'<img alt="" src="images/icons/'%20+%20sIcon%20+%20'.gif" style="max-width:90%" style="max-width:90%" border="0">' +'</td> <td> ' +sLink +fileName +'' +'</td> <td align="right" nowrap> ' +fileSize +' KB' +'</td> <td align="right" width="45">- <a href="#" onclick="DeleteFile(\''+fileName+'\',\'' + fileUrl.replace( /'/g, '\\\'') + '\');return false;">Delete</a> </td>' ;}<br>3, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 增加:<br><dl class="code">PHP code<pre class="brush:php;toolbar:false"><!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->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
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/", sCurrentFolderUrl ) ) ;
登入後複製
5, fckeditor\editor\filemanager\connectors\php\commands.php, 添加:
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->function DeleteFile( $resourceType, $currentFolder ) {$file = $_SERVER['DOCUMENT_ROOT'].$_GET['FileUrl'];if (is_file($file)) {unlink($file);} else {echo '<error number="1? originaldescription=”unable to locate file">';}}function DeleteFolder( $resourceType, $currentFolder ) {$folder = $_SERVER['DOCUMENT_ROOT'].$_GET['FolderName'];if (is_dir($folder) ) {DELETE_RECURSIVE_DIRS($folder);} else {echo '<error number="2? originaldescription=" unable to locate folder>';}}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);}<div class="clear"> </div></error></error>
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

使用java的File.getParentFile()函數取得檔案的父目錄
