php教程给fck文件管理器添加查看、修改、删除文件功能
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('originaldescription').value ) ;
switch ( ierrornumber )
{
case 0 :
refresh() ;
break ;
case 401 :
alert( 'you have no permissions to rename the folder' ) ;
break ;
case 402 :
alert( 'invalid folder name' + serrordescription ) ;
break ;
case 403 :
alert( 'is not folder' + serrordescription ) ;
break ;
case 404 :
alert( 'folder not exists' + serrordescription ) ;
break ;
default :
alert( 'error renaming folder. nerror number: ' + ierrornumber + ' nerror description: ' + serrordescription ) ;
break ;
}
}
function renamefile( filename )
{
var newname = prompt('please enter the new file name for "' + filename + '":', filename);
if ((newname != null) && (newname != '') && (newname != filename)) {
oconnector.sendcommand( 'renamefile', "filename=" + encodeuri( filename ) + "&newname=" + encodeuri( newname ), renamefilecallback ) ;
}
}
function renamefilecallback( 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 501 :
alert( 'you have no permissions to rename the file' ) ;
break ;
case 502 :
alert( 'invalid file name' + serrordescription ) ;
break ;
case 503 :
alert( serrordescription + 'is not a file' ) ;
break ;
case 504 :
alert( 'file not exists' + serrordescription ) ;
break ;
default :
alert( 'error renaming file. nerror number: ' + ' nerror description: ' + serrordescription ) ;
break ;
}
}
第二步 找到这个文件 /fckeditoreditorfilemanagerbrowserdefaultfrmfolders.html
将函数openfolder(folderpath)最后一句修改为:
var agent = navigator.useragent;
if(agent.indexof('msie') != -1 || agent.indexof('trident') != -1) {
window.parent.frames['frmresourceslist'].loadresources( oconnector.resourcetype, (folderpath) ) ;
}else{
window.parent.frames['frmresourceslist'].loadresources( oconnector.resourcetype, encodeuri(folderpath) ) ;
}
3。第三步,找到fckeditoreditorfilemanagerbrowserdefaultbrowser.html
添加函数:
function selectbrowser(str) {
var agent = navigator.useragent;
if(agent.indexof('gecko') != -1) {
return encodeuricomponent(str);
}else if(agent.indexof('msie') != -1 || agent.indexof('trident') != -1) {
return str;
}else{
return encodeuricomponent(str);
}
}
第79行修改为: oconnector.connectorurl += 'serverpath=' + selectbrowser( sserverpath ) + '&' ;
第91行修改为: surl += '¤tfolder=' + selectbrowser( this.currentfolder ) ;
首页 1 2 末页