Server model functions

 < Day Day Up > 

In Macromedia Dreamweaver, each document has an associated document type. For dynamic document types, Dreamweaver also associates a server model (such as ASP-JS, ColdFusion, or PHP-MySQL).

Server models are used to group functionality that is specific to a server technology. Different server behaviors, data sources, and so forth, appear based on the server model that is associated with the document.

Using the server model functions, you can determine the set of server models that are currently defined; the name, language, and version of the current server model; and whether the current server model supports a named character set (such as UTF-8).

NOTE

Dreamweaver reads all the information in the server model HTML file and stores this information when it first loads the server model. So, when an extension calls functions such as dom.serverModel.getServerName(), dom.serverModel.getServerLanguage(), and dom.serverModel.getServerVersion(), these functions return the stored values.


dom.serverModel.getAppURLPrefix()

Availability

Dreamweaver MX.

Description

Returns the URL for the site's root folder on the testing server. This URL is the same as that specified for the Testing Server on the Advanced tab in the Site Definition dialog box.

When Dreamweaver communicates with your testing server, it uses HTTP (the same way as a browser). When doing so, it uses this URL to access your site's root folder.

Arguments

None.

Returns

A string, which holds the URL to the application server that is used for live data and debugging purposes.

Example

If the user creates a site and specifies that the testing server is on the local computer and that the root folder is named "employeeapp", a call to the dom.serverModel.getAppURLPrefix() function returns the following string:

 http://localhost/employeeapp/ 

dom.serverModel.getDelimiters()

Availability

Dreamweaver MX.

Description

Lets JavaScript code get the script delimiter for each server model, so managing the server model code can be separated from managing the user-scripted code.

Arguments

None.

Returns

An array of objects where each object contains the following three properties:

  • The startPattern property is a regular expression that matches the opening script delimiter.

  • The endPattern property is a regular expression that matches the closing script delimiter.

  • The participateInMerge pattern is a Boolean value that specifies whether the content that is enclosed in the listed delimiters should (true) or should not (false) participate in block merging.

dom.serverModel.getDisplayName()

Availability

Dreamweaver MX.

Description

Gets the name of the server model that appears in the user interface (UI).

Arguments

None.

Returns

A string, the value of which is the name of the server model.

dom.serverModel.getFolderName()

Availability

Dreamweaver MX.

Description

Gets the name of the folder that is used for this server model in the Configuration folder (such as in the ServerModels subfolder).

Arguments

None.

Returns

A string, the value of which is the name of the folder.

dom.serverModel.getServerExtension() (deprecated)

Availability

Dreamweaver UltraDev 4; deprecated in Dreamweaver MX.

Description

Returns the default file extension of files that use the current server model. (The default file extension is the first in the list.) If no user document is currently selected, the serverModel object is set to the server model of the currently selected site.

Arguments

None.

Returns

A string that represents the supported file extensions.

dom.serverModel.getServerIncludeUrlPatterns()

Availability

Dreamweaver MX.

Description

Returns the following list of properties, which let you access:

  • Translator URL patterns

  • File references

  • Type

Arguments

None.

Returns

A list of objects, one for each searchPattern. Each object has the following three properties:

Property

Description

pattern

