Web Script Reference

PhotoWarp communicates information about the current job to a web script through a job description file. This is an XML text file that contains all information needed by a particular web script, including all known meta information about a job, a source, and its outputs. The description file is never seen directly by a script, but rather is parsed by a PHP function into an associative array, called $job.

The parsing function is included in a private prefix file maintained internally by PhotoWarp. The name of the file is passed in the environment variable PW_PREFIX_FILE to the script, which should include the file before any other script code is reached:

<?php
include($_ENV["PW_PREFIX_FILE"]);
?>

The prefix file may be changed at any point in the future to provide new or improved capabilities, which is why it is maintained privately by PhotoWarp. Updates may be provided through PhotoWarp's auto update capability, or through new versions of the application itself.

Job Description Variables

$job is the global variable used by web scripts to access information passed in by PhotoWarp. Several shorthand variables are also defined by the prefix file for convenience, which are expressed below.

Tip

For a complete list of all values in a job description array, run the Debug web script on a job and view the resulting HTML file in your browser.

$job Top level variable. Contains values pertaining to the job itself.
$job['name'] Name of the job file
$job['options'] Job-level options. Usually ignored.
$script Settings pertaining to the current web script.
Same as $job['script'].
$PW_IndexURL Link to the index file for this job (if available).
Same as $script['index']['link_url'].
$script['options']
['ScriptOutputList']
An indexed array of each output to be represented by this script. Attributes include the format name, base format, template, and all options for the output.
$PW_IsIndex True if this output represents an index.
Same as $script['options']['ScriptIsIndex'].
$PW_UseJavaFallback True if this script should use the automatic fallback script. Usually only ShowPano() needs to know this.
$script['options']['ScriptUseJavaFallback']
$sources An indexed array of each source to be represented by this script. For singleton scripts, this will contain only one element, $sources[0].
Same as $job['sources']
$source Not actually set by the prefix file, but a useful convenience provided within a script. For singleton scripts, set $source = $sources[0]. For indices, $source is set in a while loop to the value of the current source to be represented.
$source['name'] Name of the current source. This defaults to the source file name, but may be renamed in PhotoWarp to something more appropriate.
$source['path'] Local path of the current source image.
$source['options'] Calculated option values for this source, including pan and tilt constraints and resolution.
$source['exif'] EXIF values retrieved from this source image, if present. These are the same values displayed in the Inspector/Details pane for the source.
$source['outputs'] Settings for each output representing the source.
$source['pages'] An array of pages generated for this source. $source['pages'][n]['link_url'] contains the relative URL for each page.

Prefix Functions

In addition to parsing the job description file, the prefix file contains several PHP functions for added capabilities or easier access to the contents of the description file.

ScriptHeader()

ScriptHeader() should be called in the <head> section of an HTML document. This includes Javascript code necessary for the Java fallback capability.

BodyArgs()

Provides a mechanism for the prefix file to include Javascript events in the page body. Presently this functionality is unused.

ShowPano($source)

ShowPano() generates HTML to display the pano for the given source. This function will generate the appropriate code for standard images, Java viewers, and QuickTime movies, as well as the Java fallback behavior.

Customizing embedded panoramas

You can add additional parameters to QuickTime VR, Zoom Viewer or PTViewer embedding tags. Create a new array variable with one of the following names, and set the parameters as needed.

The following code sample hides the controller bar and activates kiosk mode for a QuickTime VR movie:

$PW_QTVRParams = new array();
$PW_QTVRParams['autoplay'] = "true";
$PW_QTVRParams['kioskmode'] = "true";

ShowPano($source);