PHP adds view, modify, and delete file functions to FCK File Manager (1/2)

Source: Internet
Author: User
Tags php tutorial

PHP Tutorial Adds view, modify, and delete file features to the FCK file Manager

olistmanager.getfolderrowhtml = function (foldername, FolderPath)
{
Build the link to view the folder.
var slink = ' <a href= ' # ' onclick= ' Openfolder (' + protectpath (folderpath) + '); return false; " >
var rlink = ' <a href= ' # ' title= ' Rename folder ' onclick= ' Renamefolder (' + foldername + '); > </a> ';

var dlink = ' <a href= ' # ' title= ' Delete folder ' onclick= ' DeleteFolder (' + foldername + '); > ";

var sslink = Rlink + dlink;
Return ' <tr> ' +
' <td width= ' ></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; " >
var vlink = ' <a href= ' + protectpath (fileurl) + ' "target=" _blank "" title= "View File" ></a>";

var rlink = ' <a href= ' # ' title= ' rename file ' onclick= ' renamefile (' + filename + '); return false; " ></a > ';

var dlink = ' <a href= ' # ' title= ' delete file ' onclick= ' deletefile (' + filename + '); return false; " ></a > ';


Get the file icon.
var sslink = vlink + Rlink + dlink;
Return ' <tr> ' +
' <td width= ' ></td><td> ' +
Slink +
FileName +
' </a> ' +
' </td><td align= ' right ' nowrap> ' +
FileSize +
' KB ' + Sslink +
' </td></tr> ';
}

function Openfolder (FolderPath)
{
The load the resources list is 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), R Enamefoldercallback);
}
}

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 (' 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), rename Filecallback);
}
}

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;
}
}


The second step is to find this file/fckeditoreditorfilemanagerbrowserdefaultfrmfolders.html
Modify the last sentence of the function Openfolder (FolderPath) to:

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. Step three, find fckeditoreditorfilemanagerbrowserdefaultbrowser.html.
To add a function:

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);
}
}


The 79th line is modified as: Oconnector.connectorurl = ' serverpath= ' + selectbrowser (sserverpath) + ' & ';
The 91st line is modified as: sURL + = ' &currentfolder= ' + selectbrowser (this.currentfolder);

Home 1 2 last page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.