A JavaScript regular expression that is specified in the searchPattern field of an EDML file. (A regular expression is delimited by a pair of forward slashes (//).)

fileRef

The 1-based index of the regular expression submatch that corresponds to the included file reference.

type

The portion of the paramName value that remains after removing the _includeUrl suffix. This type is assigned to the type attribute of the <MM:BeginLock> tag. For an example, see Server Model SSI.htm in the Configuration/Translators folder.


Example

The following code snippet from a participant file shows a translator searchPatterns tag:

 <searchPatterns whereToSearch="comment">    <searchPattern paramNames=",ssi_comment_includeUrl">       <![CDATA[/<!--\s*#include\s+(file|virtual)\s*=\s*"([^"]*)"\s*-->/i]]>    </searchPattern> </searchPatterns> 

The search pattern contains a JavaScript regular expression that specifies two submatches (both of which are contained within parentheses). The first submatch is for the text string file or virtual. The second submatch is a file reference.

To access the translator URL pattern, your code should look like the following example:

 var serverModel = dw.getDocumentDOM().serverModel; var includeArray = new Array(); includeArray = serverModel.getServerIncludeUrlPatterns(); 

The call to serverModel.getServerIncludeUrlPatterns() returns the following three properties:

Property

Return value

pattern

/<!--\s*#include\s+(file|virtual)\s*=\s*"([^"]*)"\s*-->/i

fileRef

2

type

ssi_comment


dom.serverModel.getServerInfo()

Availability

Dreamweaver MX.

Description

Returns information that is specific to the current server model. This information is defined in the HTML definition file for the server model, which is located in the Configuration/ServerModels folder.

You can modify the information in the HTML definition file or place additional variable values or functions in the file. For example, you can modify the serverName, serverLanguage, and serverVersion properties. The dom.serverModel.getServerInfo() function returns the information that the server model author adds to the definition file.

NOTE

The other values that are defined in the default server model files are for internal use only.


The serverName, serverLanguage, and serverVersion properties are special because the developer can access them directly by using the following corresponding functions:

  • dom.serverModel.getServerName()

  • dom.serverModel.getServerLanguage()

  • dom.serverModel.getServerVersion()

Arguments

None.

Returns

A JavaScript object that contains a variety of information that is specific to the current server model.

dom.serverModel.getServerLanguage() (deprecated)

Availability

UltraDev 1; deprecated in Dreamweaver MX.

Description

Determines the server model that is associated with the document and returns that value. The server language for a site is the value that comes from the Default Scripting Language setting on the App Server Info tab in the Site Definition dialog box. To get the return value, this function calls the getServerLanguage() function in the Server Models API.

NOTE

The Default Scripting Language list exists only in Dreamweaver 4 and earlier versions. For Dreamweaver MX or later, the Site Definition dialog box does not list supported scripting languages. Also, for Dreamweaver MX or later, the dom.serverModel.getServerLanguage() function reads the serverLanguage property of the object that is returned by a call to the getServerInfo() function in the Server Models API.


Arguments

None.

Returns

A string that contains the supported scripting languages.

dom.serverModel.getServerName()

Availability

Dreamweaver 1; enhanced in Dreamweaver MX.

Description

Retrieves the server name that is associated with the document and returns that value. The server name differentiates between server technologies (such as ASP.NET and JSP), but does not differentiate between languages on the same server technology (such as ASP.NET VB and ASP.NET C#). Possible values include ASP, ASP.NET, Cold Fusion, JSP, and PHP.

To retrieve the server model name associated with the document, see "dom.serverModel.getDisplayName()" on page 916 or "dom.serverModel.getFolderName()" on page 916.

NOTE

For Dreamweaver MX, or later, dom.serverModel.getServerName() reads the serverName property of the object that is returned by a call to the getServerInfo() function in the Server Models API.


Arguments

None.

Returns

A string that contains the server name.

dom.serverModel.getServerSupportsCharset()

Availability

Dreamweaver MX.

Description

Determines whether the server model that is associated with the document supports the named character set.

NOTE

In addition to letting you call this function from the JavaScript layer, Dreamweaver calls this function when the user changes the encoding in the page Properties dialog box. If the server model does not support the new character encoding, this function returns false and Dreamweaver pops up a warning dialog box that asks if the user wants to do the conversion. An example of this situation is when a user attempts to convert a ColdFusion 4.5 document to UTF-8 because ColdFusion does not support UTF-8 encoding.


Arguments

 metaCharSetString 

  • The metaCharSetString argument is a string value that names a particular character set. This value is the same as that of the "charset=" attribute of a meta tag that is associated with a document. Supported values for a given server model are defined in the HTML definition file for the server model, which is located in the Configuration/ServerModels folder.

Returns

A Boolean value: TRue if the server model supports the named character set; false otherwise.

dom.serverModel.getServerVersion()

Availability

UltraDev 1; enhanced in Dreamweaver MX.

Description

Determines the server model that is associated with the document and returns that value. Each server model has a getVersionArray() function, as defined in the Server Models API, which returns a table of name-version pairs.

NOTE

For Dreamweaver, dom.serverModel.getServerVersion() first reads the serverVersion property of the object that is returned by a call to getServerInfo() in the Server Models API. If that property does not exist, dom.serverModel.getServerVersion() reads it from the getVersionArray() function.


Arguments

 name 

  • The name argument is a string that represents the name of a server model.

Returns

A string that contains the version of the named server model.

dom.serverModel.testAppServer()

Availability

Dreamweaver MX.

Description

Tests whether a connection to the application server can be made.

Arguments

None.

Returns

A Boolean value that indicates whether the request to connect to the application server was successful.

dreamweaver.getServerModels()

Availability

Dreamweaver MX.

Description

Gets the names for all the currently defined server models. The set of names is the same as the ones that appear in the Server Model text field in the Site Definition dialog box.

Arguments

None.

Returns

An array of strings. Each string element holds the name of a currently defined server model.

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net