Generic Control Panel system documentation

  1. What it does
  2. How to program the Generic Control Panel system
    1. General syntax
    2. Basic structure
    3. Form elements
    4. Enforced Referential Integrity
  3. Reference
  4. Example .cgf file

What it does

The Generic Control Panel system allows the quick and easy creation of control panels for a table in a database, allowing for addition, alteration and deletion of data whilst enforcing referential integrity if necessary.

How to program the Generic Control Panel system

To create a control panel for the Generic Control Panel system, the definitions for the control panel must be stored in a text file with a .cgf extension in the directory specified by the system (by default, the system searches for .cgf files in the ./cgf folder).

General syntax

Each tag is specified in square brackets [ ] and will always have a matching end tag [/ ]. Any parameters for a tag are specified between the start and end tag in the form xxx="yyyy" Note that the quotes are always necessary even if the value is numeric.

Basic structure

A .cgf file in it's simplest form comprises of a title, a database definition, a master table definition and at least one form element. EG:

[title]Companies[/title]
[database]
dsn="addressbook"
uid="eb0s0021"
pwd=""
[/database]
[master]
table="company"
uKey="company_id"
nameField="company_name"
autoUpdate="false"
x="0"
y="40"
[/master]
[input]
caption="Company name"
field="company_name"
datatype="text"
x="250"
y="40"
[/input]

The [title] tag indicates the title that will appear on the button for the control panel and also on the control panel itself as the main heading.

The [database] tag contains all the information on how to connect to the database that the table to be administered is in. This is done either by specifying a dsn, uid and password (dsn, uid, pwd) or by providing a complete connection string (using the connectionString parameter).

The [master] tag specifies the table (and other necessary values) which is to be administered using the Generic Control Panel system. It requries the table name (table), the unique key of the table (uKey) which must be numeric, the name field (nameField) which is the field that will be displayed in the list of records, whether or not the list of records should update automatically (autoUpdate) - can be either "true" or "false", and the x and y coordinates (x,y) of the position that the list of records should be placed in.

Form elements

There are currently 5 types of form elements. Input boxes ([input]) which allow for either numeric (int, shortint, numeric etc.) or text (char, varchar) fields, select boxes ([select])/muliableselect([clselect]) which allow selection of a value from another table, checkboxes ([checkbox]) which allow for boolean (bit) values and text area's ([textarea]) free text to meno fields.

Enforced Referential Integrity

In order to preserve referential integrity within the database (ie. in a relational database, deleting an item in one table that is referenced by an item in another table would break referential integrity), the [eri] tag is provided to make the system first checks to see if the record can be deleted safely in as many table as needed.

The [eri] tag has the following parameters:

Each [eri] tag included in the control panel instructs the system to check against a specified field (foreignKey) with datatype (datatype) in a table (table) (if dsn, uid & pwd or connectionString are specified it uses that to connect otherwise it uses the connection of the master table) to see if the record is referenced by any records in that table.

If the user tries to delete a record that is referenced by records in another table, the system will display an error message (errorMsg) and a list of the records (displaying the nameField and ordered by orderField) and can then (if desired) provide the user with a means of resolving the problem. This functionality is specified by the two boolean parameters: merge & delete.

If 'merge' is true then the system will, on encountering a record that cannot be deleted, provide the user with the means to change any records in other tables that point to the record to point to some other record in the same table.

If delete is true then the system will, on encountering a record that cannot be deleted, provide the user with the ability to delete the records in the table that point to the offending record.

If both merge and delete are true then the user will have the option to choose which action to perform.

If neither merge or delete is true then the system will simply not allow the record to be deleted.

Hidden Files

All .cgf files go into a folder called 'cgf'. The sub folders inside the generic folder each have a folder name which is used as the title of the page. The folders may be hidden by adding a @ sign in front of the first character of the folder name and therefore the folder is hidden.

Also the files within the folders can be hidden too. This is also done by placing a @ sign in front of the first character of the file name.

