-
Notifications
You must be signed in to change notification settings - Fork 0
Plugins
Jeff has a base structure developed to allow the integration of extra plugins. The file plugins.php in the root directory defines an array where the keys are the installed plugin names and the values are arrays containing specific options to pass to the plugin constructor, if needed.
Clearly first it's necessary to install the plugin (copy files, creating db tables, etc...) following the plugin installation instructions, then the plugin can be integrated by saying Jeff it's present, such thing is done writing the array discussed above.
Each plugin must have a wrapper class of the same name in the folder ROOT/plugins/PLUGIN_NAME, which is automatically instantiated in the core class and put in the registry property plugins. The plugin instance is retrieved this way:
$this->_registry->plugins["PLUGIN_NAME"]
Such objects contain the definition of the main plugin functions and eventually includes other classes/files/modules.
The field type plugins are plugin used to manage particular type of data that have to be recorded in the database. In particular are plugins that work together with the adminTable class and allow the automatic management of different kinds of data (i.e. tag type fields).
So these plugins must have some methods needed to work with the adminTable class, for the view, form, and action features. Then they can also provide other functionality like presentation modules, objects used to display data in the front-end and so on.
The compulsory methods are:
- **adminList(array $opts, mixed $value)
@params opts: plugin field options specific for every plugin, the ones defined in the setPluginFields method of the adminTable class
@params value: the value recorder in the database - **adminDelete(**array $opts, array $f_s)
@params opts: same as for the adminList method
@params f_s: the array of the fields primary keys that have to be deleted. - **formAdmin(**array $opts, string $fname, string $flabel, array $field, form $myform, mixed $value)
@params opts: same as for the adminList method
@params fname: the input field name
@params flabel: the input field label
@params field: the field db structure
@params myform: the form object
@params value: the actual value of the field - **cleanField(**array $opts, mixed $model, string $fname, mixed $pkf, bool $insert)
@params opts: same as for the adminList method
@params model: the object which owns the plugin field
@params fname: the field name
@params pkf: the primary key of the record/object
@params insert: whether the action is an insertion or not
All these methods are automatically called by the adminTable class object to perform the basing tasks:
- show table content (adminList)
- delete fields (adminDelete)
- print the backend form (formAdmin)
- save the object after insertion/modification (cleanField)
There is also an optional method, called if it exists.
- **afterModelSaved(**array $opts, mixed $model, string $fname, mixed $pk, bool $insert)
@params opts: same as for the adminList method
@params model: the object which owns the plugin field
@params fname: the field name
@params pk: the name of the primary key field of the model
@params insert: whether the action is an insertion or not
this method is called after the model object is saved, so that it's possible to perform actions with the model id which is now known.