000_DW_API_Print.
000_DW_API_Print.
000_DW_API_Print.book Page 3 Wednesday, July 20, 2005 11:58 AM Contents Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Extending Dreamweaver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Additional resources for extension writers . . . . . . . . . . . . . . . . . . . . . . . . .
000_DW_API_Print.book Page 4 Wednesday, July 20, 2005 11:58 AM Chapter 6: The Database API . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 How Database API functions work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Database connection functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Database access functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Chapter 7: The Database Connectivity API . . . . . . . . . . .
000_DW_API_Print.book Page 5 Wednesday, July 20, 2005 11:58 AM Chapter 12: Site. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Report functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Site functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Chapter 13: Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Conversion functions . . . . . . . .
000_DW_API_Print.book Page 6 Wednesday, July 20, 2005 11:58 AM Chapter 17: Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 Code functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 Find/replace functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494 General editing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 Print function . . . . . . . . .
000_DW_API_Print.book Page 7 Wednesday, July 20, 2005 11:58 AM Introduction The Dreamweaver API Reference describes two application programming interfaces (APIs) that let you perform various supporting tasks when developing Macromedia Dreamweaver 8 extensions and adding program code to your Dreamweaver web pages. These two APIs are the utility API and the JavaScript API. The utility API contains subsets of related functions that let you perform specific types of tasks.
000_DW_API_Print.book Page 8 Wednesday, July 20, 2005 11:58 AM Background This book assumes that you are familiar with Dreamweaver, HTML, XML, JavaScript programming and, if applicable, C programming. If you are writing extensions for building web applications, you should also be familiar with server-side scripting on at least one platform, such as Active Server Pages (ASP), ASP.net, PHP: Hypertext Preprocessor (PHP), ColdFusion, or Java Server Pages (JSP).
000_DW_API_Print.book Page 9 Wednesday, July 20, 2005 11:58 AM Workspace The following new Window, Code collapse, and Code view toolbar functions have been added to the Workspace chapter. Window on page 231 (added support for the Macintosh) ■ dreamweaver.cascade() ■ dreamweaver.tileHorizontally() ■ dreamweaver.tileVertically() on page 239 (added support for the Macintosh) on page 240 (added support for the Macintosh) Code collapse on page 241 ■ dom.collapseFullTag() ■ dom.
000_DW_API_Print.book Page 10 Wednesday, July 20, 2005 11:58 AM Site ■ dom.getSiteURLPrefixFromDoc() on page 256 ■ dom.localPathToSiteRelative() on page 257 ■ dom.siteRelativeToLocalPath() on page 257 ■ dreamweaver.compareFiles() ■ dreamweaver.siteSyncDialog.compare() ■ dreamweaver.siteSyncDialog.markDelete() ■ dreamweaver.siteSyncDialog.markGet() ■ dreamweaver.siteSyncDialog.markIgnore() ■ dreamweaver.siteSyncDialog.markPut() ■ dreamweaver.siteSyncDialog.markSynced() ■ site.
000_DW_API_Print.book Page 11 Wednesday, July 20, 2005 11:58 AM Design The following new CSS, Layout view, and Zoom functions have been added to the Design chapter: CSS ■ cssStylePalette.getInternetExplorerRendering() on page 419 ■ cssStylePalette.setInternetExplorerRendering() on page 420 ■ dom.getElementView() ■ dom.getShowDivBackgrounds() ■ dom.getShowDivBoxModel() on page 422 ■ dom.getShowDivOutlines() on page 423 ■ dom.resetAllElementViews() ■ dom.setElementView() ■ dom.
000_DW_API_Print.book Page 12 Wednesday, July 20, 2005 11:58 AM Layout view on page 459 ■ dom.getShowBlockBackgrounds() ■ dom.getShowBlockBorders() ■ dom.getShowBlockIDs() on page 460 ■ dom.getShowBoxModel() on page 461 ■ dom.setShowBlockBackgrounds() ■ dom.setShowBlockBorders() ■ dom.setShowBlockIDs() on page 462 ■ dom.setShowBoxModel() on page 463 on page 459 on page 461 on page 462 Zoom ■ dreamweaver.activeViewScale() ■ dreamweaver.fitAll() ■ dreamweaver.
000_DW_API_Print.book Page 13 Wednesday, July 20, 2005 11:58 AM Enablers The following new functions have been added to the Enablers chapter: ■ dreamweaver.canFitSelection() on page 568 ■ dreamweaver.canPasteSpecial() on page 568 ■ dreamweaver.canZoom() ■ on page 574 dreamweaver.cssStylePalette.canApplySelectedStyle() on page 575 (added new argument) ■ dreamweaver.cssStylePalette.canDeleteSelectedStyle() on page 575 (added new argument) ■ dreamweaver.cssStylePalette.
000_DW_API_Print.book Page 14 Wednesday, July 20, 2005 11:58 AM Conventions used in this guide The following typographical conventions are used in this guide: font indicates code fragments and API literals, including class names, method names, function names, type names, scripts, SQL statements, and both HTML and XML tag and attribute names. ■ Code ■ Italic code ■ The continuation symbol (¬) indicates that a long line of code has been broken across two or more lines.
000_DW_API_Print.book Page 15 Wednesday, July 20, 2005 11:58 AM 1 PART 1 Utility APIs Learn about the Macromedia Dreamweaver 8 utility functions that you can use to access local and web-based files, work with Macromedia Fireworks, and Macromedia Flash objects, manage database connections, create new database connection types, access JavaBeans fscomponents, and integrate Dreamweaver with various source control systems. Chapter 1: The File I/O API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
000_DW_API_Print.
000_DW_API_Print.book Page 17 Wednesday, July 20, 2005 11:58 AM 1 CHAPTER 1 The File I/O API Macromedia Dreamweaver 8 includes a C shared library called DWfile, which gives authors of objects, commands, behaviors, data translators, floating panels, and Property inspectors the ability to read and write files on the local file system. This chapter describes the File I/O API and how to use it.
000_DW_API_Print.book Page 18 Wednesday, July 20, 2005 11:58 AM Description This function copies the specified file to a new location. Arguments originalURL, copyURL ■ The originalURL argument, which is expressed as a file:// URL, is the file you want to copy. ■ The copyURL argument, which is expressed as a file:// URL, is the location where you want to save the copied file. Returns A Boolean value: true if the copy succeeds; false otherwise. Example The following code copies a file called myconfig.
000_DW_API_Print.book Page 19 Wednesday, July 20, 2005 11:58 AM Example The following code tries to create a folder called tempFolder at the top level of the C drive and displays an alert box that indicates whether the operation was successful: var folderURL = "file:///c|/tempFolder"; if (DWfile.createFolder(folderURL)){ alert("Created " + folderURL); }else{ alert("Unable to create " + folderURL); } DWfile.exists() Availability Dreamweaver 2.
000_DW_API_Print.book Page 20 Wednesday, July 20, 2005 11:58 AM Description This function gets the attributes of the specified file or folder. Arguments fileURL ■ The fileURL argument, which is expressed as a file:// URL, is the file or folder for which you want to get attributes. Returns A string that represents the attributes of the specified file or folder. If the file or folder does not exist, this function returns a null value.
000_DW_API_Print.book Page 21 Wednesday, July 20, 2005 11:58 AM Returns A string that contains a hexadecimal number that represents the number of time units that have elapsed since some base time. The exact meaning of time units and base time is platform-dependent; in Windows, for example, a time unit is 100ns, and the base time is January 1st, 1600.
000_DW_API_Print.book Page 22 Wednesday, July 20, 2005 11:58 AM Example You can call this function and the DWfile.getModificationDate() function on a file to compare the modification date to the creation date: var file1 = "file:///c|/temp/file1.txt"; var time1 = DWfile.getCreationDate(file1); var time2 = DWfile.getModificationDate(file1); if (time1 == time2){ alert("file1 has not been modified since it was created"); }else if (time1 < time2){ alert("file1 was last modified on " + time2); } DWfile.
000_DW_API_Print.book Page 23 Wednesday, July 20, 2005 11:58 AM Arguments fileURL ■ The fileURL argument, which is expressed as a file:// URL, is the file for which you are checking the time of the most recent modification. Returns A JavaScript Date object that represents the date and time when the specified file was last modified. DWfile.getSize() Availability Dreamweaver MX. Description This function gets the size of a specified file.
000_DW_API_Print.book Page 24 Wednesday, July 20, 2005 11:58 AM ■ The constraint argument, if it is supplied, must be either "files" (return only files) or "directories" (return only folders). If it is omitted, the function returns files and folders. Returns An array of strings that represents the contents of the folder.
000_DW_API_Print.book Page 25 Wednesday, July 20, 2005 11:58 AM DWfile.remove() Availability Dreamweaver 3. Description This function deletes the specified file. Arguments fileURL ■ The fileURL argument, which is expressed as a file:// URL, is the file you want to remove. Returns A Boolean value: true value if the operation succeeds; false otherwise. Example The following example uses the DWfile.
000_DW_API_Print.book Page 26 Wednesday, July 20, 2005 11:58 AM Arguments fileURL, strAttrs ■ The fileURL argument, which is expressed as a file:// URL, identifies the file for which you are setting the attributes. ■ The strAttrs argument specifies the system-level attributes for the file that is identified by the fileURL argument.
000_DW_API_Print.book Page 27 Wednesday, July 20, 2005 11:58 AM Arguments fileURL, text, {mode} ■ The fileURL argument, which is expressed as a file:// URL, is the file to which you are writing. ■ The text argument is the string to be written. ■ The mode argument, if it is supplied, must be "append". If this argument is omitted, the contents of the file are overwritten by the string. Returns A Boolean value: true if the string is successfully written to the file; false otherwise.
000_DW_API_Print.
000_DW_API_Print.book Page 29 Wednesday, July 20, 2005 11:58 AM 2 CHAPTER 2 The HTTP API Extensions are not limited to working within the local file system. Macromedia Dreamweaver 8 provides a mechanism to get information from and send information to a web server by using hypertext transfer protocol (HTTP). This chapter describes the HTTP API and how to use it. How the HTTP API works All functions in the HTTP API are methods of the MMHttp object.
000_DW_API_Print.book Page 30 Wednesday, July 20, 2005 11:58 AM Functions that return an object also have a callback version. Callback functions let other functions execute while the web server processes an HTTP request. This capability is useful if you are making multiple HTTP requests from Dreamweaver. The callback version of a function passes its ID and return value directly to the function that is specified as its first argument.
000_DW_API_Print.book Page 31 Wednesday, July 20, 2005 11:58 AM