WSSP Scripting |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The following is a sample of an WSSP document:
|
This WSSP document contains the %%server%%, %%ID%%, and %%lastLogin%% text elements, and the <!--%%IF EXISTS(lastLogin)--> and <!--%%ENDIF--> structural elements (these text elements are ficticious, do not try to use these samples in your real .wssp pages).
If the WSSP document should contain non-ASCII symbols, the UTF-8 character set should be used. When the WSSP document is being processed, the Web Application module retrieves the charset string value from the produced data dictionary. If this value is not UTF-8, then the WSSP text is converted into this page charset.
The WSSP scripting uses several types of expressions:
An alphanumeric string (such as system or id) is
a data element name. The value of such an expression is the dataset value associated
with this name. If the dataset does not have a specified key, the expression value is NULL.
Example: the dataset contains the key system and its associated value is
the Sun Solaris string, the value of the expression system is the string
Sun Solaris.
The dataset dictionary is case-insensitive, so the data element names are case-insensitive, too.
An alphanumeric string followed by the [] symbols is interpreted as an array scanner name. It can be used only inside the <!--%%FORALL name...--> ....<!--%%ENDFOR name--> structure where this array element is defined (see below). The array scanner names are case-insensitive.
An expression followed by the dot symbol (.) and an alphanumeric string is a keyed element. The expression before the dot symbol is calculated, and its value should be a dictionary. The alphanumeric string after the dot sign specifies the key to be used to extract the value from that dictionary. If the value of the expression before the dot sign is not a dictionary, or if it does not contain the specified key, the keyed element value is NULL.
Keys can be specified as quoted strings, in this case they can specify non-alphanumeric symbols.
Example: the dataset contains the key settings and its associated value is
the 2-element dictionary: {OS = "Sun Solaris"; CPU = "sparc";}. The value of the
settings.OS expression is the Sun Solaris string, the value of
the settings."OS1" expression is NULL.
An expression followed by an index expression in square bracket symbols ([index])
is an indexed element. The expression before the square bracket is calculated, and its value should be
an array. The index expression is calculated, and its value should be a string representing a number.
This number specifies which array element becomes the value of this indexed expression. The first
array element is retrieved if the value of the index expression is 0.
If the value of the expression before the bracket symbol is not an array, or if the value of the index expression
is not a string, or if the value of the index expression represents a number that is negative or
is equal or greater than the number of array elements, the value of the indexed element expression
is NULL.
An alphanumeric string followed by the ( symbol is a function call. Elements after the ( symbol specify the function parameters, and they are followed by the ) symbol.
Function names are case-insensitive.
The following list specifies the available functions and their parameters.
The session dataset is case-insensitive. It contains the following keys and values:
Key | Value |
---|---|
ID | a string with the unqiue identifier of this session |
accountName | a string with the session Account name |
domainName | a string with the name of the Domain the session Account belongs to |
filesRef | a string with the URL prefix needed to retrieve files from the session Skin |
fullAccountName | a string with the session Account full name: accountName@domainName |
loginAddress | a string specifying the network (IP) address the user was using when initiating this session |
loginTime | a string with the session start time in the ACAP format |
mailboxes | an array with the names of "selectable" mailboxes |
selectedMailbox | a string with the name of the target mailbox for the last Copy/Move operation |
webFolders | an array the Personal File Site folder names |
selectedWebFolder | a string with the name of the target File Site folder for the last Store File In operation |
webSiteEnabled | this YES string element exists if the storage limit for the Personal File Site is not set to zero |
Logical expressions are two expressions separated with a | (OR) sign or with a & (AND) sign. You can also use parentheses to enclose expressions:
The string should contain some number and, optionally, the k or K suffix (in this case the number is multiplied by 1024), or the m or M suffix (in this case the number is multiplied by 1048576). Alternatively, a string can start with a letter u or U, in this case the converted number of bytes is -1.
The resulting number is converted into a "size string", using the dictionary retrieved with the DICTIONARY("SizePictures") expression. If the number is negative, the dictionary is used to translate the string unlimited, and the result is used to replace this text element using the same convertions as used for the a text element with the HTML: prefix.
The calculated number of bytes is checked to see if it represents an even number of Megabyte or Kilobytes, and that number is greater than one. Then a string value associated with the keys "M", "K", or "" (empty string) is retrieved from the dictionary. The string is expected to contain the ^0 symbol combination which is replaced with the number of megabytes, Kilobytes, or bytes specified with the expression value. The resulting string is processed with the method used for the HTML: text element prefix.
If the DICTIONARY("SizePictures") expression result is NULL, or this dictionary does not contain a string value for the required key, the resulting string is built using the number and the key name (20M, 1345K, 182345777).
The string should contain some number and, optionally, the s or S suffix, or the m or M suffix (in this case the number is multiplied by 60), or the h or H suffix (in this case the number is multiplied by 3600), or the d or D suffix (in this case the number is multiplied by 86400).
The resulting number is converted into a "time string", using the dictionary retrieved with the DICTIONARY("TimePictures") expression.
The calculated number of seconds is checked to see if it represents an even number of weeks, days, hours, or minutes, and if that number is greater than 1. Then a string value associated with the keys weeks, days, hours, minutes, or seconds is retrieved from the dictionary. The string is expected to contain the ^0 symbol combination which is replaced with the number of weeks, days, hours, minutes, or seconds specified with the expression value. The resulting string is converted from the UTF-8 into the required charset and the converted string substitutes the text element using HTML escape symbols.
If the DICTIONARY("TimePictures") expression result is NULL, or this dictionary does not contain a string value for the required key, the resulting string is built using the number, a space, and the key name (3 weeks, 11 hours, 5 seconds).
If the DICTIONARY("TimePictures") exists and contains the string "^0mins" as the minutes value, then the text element %%TIME:elapsedTime%% will be substituted with the 40mins string.
symbols | substituted with |
^D | the day of month (2-digit) |
^d | the day of month (1- or 2-digit) |
^M | the month name (one of those returned with the MONTHNAMES() function), translated using DICTIONARY("DatePictures") |
^N | the month number (2-digit, from 01 to 12) |
^Y | the year number (2-digit) |
^y | the year number (4-digit) |
^s | the seconds value (2-digit) |
^m | the minutes value (2-digit) |
^H | the hours value (2-digit), from 00 to 23 |
^h | the hours value (1- or 2-digit), from 12,1 to 11 |
^t | the AM or PM suffix, translated using DICTIONARY("DatePictures") |
^w | the weekday number (Sun - 0) |
^W | the weekday name (one of those returned with the WEEKDAYS() function), translated using DICTIONARY("DatePictures") |
The value of the expression is calculated, and if it is a string and that string does not start with one of the symbols N, n, -, or 0, the portion of the script between the <!--%%IF expression--> element and the <!--%%ELSE--> element is processed. If the <!--%%ELSE--> element does not exist, the portion of the script between the <!--%%IF expression--> element and the <!--%%ENDIF--> element is processed.
If the expression result is not a string, or it is a string that starts with one of the listed symbols, the portion of the script between the <!--%%ELSE--> element and the <!--%%ENDIF--> element is processed. If the <!--%%ELSE--> element does not exist, the portion of the script between the <!--%%IF expression--> and <!--%%ENDIF--> elements is removed completely.
If the dataset does not contain the lastLogin element,
this script portion will produce
Welcome, new user!
The value of the expression is calculated. The resulting value should be an array.
The portion of the script between the <!--%%FORALL scanner ...--> and <!--%%EMPTYFOR scanner-->
elements or (if the <!--%%EMTPYFOR scanner--> element does not exist)
the portion of the script between the <!--%%FORALL scanner ...--> and <!--%%ENDFOR scanner-->
elements is processed repeatedly, for each array element.
Expressions specified in that portion of the script can use the scanner[] array scanner reference to access the current element of the expression array value.
If the expression value is not an array or if it is an empty array, and the <!--%%EMPTYFOR scanner--> element is specified, the portion of the script between the <!--%%EMPTYFOR scanner--> and <!--%%ENDFOR scanner--> elements is processed. If the resulting array has at least one element, this portion is not processed.
If the fileList value is
({name=MyReport; size=2300;},{name="My Old Report"; size=4000;})
then this portion of the script will produce the following HTML code:
<TABLE BORDER=1>
<TR><TD>File Name</TD><TD>File Size</TD></TR>
<TR><TD>MyReport</TD><TD>2300</TD></TR>
<TR><TD>My Old Report</TD><TD>4000</TD></TR>
</TABLE>
The <!--%%IF ...--> ...<!--%%ELSE--> ...<!--%%ENDIF--> constructs and the <!--%%FORALL ...--> ... <!--%%ENDFOR ...--> constructs can be nested.
It is recommeded to use the .wssi file name extension for files designed to be used with the INCLUDE element.
The INCLUDE elements can be nested, this means that .wssi files can include other .wssi files.
Unlike the #include operators in the C and C++ languages, this operator is a real, not a pre-processor operator. As a result, if an <!--%%INCLUDE filename--> element is used within a <!--%%FORALL ...--> ... <!--%%ENDFOR ...--> construct, the filename code can be executed several times, once for each element of the array used in the FORALL construct.
The number of elements and the value used for each element are defined by the list of numeric numbers - number1,number2,....,numberN. These numbers should be specified in the ascending order, and these numbers should not be less than -1.
The selected expression is calculated, and its value should be a string. The string numeric value is used to add the keyword SELECTED to the <OPTION VALUE="value"> element that has the same value.
The DISPLAY keyword and the dictionary expression can be omitted. In this case, the presentation strings are the same as the value strings, this means that these strings are numbers.
If the DISPLAY keyword and the dictionary expression are specified, the expression is calculated. If the expression value is a dictionary, then the presentation strings are the numeric values "translated" using this dictionary, the results are converted into the required charset and placed using the HTML escape symbols.
If the keyword DEFAULT with the selectedDefault expression are specified, an additional <OPTION VALUE="-2">defaultPresentation string is added before the sequence. If the selected expression value is NULL, this string element will have the keyword SELECTED added.
The defaultPresentation string is the DefaultValuePicture string retrieved from the Skin Text Dataset. This string should contain the ^0 symbol combination. This symbol combination is substituted with the selectedDefault expression value. If the DISPLAY dictionary is specified, the selectedDefault expression value is translated first.
Values are translated using the specified DISPLAY dictionary. If the DISPLAY dictionary is not specified or it does not contain a string for the given value, the presentation time strings are composed using the same method as the method used for the TIME: text elements.
Values are translated using the specified DISPLAY dictionary. If the DISPLAY dictionary is not specified or it does not contain a string for the given value, the presentation size strings are composed using the same method as the method used for the SIZE: text elements.
The number of elements and the value used for each element are defined by the value of the valueSet expression. This value should be an array of strings. The value in each element is the string index in the valueSet array result.
The selected expression is calculated, and its value should be a string. The keyword SELECTED is added to the <OPTION VALUE="value"> element created for the the valueSet array element that matches the selected expression result.
The DISPLAY keyword and the dictionary expression can be omitted. In this case, the presentation strings are the same as the valueSet result elements.
If the DISPLAY keyword and the dictionary expression are specified, the expression is calculated. If the expression value is a dictionary, it is used to "translate" the valueSet array strings before converting them into the required charset and placing into the resulting markup text using the HTML escape symbols.
If the keyword DEFAULT with the selectedDefault expression are specified, an additional <OPTION VALUE="-1">defaultPresentation string is added before the sequence. If the selected expression value is NULL, this string element will have the keyword SELECTED added.
The defaultPresentation string is the DefaultValuePicture string retrieved from the Skin Text Dataset. This string should contain the ^0 symbol combination. This symbol combination is substituted with the selectedDefault expression value. If the DISPLAY dictionary is specified, the selectedDefault expression value is translated first.
Unlike the ENUMMENU element, this element does not contain the IN valueSet part: the built-in array (NO,YES) array is used instead.
The values of the selected and selectedDefault expressions are converted in the
same way as they are converted for a text element with the MAILBOXNAME: prefix, using the
MailboxNames dictionary from the Skin Text Dataset, this is why MAILBOXMENU elements do not
have the DISPLAY part.
If the NOINBOX keyword is specified, the INBOX mailbox (if exists in mailboxList) is not displayed.
The time values are generated from the midnight (00:00) till 23:59 with the timePeriod step (specified in minutes). If the PERIOD keyword and the timePeriod value are not specified, the 30 minutes (1800 seconds) step is used. If the PERIOD keyword is specified, the timePeriod value can be either a numeric constant specifying the period in minutes, or an expression. The expression value is calculated and converted to a number. This number specifies the period in seconds.
The selected and selectedDefault expressions should have numeric values - the currently selected (and the default) time-of-day (seconds from midnight).
The selected expression value should have a date-type value. The time part of that value is used as the currenly selected time-of-day value.
The selected expression value should have a date-type value. The value is converted to the local time zone, and time part of the converted value is used as the currenly selected time-of-day value.
If the specified time is more than before days earlier than the current date or if it is more than after days later than the current date, then this element is substituted with a text with several text controls. Otherwise a menu control is composed.
The before and after values should be specified as numbers.
If the before value is not explicitly specified, it is set to 7.
If the after value is not explicitly specified, it is set to 31.
If the CANNEVER keyword is used, the control menu displays the Never item with the remote future date value. If the selected value
is equal to the remote future value, a menu control is composed.
To compose text controls, the dateOnly format string is taken from the DatePictures dictionary, and the text control codes are used to substitute its ^D, ^M, ^Y, and ^y symbol combinations. Each control has the specified name with a prefix: the day control has the name-D name, the month control has the name-M name, the 2-digit year control has the name-Y name, and the 4-digit year control has the name-y name.
If a menu is to be composed the SELECT markup language element is generated. It has the specified name name.
The menu contains an element for the current date, before elements for the previous dates, and after elements
for the future dates. The elements are formatted using the dayAndMonthDate format string from
the DatePictures dictionary.
An additional element with the ... text is added for the "after+1" date. When this element
is selected, the selected date value moves outside the "menu-covered" range, allowing the user to use text controls and select an arbitrary date.
The selected expression value should have a date-type value. The value is assumed to be expressed in the global (GMT) terms, so the value is converted to the local time first.