Class comprising functionality which allows a database table to be maintained through a user interface which allows the usual Add, Modify, Delete options, but which gets just about all the info it requires from the database schema itself. A dynamic maintainer.
Example of usage: consider a table 'foo' with an integer key field named 'bar', which comes from a sequence. It also has a field 'desc' of type 'text', and a foreign key field 'user_id' of type 'text' which refers to 'uuser.user_id'. For the sake of demonstration it also has a field 'auth_code' which we only ever want to view, a field called 'special' which we always want hidden, and a field called 'blurb' which is a memofield of specific sizing.
To maintain 'foo' you might then proceed as follows. Note that a lot of methods have been used here for illustration, but in fact you might easily use a lot less in real life.
$maint = new maintainer("Foo Maintenance", "foo"); $maint->set_title("Setup Users"); $maint->set_fieldsequence("bar", "seq_bar_id"); $maint->set_labelfields("uuser", "full_name"); $maint->set_nonblankfields("full_name,user_type,email"); $maint->set_hiddenfields("special"); $maint->set_viewonlyfields("auth_code"); $maint->set_fieldlabel("auth_code", "Authorization code"); $maint->set_fieldsize("blurb", 300, 250); $maint->set_datetimeformat("last_login", "M j H:i"); $maint->view_primary_keys(); $maint->view_record_filter(); ... $RESPONSE->plugin("MAIN_CONTENT", $maint->render());
Located in /maintainer-defs.php (line 108)
RenderableObject | --StylableObject | --HTMLObject | --maintainer
True if maintainer has been activated
Current record/row
The name of the database containing the table
Array of detail tables. Master-detail relationship.
If true we auto-detect sequences for integer fields,
Maintainers form encoding type
Name of form we will be using
Array of joined tables. Tables with a 1-to-1 link.
Array of linked tables. Tables forming many-to-many link.
Array of messages to display at the top of the maintainer.
If true, password field content is encrypted
True if record is valid
Row count - total records in table
Database schema
If true we include a built-in record filter
If true, status bar is displayed
Table requiring maintenance (object)
Title of this maintenance page
True if this maintainer is good to go
If true, password field content is displayed
If true, primary keys are displayed
Inherited from HTMLObject
HTMLObject::$accesskey
HTMLObject::$align
HTMLObject::$alt
HTMLObject::$bgcolor
HTMLObject::$bgurl
HTMLObject::$border
HTMLObject::$color
HTMLObject::$height
HTMLObject::$hspace
HTMLObject::$lang
HTMLObject::$langdir
HTMLObject::$linkover_text
HTMLObject::$name
HTMLObject::$onblur
HTMLObject::$onchange
HTMLObject::$onclick
HTMLObject::$ondblclick
HTMLObject::$onfocus
HTMLObject::$onkeydown
HTMLObject::$onkeypress
HTMLObject::$onkeyup
HTMLObject::$onload
HTMLObject::$onmousedown
HTMLObject::$onmousemove
HTMLObject::$onmouseout
HTMLObject::$onmouseover
HTMLObject::$onmouseup
HTMLObject::$onselect
HTMLObject::$size
HTMLObject::$src
HTMLObject::$tabindex
HTMLObject::$target
HTMLObject::$user_attributes
HTMLObject::$valign
HTMLObject::$vspace
HTMLObject::$width
Inherited from StylableObject
StylableObject::$class
StylableObject::$id
StylableObject::$style
Create a new maintainer.
Auto-detect sequences for integer fields. The technique is to assume sequences are named after the field in the form: 'seq_{fieldname}' and if so then this sequence is associated with the given field named {fieldname}.
Associates a detail table with the maintained table. This defines
the standard Master->Detail relationship where there are many detail records for each master record. This results in a special multi-record widget in which the detail records for the current master record can be maintained.
Specify that the maintainer should not auto-detect sequences which
pertain to fields on the table. The default action is to look for sequences for all integer fields. This method allows you to turn this feature off, in case it is getting in the way. You can then use the set_fieldsequence() method
Specify whether the maintainer should show its status bar or not.
The initial default is that it is shown.
Render the maintainer as HTML. Use the render() method rather than directly calling this method.
Associates a table with the maintained table. This is a table with a 1-to-1 or 1-to-many relationship with the table being maintained.
We currently support the '1-to-1' link where the joined table data is merged into the main table. This method will therefore cause that joined table's data to be maintained alongside the main data, as accessed via the join fields provided. The $joinfields should be a comma-delimited string of the following form: 'fieldA=fieldB,fieldX=fieldY' Where the first field is the one in the table being maintained, and the second the equivalent in the joined table. If only one field is supplied, it is assumed to be identically named in both.
Associates a table with the maintained table via a link-table.
This defines the standard threesome which makes up a many-to-many link, and where the middle link-table consists only of the key fields common to both main tables. This method will cause the link table to be maintained via either a group of checkboxes, or a multiple select dropdown menu (combo box). NB: This mechanism assumes that the field-naming follows the convention whereby the link-table key is composed of keyfields which are named identically to the keyfields in each of the linked tables (the maintained one and the linked one).
Restrict access. Use this method to restrict maintainer access to the specified group membership. This will cause the RESPONSE to be sent without any content.
Sets a datetime format string for a specified field. This influences the formatting of displayed dates and/or times in that field.
Specify that the given fields should be disabled, not editable. Field is seen on screen, but is not modifiable.
Associates a string of text 'blurb' with the field. This will be presented just sitting below the field as explanatory text.
Sets the CSS style/class for a field.
Associates a function with the field which will be called when data is displayed to format the content. Only really useful for text/memo/numeric fields. The function should accept a string content parameter, and return the re-formatted string content.
Sets the label of the field, which then takes the place of the default naming which uses a proper-cased version of the field name, with underscores replaced by spaces.
Associates a function with the field which will be called when data is POSTed to format the content. Only really useful for text/memo/numeric fields. The function should accept a string content parameter, and return the re-formatted string content.
Associates a named sequence with a field. This is so we can create new records using that sequence to populate the record field.
Notes: the maintainer will, as default, try to detect sequences for integer fields. @see disable_autosequence method.
Sets the size of the field in pixels, width x height
Sets the type of a text field. This is a generic type and the
possibilities are: 'text' Standard text field 'password' Rendered as a password field, and a confirm field 'memo' Standard textarea widget 'image' Text field which contains an image which is displayed
Associates a function with the field which will be called when data is POSTed to validate the content. The function should accept a string content parameter, and return true (if valid) or false.
Specify the maintainers form encoding type. This will enable us to use file upload fields within the maintainer.
Use given user interface element for maintaining specified table field.
Set the name of the form we should use. Sometimes this is useful when other entities are using the same form.
Specify that the given buttons should be hidden. BY default all the usual buttons are available. This method allows you to list those which should NOT be shown. Possible button names are: 'save', 'reset', 'add', 'remove', 'cancel', 'refresh'.
Specify that the given fields should be hidden, not editable. Value will be submitted on POST (save) via hidden field in form.
Associates a list of fieldnames on a table to use as the label for a drop-down select reference. This is mainly so you can specify meaningful label strings for drop-down selects on foreign keyed fields, although it will work on any table, not just FKs.
Note: The list of field names should be comma-delimited.
Specify that the given field should be non-blank. This causes a check to be made on form submit and if any field is empty (nullstring) then a warning message is displayed and submit is prevented.
Specify that the given field should be omitted from the form
Whether passwords are encrypted or not. If true then we just apply the standard MD5 algorithm to the content.
Set the title of this maintainer. The default is derived from the name of the maintained table, with 'Maintenance' appended. Otherwise set your own title using this method.
Specify that the given field should be displayed on the form as text (view-only) but will not be submitted with the form.
Allows content of any password fields to be shown for reference. This is useful to reference screens where someone might need to be able to read passwords from the maintenance screen. Defaults to false.
Allows primary key values to be viewed along with other data. It is sometimes useful to see this info in view-only mode.
Causes the filtering widgets to be viewed or not viewed. The filter widgets allow users to input rudimentary filtering criteria on a single field which they can select, in order to filter the recordset.
Inherited From HTMLObject
HTMLObject::HTMLObject()
HTMLObject::inherit_attributes()
HTMLObject::setaccesskey()
HTMLObject::setalign()
HTMLObject::setalt()
HTMLObject::setbackground()
HTMLObject::setbgcolor()
HTMLObject::setborder()
HTMLObject::setcolor()
HTMLObject::setheight()
HTMLObject::sethspace()
HTMLObject::setlang()
HTMLObject::setlangdir()
HTMLObject::setname()
HTMLObject::setsize()
HTMLObject::setsrc()
HTMLObject::settabindex()
HTMLObject::settarget()
HTMLObject::settitle()
HTMLObject::setvalign()
HTMLObject::setvspace()
HTMLObject::setwidth()
HTMLObject::set_attribute()
HTMLObject::set_linkover_text()
HTMLObject::set_onblur()
HTMLObject::set_onchange()
HTMLObject::set_onclick()
HTMLObject::set_ondblclick()
HTMLObject::set_onfocus()
HTMLObject::set_onkeydown()
HTMLObject::set_onkeypress()
HTMLObject::set_onkeyup()
HTMLObject::set_onload()
HTMLObject::set_onmousedown()
HTMLObject::set_onmousemove()
HTMLObject::set_onmouseout()
HTMLObject::set_onmouseover()
HTMLObject::set_onmouseup()
HTMLObject::set_onselect()
HTMLObject::set_tabindex()
HTMLObject::taghtml()
Inherited From StylableObject
StylableObject::StylableObject()
StylableObject::clearstyle()
StylableObject::setclass()
StylableObject::setcss()
StylableObject::setid()
StylableObject::setstyle()
Inherited From RenderableObject
RenderableObject::RenderableObject()
RenderableObject::html()
RenderableObject::render()
RenderableObject::wml()
RenderableObject::wmlup()
RenderableObject::xml()
Documentation generated by phpDocumentor 1.3.0RC3