Adobe GoLive CS2 Programmer's Manual page 144

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
You can specify the destination of the copy as a pathname or as a local URL. The following code example
uses URLs to copy the newImage.gif file from an installed extension's folder to the currently open site's
script library folder. To construct the destination URL for the copy operation, it concatenates the site's root
folder path with the name of the current script library folder. If the copy operation succeeds, this method
returns true , otherwise, it returns false .
// Copies a source graphic from the extension's folder into the current
// site's Generated Items folder so the graphic is uploaded with the Site.
function copyGraphicToSite(){
//ensure the Site window is frontmost
if (document == null || document == undefined ||
{
}
// Site window is frontmost so use it to access
// the site folder and the Generated Items folder.
// get url to site folder
// can't use document.parent -- it's undefined for site docs
var siteFoldURL = document.site.url;
// construct destination folder URL
// get name of generated Items folder
var genFldName = app.prefs.scriptLibFolder;
// append name of generated Items folder to Site Root URL
var genFldURL = siteFoldURL + genFldName;
// make sure destination folder exists before copying to it
var destFldObj = JSXFile(genFldURL);
if (!destFldObj.isFolder) // no destination folder, so create it.
{
}
// if we got this far, destination folder exists
// don't overwrite if file is already present in destination folder
var destFldURL = destFldObj.url;
var destURL = destFldURL + "newImage.gif"
var destObj = JSXFile(destURL);
if (destObj.exists && !destObj.isFolder)
{
}
// make a JSXFile object that represents the file to copy
var srcFileURL = app.folder.url +
var srcFileObj = JSXFile(srcFileURL);
document.type != "site")
Window.alert ("Please make a site window frontmost and try again.");
return false;
if (!(destFldObj.createFolder())) // folder creation failed
{
Window.alert("Destination folder could not be found or created.");
return false;
}
Window.alert("Destination already contains a copy of the graphic.");
return false;
"Modules/Extend Scripts/copyGraphic/images/newImage.gif";
Adobe GoLive CS2 SDK
Managing Web Sites
144

Advertisement

Table of Contents
loading

Table of Contents