Calling of a file with the full menu

A file can call by using either a querstring or form with the id of genricfile and the value the subdicrtory/filename (?genricfile=northwind\northwind.cgf)
see ref,readonly

Calling of a subfolder

A file can call by using either a querstring or form with the id of load and the value the subdicrtory/filename (?load=northwind\northwind.cgf)
see ref,readonly

Calling of a record

A record can called by using either a querstring or form with the id of ref and the value the from the Ukey paramerter in the [master] section of your .cgf file.
see readonly

making a record read only

A record can be made readonly by using readonly = "true" in the input sections of your .cgf file.

making a record update

A record can be made updateonly by using updateonly = "true" in the [master] section of your .cgf file.

Functions

Announcements (String):

The String is optional and can be written as follows: Announcements(""). Therefore if this is used, the function will use the system's ("live") variable in order to work out the announcements group.

If String=text, then the announcements will use this as the Name of the announcements group and bring up all announcements relevant to the text name i.e. Samples.

If String=number, then the announcements will show the announcement as a number by

Reference

[checkbox]

Type:
Form element
Parameters:
caption - Text to appear to the left of the checkbox
field - Field in the table that this element is linked to
x - Distance from the left side of the page to the element
y - Distance from the top edge of the page to the element
readonly - makes it a readonly imput

[database]

Type:
Required definition element
Parameters:
dsn - Name of the Data Source to connect to
uid - User ID to connect with
pwd - Password for the chosen user ID
dbtype - set this if you are not using ms sql comma seperated list
values are:-
  nomax for do not use the sql max funtion (ms access)
connectionString - Can be specified instead of dsn, uid & pwd to provide greater control over the database connection. If this is specified, any values in dsn, uid or pwd are ignored

[eri]

Type:
Special
Parameters:
dsn - Name of the Data Source to connect to - if none is specified then the system uses the DSN of the master table instead
uid - User ID to connect with
pwd - Password for the chosen user ID
connectionString - Can be specified instead of dsn, uid & pwd to provide greater control over the database connection. If this is specified, any values in dsn, uid or pwd are ignored
table - The table to check for referential integrity
foreignKey - The field to check for referential integrity
datatype - The datatype of the foreignKey
nameField - Name of the field(s) to be displayed
orderField (optional) - Order of the field(s) to be displayed - if none is specified nameField is user
errorMsg - Error message to be displayed
merge - (true/false) If true, the user is provided with the ability to re-point records to a different record
delete - (true/false) If true, the user is provided with the ability to delete the linked records
Note:
See the section on Enforced Referential Integrity for full details

[input]

Type:
Form element
Parameters:
allowNull - For numeric datatype, allows the user to leave the input box blank
caption - Text to appear to the left of the input box
field - The field in the table that is linked to the input box
datatype - Either "number" or "text"
maxlength (optional) - Maximum length of the field
obscure (optional) - (true/false) If true, the text in the field is shown as asterisks (stars)
x - Distance from the left side of the page to the element
y - Distance from the top edge of the page to the element
readonly - makes it a readonly imput

[master]

Type:
Required definition element
Parameters:
table - The table which contains the data to be administered by this control panel
uKey - The field that is the unique key in the master table. Note that this field must be numeric. If the database has a composite key use a comma seperated list
nameField - The field that is to be displayed in the master select box. If more than one field is to be displayed, enter them as a comma-separated list
orderField (optional) - The field to order the master select box list by. If none is specified it will use the nameField. Again, this can be a comma-separated list if it is needed to order by more than one field
autoUpdate - (true/false) - specifies whether or not to automatically update the list of fields whenever an item is added, edited or deleted
x - Distance from the left side of the page to the master select box
y - Distance from the top edge of the page to the master select box
foreignUkeyField - Comma-seperated list that is mandatory if the uKey is a composite key
nameTable - Comma-seperated list that is mandatory if the uKey is a composite key
updateonly - (true/false) disables deleting and adding

