posted on 3:21 PM, July 12, 2009
Generic, multi-purpse CMS objects are data objects that an end-user can be expected to create, edit, delete, and display in reports of one kind or another. This class defines a useful set of core behaviours for objects that fit this description.
This class can be inherited by specialized objects that can override the core beheviours to specify custom forms, reports, data handling, etc.
Each Object has two important attributes, type and id. In the generic Object, these are taken to be a table name and record ID, and are used as an ``address'' to look up the data, and also as raw material for composing a name (label) for the object. The type can be treated as a pseudo-class, since two objects of different types will have slightly different behaviours, as specified by the lower-level database record handling tools.
Each Object has a data attribute, consisting of the actual database record that the Object represents. This data is only loaded when needed. You can pass an actual datahash in when instantiating the record, if you have already loaded it another way.
Instantiate a new object; the type and id can be passed in the
Transform the object so that it represents a different record.
Returns the object's type (by default, it's table).
Returns the object's ID. An object normally only has an ID if it was fetched from the database. An object that has data, but no ID, is a working object that must be saved for it to be asigned an ID.
Returns a human-friendly description of the object.
Returns true if the object's type and ID are defined.
Returns the name of the key in the objects datahash that looks up the objects ID.
Returns the value of the named attribute (eg.
Returns the value of the named key in the object's datahash.
Sets the value of the named key in the object's datahash. Only sets the value in the object; to make this change permanent, the object must be saved.
Formats the value of the named key in the object's datahash as HTML. Also performs access-control checks to ensure the user is permitted to view the data.
Returns true (1) if the object's data has been modified and is out of sync with the saved data. Returns false (0) if the object matches the saved data.
Formats the entire Object as an HTML report.
Fetches the Object's data. If
Creates a new record, using
Updates an existing record, using
Writes the objects datahash out to the database, using either the
Moves the record represented by the Object to the trash.
Creates a new record that is a copy of the record represented by the Object (except for the record ID).
Generates an HTML form that allows the user to enter data for a new object/record.
Generates an HTML form that allows the user to edit the data of the current Object.
Process the form generated by
Process the form generated by
best practices (5)
content management (12)
data handling (7)
graphic design (21)
html formatting (7)
plug-in modules (28)
visual tutorial (29)
web protocols (9)