The PDF generation class requires PEAR (PHP Extension and Application Repository) to be installed. PEAR can be downloaded from http://pear.php.net/ or on UNIX machines installed using the php4-pear package.
The PDF generation class requires HTML2PS to be installed and being executable. HTML2PS can be downloaded from http://user.it.uu.se/~jan/html2ps.html or on UNIX machines installed using the html2ps package.
The PDF generation class requires PS2PDF to be installed and being executable. PS2PDF is part of the GhostScript distribution that can be downloaded from http://www.cs.wisc.edu/~ghost/ or on UNIX machines installed using the gs package.
The Form Maker is useless without it's repositories. All field types and javascripts users will be able to create are defined there. It might be needed to extend the default content of the repositories with custom field types and javascripts. The repositories are, in fact, collections of small HTML templates. Items from the repository can be locked. This means, such an item can't be edited unless the value of the locked field in the database table is set to zero.
Fieldtype repository items consist of a name, description and a HTML template. The template can contain de default TYPO3 markers for groups (<!-- ... -->) and fields (### ... ###). Enclosing a part of the template in group markers will enable users to multiply that template part several times. For example, you can define a radio button and enclose it in group markers so users can create a list of radio buttons using just one field. There are two kind of field markers: system markers and user markers. There are three system markers that are obligatorily: ###SYS:Name###, ###SYS:Id### and ###SYS:Value###. The system markers are used to identify a field. All other markers needed will be user markers that look like this: ###USR: ... ###. User markers will return as option in the 'Fieldtype settings'-wizard.
Javascript repository items consist of a name, description, parameter list and a javascript function. The parameter list is a comma seperated list of parameter names. These names appear in the 'Javascript'-wizard and can be filled in by the user. The parameters can be accessed in the javascript function by the array 'cParams'. This way, the parameters corresponding to a parameter list 'id,name' can be accessed by the variables 'cParams[“id”]' respectivaly 'cParams[“name”]'.
Furthermore, all javascripts from the repository have access to two more variables: cObj and cType. cObj contains the calling HTML object and cType contains the type (next, previous, last, first, etc.) of submit button that is pressed. Therefore, cType is only not empty when a javascript is attached to the onSubmit event.
The javascript function itself is that part of the function that you would normally find between the accodances corresponding to the function statement:
function someJavascriptFunction(someParameter) {<!-- THIS IS THE PART TO SAVE IN THE REPOSITORY -->
}
Javascripts can become quite complex, especially when you are trying to create a javascript which is useable in a great variaty of situations (which is a good thing). Since all references to form objects is done via ID's things can get fuzzy quite fast. In order to prevent a user to drown in ID's and complex attachments of javascripts to multiple events etc. it is possible to create an user friendly interface on top a javascript, such an interface is called a preset.
A detailed description how to use presets is given in the 'Javascript wizard' section in the 'Users manual' section above. The idea behind presets is another layer on top of the advanced options of the 'Javascript'-wizard. Preset are accessed via the 'Presets' page in this wizard, while the advanced options can be accessed via the 'Advanced' page. A preset contains three options which can be set by default or can de set by the user using the interface. These options are translated to one or more javascript attachments. Thus, the results of an preset will also be visible through the advanced options and visa versa the advanced options are matched against the three preset parameters. If a match is found, advanced options will also appear on the preset page.
The three options are a comma seperated list with events, an ID of javascript from the repository and an array with parameter values. Once these parameters are set, the preset will generate one or more javascript attachments. After using the user friendly interface of a preset, the parameter values could look like this:
javascriptEvents= 'onload,onchange'
javascriptID= 1
javascriptParameters= Array(
'text' => 'some text here'
)
This will result in the javascript function with ID 1 to be attached to the onLoad and onChange event of the object that is being editted. Both attachments will send the string 'some text here' as value of the 'text' parameter to that function.
Again, this works in both ways. If you attach the javascript with ID 1 to the onLoad and onChange event of an object and send the same parameters to both attachments, they will apear on the 'Presets' page as one preset. This is, when the javascript id and event are deafult values of the preset and the parameters are user defined. You could also choose to let the events be user defined as well. In that case, all attachments with function ID 1 and the same parameters are collected, no matter the event, and displayed as one preset.
Presets can be complex to understand, play with it and it will become clear soon.
When you created an advanced javascript (or a simple one, but one where the user has to supply fuzzy information like ID's) you might want to create a new preset. This section is a kickstart to your first preset. Presets are saved in PHP files in the extension directory, more precise: in the wizard_javascript/presets directory. Each preset has it's own file. The file contains a PHP class that extends the class 'preset'.
Conf.php file
Once you created a preset, you will have to modify the 'conf.php' file in the wizard_javascript/preset directory in order to let it appear on de 'Presets' page of the 'Javascript'-wizard. This file contains an array that contains all definitions of all available presets. You will need to create a new item in this array, also an array. This array gets the folowing items:
Key: | Value: | Example: |
|---|---|---|
name | Screen name of the preset. | 'Subform' |
description | Screen description of the preset. | 'Make this object hide/unhide one or more subforms' |
file | Filename of file that contains the PHP class for this specific preset. | 'preset_subform.php' |
class | Name of the PHP class for this specific preset. | 'tx_dreformmaker_javascriptpreset_subform' |
tables | Comma seperated list with tables to which this preset might apply. Javascripts can be attached to fields or pages. Some presets will only function well for fields and not for pages or visa versa. This can be managed to modify this list of tables for which the preset do work. | 'pages,tt_content' |
Preset class
All presets extend the 'preset' class which can be found in the 'class.preset.php' file. This class contains all variables and functions necessary to create a valid preset. A preset can be created by overwriting one or more of these functions in the extending class. The variables in the 'preset' class are:
Variable: | Data type: | Description: |
|---|---|---|
javascriptEvent | string | Comma seperated list with events to which the preset applies. Possible events are: onload, onfocus, onblur, onchange, onclick, ondblclick and onsubmit |
javascriptID | integer | ID of the javascript from the repository to which the preset applies. |
javascriptParameters | array | Array of all parameters defined for the javascript defined with javascriptID and the values that has to be used when saving a preset. |
javascriptOriginal | array | Same as javascriptParameters, but in this variable the original values of the preset are stored. This means, this variable is only used when editting a preset. When a preset is modified, but the user decides not to save it, these parameters are used to undo the changes. |
The functions in the 'preset' class are:
Function: | Parameters: | Return: | Description: |
|---|---|---|---|
init | array original, optional string event, optional integer id, optional array parameters, optional | void | Initializes the preset. Based on the given parameters the preset variables are set. This function can be overwritten in order to set a few of the parameters by default, thereby restricting the scope of the preset. |
loadWizard | string | Returns the HTML content of the wizard itself. Normally this is a form, the submit buttons do not have to be included. This function has to be overwritten, otherwise an error message 'Preset doesn't contain a wizard' will be shown and the preset exits. | |
getSummary | array javascripts array parameters | array | Looks for matches in the existing javascript attachments with the preset. Returns an array which is used by the 'Javascript'-wizard to show a nice list with defined presets and options to delete and edit them. The array has the following structure (two matches found): Array ( [0] => Array ( [id] => list with javascript ID's [event] => list with events [function] => function ID [parameters] => Array ( [parameter1] => value1 [parameter2] => value2 ) ) [1] => Array ( [id] => list with javascript ID's [event] => list with events [function] => function ID [parameters] => Array ( [parameter1] => value1 [parameter2] => value2 ) ) ) You probably don't want to overwrite this function, but want to modify the results before sending them to the 'Javascript'-wizard. For this purpose, the 'modifyDefaultSummary' function is defined. |
modifyDeafultSummary | array summary | array | Before the summary array created by the 'getSummary' funtion is returned to the 'Javascript'-wizard it's send to this function. By default, this function returns the array untouched, but you might want to overwrite this function to modify the summary array. This could be useful to replace ID's for names, for example, to make also the summary user friendly. |
updateJavascriptSettings | array javascripts array parameters | array | Modifies the javascript settings array based on the preset parameters. These settings are used throughout the extension and will appear on the 'Advanced' page of the 'Javascript'-wizard as well as in the 'Javascript' field of the properties page of the object being editted. |
updatePresetParameters | void | Handles the submission of the wizard. The 'loadWizard' function creates a form. Once the form is submitted, this function modifies the preset parameters based on the parameters from the wizard. This function is empty, by default, so has to be overwritten will a preset need to make any sense. |
WARNING: at this moment self made presets are probably overwritten when updating [drecomm] Form Maker. Please backup all your presets before updating. Put them back after the update is completed.