[required]

Type:
Optional definition element
Parameters:
The contents of the tag is the only parameter. Specifies the access rights with the login system that are required to access this page. (see Login System documentation for more details)

[select]

Type:
Form element
Parameters:
allowNull - If this is true, provides a null option for the user to select as well as any other available options
caption - Text to appear to the left of the select box
table - The table which contains the data that fills the select box
field - The field in the master table that is linked to the select box
datatype - Either "number" or "text"
nameField - The field in the specified external table that contains the data to be displayed to the user in the select box
orderField (optional) - The field in the specified external table that contains the order to display the data to the user in the select box. If none is specified, the nameField is used instead
localKey - The unique key in the specified external table
x - Distance from the left side of the page to the element
y - Distance from the top edge of the page to the element
readonly - makes it a readonly imput

[clsselect]

Type:
Form element that allows for multiple selects
Parameters:
allowNull - If this is true, provides a null option for the user to select as well as any other available options
caption - Text to appear to the left of the select box
table - The table which contains the data that fills the select box
field - The field in the master table that is linked to the select box
datatype - Either "number" or "text"
nameField - The field in the specified external table that contains the data to be displayed to the user in the select box
orderField (optional) - The field in the specified external table that contains the order to display the data to the user in the select box. If none is specified, the nameField is used instead
localKey - The unique key in the specified external table
x - Distance from the left side of the page to the element
y - Distance from the top edge of the page to the element
readonly - makes it a readonly imput

[textarea]

Type:
Form element
Parameters:
allowNull - If this is true, provides a null option for the user to select as well as any other available options
caption - Text to appear to the left of the select box
field - The field in the master table that is linked to the text area box box
x - Distance from the left side of the page to the element
y - Distance from the top edge of the page to the element
width - The width of the text box
height - The height of the text box
readonly - makes it a readonly imput

[title]

Type:
Required definition element
Parameters:
The contents of the tag is the only parameter. Specifies the title to be used on the control panel and on the button used to select the control panel

Example .cgf file

The following code is a full example of a .cgf file. This control panel is used to administer the "country" table in the lookup database. It has inputs for the country name and country abbreviation code, it has a select box to select the language spoken in that country. 3 other tables reference countries in the country table so referential integrity checks are included for these.

[title]Countries[/title]
[required]64[/required]
[database]
dsn="lookup"
uid="eb0s0004"
pwd=""
[/database]
[master]
table="country"
uKey="country_id"
nameField="country"
x="0"
y="40"
[/master]
[input]
caption="Country name"
field="country"
datatype="text"
x="250"
y="40"
[/input]
[input]
caption="Country code"
field="code"
datatype="text"
maxlength="3"
x="250"
y="70"
[/input]
[select]
allowNull="true"
caption="Primary language"
table="languages"
field="language_id"
datatype="number"
nameField="language_name"
localKey="id"
x="250"
y="100"
[/select]
[eri]
dsn="samplesystem"
uid="uk90483"
pwd=""
table="samplestores"
foreignKey="country_id"
datatype="number"
nameField="store_name"
errorMsg="One or more records in the samplestores table refer to the item you are trying to delete. These record(s) are:"
merge="true"
delete="false"
[/eri]
[eri]
dsn="addressbook"
uid="eb0s0021"
pwd=""
table="location"
foreignKey="country_id"
datatype="number"
nameField="address1,address2"
errorMsg="One or more records in the location table refer to the item you are trying to delete. These record(s) are:"
merge="true"
delete="false"
[/eri]
[eri]
dsn="lookup"
uid="eb0s0004"
pwd=""
table="state_zone"
foreignKey="country_id"
datatype="number"
nameField="state_zone_name"
errorMsg="One or more records in the state_zone table refer to the item you are trying to delete. These record(s) are:"
merge="true"
delete="false"
[/eri]