Jeff PHP framework
0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
|
Class which generates automatically the backoffice for the management of a database table. More...
Public Member Functions | |
__construct ($table, $opts=null) | |
Constructs an adminTable instance. | |
editFields ($opts=null) | |
The method which returns the admin insertion/modification/deletion/export views and functionality. | |
formRecord ($pk, $myform=null, $formaction=null) | |
The insertion/modification form of the given record. | |
manage () | |
Entry point for the autogenerated backoffice gui. | |
parseDateFields ($row) | |
Parses the results from a database query substituting the date/datetime fields values with format set in the site configuration. | |
parseForeignKeys ($row) | |
Parses the results from a database query substituting the foreign keys values with the related fields values of the related table. | |
parsePluginFields ($row) | |
Parses the results from a database query substituting the plugin fields values with the way they have to be displayed. | |
parseSpecialFields ($row, $opts=null) | |
Parses the results from a database query substituting the special fields values with the way they have to be displayed. | |
saveFields () | |
Saves the form submitted data (one or more records) | |
setChangelistFields ($fields) | |
Sets the $_changelist_field property. | |
setFilterFields ($filter_fields) | |
Sets the filter fields. | |
setForeignKeys ($fkeys) | |
Sets table foreign keys. | |
setHtmlFields ($fields) | |
Sets the table html fields. | |
setPluginFields ($pfields) | |
Sets plugin fields. | |
setSpecialFields ($sfields) | |
Sets table special fields. | |
view () | |
The method which returns the admin list view. | |
Protected Member Functions | |
checkUpload () | |
Checks if at least one of the special fields requires a file upload. | |
cleanField ($name, $type, $opts=null) | |
Cleans inputs from the user. | |
cleanSpecialField ($model, $fname, $pk, $type, $insert) | |
Cleans special fields inputs from the user and sets the model properties. | |
deleteFiles ($f_s) | |
Checks if the given records are associated to files and deletes them. | |
export ($f_s, $where='') | |
Exports the given records. | |
formElement ($myform, $fname, $field, $id, $opts=null) | |
The html form element for the given field. | |
formFilters () | |
Form which contains filters in the admin list view. | |
saveRecord ($pk, $pkeys) | |
Saves the given record. | |
setSessionSearch () | |
Sets the session variables used to filter records in the admin list. | |
setWhereClause ($fkeysorder) | |
Sets the where clause used to filter records in the admin list view. | |
Protected Attributes | |
$_arrow_down_path | |
relative path to the arrow down icon | |
$_arrow_up_path | |
relative path to the arrow up icon | |
$_changelist_fields | |
array of fields shown in the admin list | |
$_cls_cbk_del | |
delete action callback class | |
$_custom_tpl | |
associative array of custom templates | |
$_deletion | |
allow record deletion | |
$_edit_deny | |
deny record modification | |
$_editor | |
charge dojo editor for html fields | |
$_efp | |
number of records for page | |
$_fields | |
the table column names | |
$_filter_fields | |
array of fields used to filter records in the admin list | |
$_fkeys | |
definition of the foreign keys | |
$_html_fields | |
definition of the html fields | |
$_insertion | |
allow record insertion | |
$_mth_cbk_del | |
delete action callback method | |
$_pfields | |
definition of the plugin fields | |
$_primary_key | |
the primary key name defined for the table | |
$_registry | |
the registry singleton instance | |
$_sfields | |
definition of the special fields | |
$_table | |
the database table | |
$_view | |
view instance |
Class which generates automatically the backoffice for the management of a database table.
This class creates a default back-office interface for managing a database table (which has a primary key field). It gets the table structure directly from the database and constructs a navigation view to surf through inserted data, an insertion/edit view (the form) to add or update records and all the necessary actions to perform insertion, modification, deletion and exportation.
The adminTable class can also manage automatically foreign keys, some particular fields (password, bool, enum, email, multicheck, file, image), html fields (charging dojo html editor if needed) and fields managed by extra plugins. Also it is possible to automatically add filters for the list view. It's enough to set the filters fields and the class adds for you the filters form and performs the research. Filters field may be text, int, float, bool and foreign keys fields.
So if it's not necessary to have a specific logic that regulates the access and actions doable over a database table, with few lines of code is possible to create the entire table back office. All you have to do is set the foreign keys and/or special fields if needed and then call the manage method. Then Jeff shows you a list of inserted records with the possibility to edit/delete them or insert a new one. All these operations are managed automatically by the manage method. In alternative you may use only some features of this class, like using only the records paginated list (setting as not editable the fields: edit_deny='all') or using only the auto generated form. Clearly even if the module requires something different, it's always possible to extend this class in order to overwrite only the aspects that need a proper customization.
Definition at line 48 of file adminTable.class.php.
adminTable::__construct | ( | $ | table, |
$ | opts = null |
||
) |
Constructs an adminTable instance.
string | $table | the database table |
array | $opts | Associative array of options:
|
Reimplemented in menuAdminTable.
Definition at line 174 of file adminTable.class.php.
adminTable::checkUpload | ( | ) | [protected] |
Checks if at least one of the special fields requires a file upload.
Definition at line 783 of file adminTable.class.php.
adminTable::cleanField | ( | $ | name, |
$ | type, | ||
$ | opts = null |
||
) | [protected] |
Cleans inputs from the user.
string | $name | the field name |
string | $type | the field data type |
mixed | $opts | Associative array of options
|
Definition at line 1175 of file adminTable.class.php.
adminTable::cleanSpecialField | ( | $ | model, |
$ | fname, | ||
$ | pk, | ||
$ | type, | ||
$ | insert | ||
) | [protected] |
Cleans special fields inputs from the user and sets the model properties.
mixed | $model | the model instance |
string | $fname | the field name |
mixed | $pk | the primary key value |
string | $type | the field data type |
bool | $insert | whether the user action is an insertion or not. |
Definition at line 1204 of file adminTable.class.php.
adminTable::deleteFiles | ( | $ | f_s | ) | [protected] |
Checks if the given records are associated to files and deletes them.
array | $f_s | Array containing the identifiers of the records that have to be deleted |
Definition at line 901 of file adminTable.class.php.
adminTable::editFields | ( | $ | opts = null | ) |
The method which returns the admin insertion/modification/deletion/export views and functionality.
mixed | $opts | associative array of options
|
Definition at line 801 of file adminTable.class.php.
adminTable::export | ( | $ | f_s, |
$ | where = '' |
||
) | [protected] |
Exports the given records.
mixed | $f_s | the id of the fields that have to be exported. Possible values are 'all' or an array of fields' id |
string | $where | the where clause used to select records if the $f_s parameter is null |
Definition at line 1255 of file adminTable.class.php.
adminTable::formElement | ( | $ | myform, |
$ | fname, | ||
$ | field, | ||
$ | id, | ||
$ | opts = null |
||
) | [protected] |
The html form element for the given field.
form | $myform | the form instance |
mixed | $fname | the field name |
array | $field | associative array containing the database structure information for the field (null, max_length, int...) |
mixed | $id | the value of the primary key |
mixed | $opts | Associative array of options
|
Reimplemented in menuAdminTable.
Definition at line 977 of file adminTable.class.php.
adminTable::formFilters | ( | ) | [protected] |
Form which contains filters in the admin list view.
Definition at line 626 of file adminTable.class.php.
adminTable::formRecord | ( | $ | pk, |
$ | myform = null , |
||
$ | formaction = null |
||
) |
The insertion/modification form of the given record.
This method can return all the form elements without the start and end form tags, or a complete form.
The complete form is generally used when calling this method outside from the adminTable class. In this case it is possible to set the form action which by default is '?save'
mixed | $pk | the value of the record primary key |
form | $myform | a form instance default null. If the form is started and closed independently by this method. |
string | $formaction | default null. The url of the form action if the method starts the form |
Definition at line 941 of file adminTable.class.php.
Entry point for the autogenerated backoffice gui.
This is the method called by client classes to generate their tables backoffice
Definition at line 341 of file adminTable.class.php.
adminTable::parseDateFields | ( | $ | row | ) |
Parses the results from a database query substituting the date/datetime fields values with format set in the site configuration.
mixed | $row | associative array deriving from a db query result |
Definition at line 761 of file adminTable.class.php.
adminTable::parseForeignKeys | ( | $ | row | ) |
Parses the results from a database query substituting the foreign keys values with the related fields values of the related table.
array | $row | associative array deriving from a db query result |
Definition at line 660 of file adminTable.class.php.
adminTable::parsePluginFields | ( | $ | row | ) |
Parses the results from a database query substituting the plugin fields values with the way they have to be displayed.
mixed | $row | associative array deriving from a db query result |
Definition at line 739 of file adminTable.class.php.
adminTable::parseSpecialFields | ( | $ | row, |
$ | opts = null |
||
) |
Parses the results from a database query substituting the special fields values with the way they have to be displayed.
mixed | $row | associative array deriving from a db query result |
mixed | $opts | Associative array of options:
|
Definition at line 688 of file adminTable.class.php.
Saves the form submitted data (one or more records)
Definition at line 1061 of file adminTable.class.php.
adminTable::saveRecord | ( | $ | pk, |
$ | pkeys | ||
) | [protected] |
Saves the given record.
mixed | $pk | the primary key value |
mixed | $pkeys | List of primary keys of the records edited in the form |
Definition at line 1105 of file adminTable.class.php.
adminTable::setChangelistFields | ( | $ | fields | ) |
Sets the $_changelist_field property.
array | $fields | See adminTable() options |
Definition at line 300 of file adminTable.class.php.
adminTable::setFilterFields | ( | $ | filter_fields | ) |
Sets the filter fields.
array | $filter_fields | Array of fields used to filter records in the admin list |
Definition at line 314 of file adminTable.class.php.
adminTable::setForeignKeys | ( | $ | fkeys | ) |
Sets table foreign keys.
array | $fkeys | Associative array in the form 'field_name'=>properties. Properties is an associative array having keys:
|
Definition at line 218 of file adminTable.class.php.
adminTable::setHtmlFields | ( | $ | fields | ) |
Sets the table html fields.
mixed | $fields | array of fields which allow html content |
Definition at line 327 of file adminTable.class.php.
adminTable::setPluginFields | ( | $ | pfields | ) |
Sets plugin fields.
array | $pfields | associative array where the key is the name of the "plugin type" field and the value is an array which contains the options required by the plugin itself |
Definition at line 283 of file adminTable.class.php.
adminTable::setSessionSearch | ( | ) | [protected] |
Sets the session variables used to filter records in the admin list.
Definition at line 548 of file adminTable.class.php.
adminTable::setSpecialFields | ( | $ | sfields | ) |
Sets table special fields.
The supported special fields types are: password, bool, enum, email, multicheck (many to many), file, image
array | $sfields | Associative array in the form 'field_name'=>properties. Properties is an associative array having keys:
|
Definition at line 266 of file adminTable.class.php.
adminTable::setWhereClause | ( | $ | fkeysorder | ) | [protected] |
Sets the where clause used to filter records in the admin list view.
bool | $fkeysorder | Whether records are ordered by a foreign key field or not |
Definition at line 592 of file adminTable.class.php.
adminTable::view | ( | ) |
The method which returns the admin list view.
Reimplemented in menuAdminTable.
Definition at line 372 of file adminTable.class.php.
adminTable::$_arrow_down_path [protected] |
relative path to the arrow down icon
Definition at line 148 of file adminTable.class.php.
adminTable::$_arrow_up_path [protected] |
relative path to the arrow up icon
Definition at line 153 of file adminTable.class.php.
adminTable::$_changelist_fields [protected] |
array of fields shown in the admin list
Definition at line 123 of file adminTable.class.php.
adminTable::$_cls_cbk_del [protected] |
delete action callback class
Definition at line 98 of file adminTable.class.php.
adminTable::$_custom_tpl [protected] |
associative array of custom templates
Definition at line 138 of file adminTable.class.php.
adminTable::$_deletion [protected] |
allow record deletion
Definition at line 113 of file adminTable.class.php.
adminTable::$_edit_deny [protected] |
deny record modification
Definition at line 118 of file adminTable.class.php.
adminTable::$_editor [protected] |
charge dojo editor for html fields
Definition at line 133 of file adminTable.class.php.
adminTable::$_efp [protected] |
number of records for page
Definition at line 93 of file adminTable.class.php.
adminTable::$_fields [protected] |
the table column names
Definition at line 68 of file adminTable.class.php.
adminTable::$_filter_fields [protected] |
array of fields used to filter records in the admin list
Definition at line 128 of file adminTable.class.php.
adminTable::$_fkeys [protected] |
definition of the foreign keys
Definition at line 73 of file adminTable.class.php.
adminTable::$_html_fields [protected] |
definition of the html fields
Definition at line 88 of file adminTable.class.php.
adminTable::$_insertion [protected] |
allow record insertion
Definition at line 108 of file adminTable.class.php.
adminTable::$_mth_cbk_del [protected] |
delete action callback method
Definition at line 103 of file adminTable.class.php.
adminTable::$_pfields [protected] |
definition of the plugin fields
Definition at line 83 of file adminTable.class.php.
adminTable::$_primary_key [protected] |
the primary key name defined for the table
Definition at line 63 of file adminTable.class.php.
adminTable::$_registry [protected] |
the registry singleton instance
Definition at line 53 of file adminTable.class.php.
adminTable::$_sfields [protected] |
definition of the special fields
Definition at line 78 of file adminTable.class.php.
adminTable::$_table [protected] |
the database table
Definition at line 58 of file adminTable.class.php.
adminTable::$_view [protected] |
view instance
Definition at line 143 of file adminTable.class.php.