jControllerDaoCrudFilter
extends jControllerDaoCrud
in package
Implements a CRUD controller, having a filter form to filter the list.
The form should be a jForms form, and should have controls having the
same name of the DAO properties that are filtered. It must also have a
submit button named _submitFilter
.
Tags
Table of Contents
- $pluginParams : array<string|int, mixed>
- parameters for plugins of the coordinator.
- $sensitiveParameters : array<string|int, string>
- sensitive parameters.
- $dao : string
- selector of the dao to use for the crud.
- $dbProfile : mixed
- the jDb profile to use with the dao.
- $editTemplate : string
- template to display the form.
- $filterForm : string
- selector of the form to use to filter the results on the "list" template if the filter is enabled It should be filled by child controller.
- $filterFormObj : jFormsBase
- $form : string
- selector of the form to use to edit and display a record It should be filled by child controller.
- $listPageSize : int
- number of record to display in the list page.
- $listTemplate : string
- template to display the list of records.
- $offsetParameterName : string
- name of the parameter which contains the page offset, for the index action.
- $propertiesForFilter : array<string|int, string>
- list of properties to enable the filtering on if empty list (default), it uses the same properties as indicated into the filterForm.
- $propertiesForList : array<string|int, string>
- list of properties to show in the list page if empty list (default), it shows all properties.
- $propertiesForRecordsOrder : array<string|int, string>
- list of properties which serve to order the record list.
- $pseudoFilterFormId : string
- id for the "pseudo" form used to filter results. You can change it if the default one corresponds to a possible id in your dao.
- $pseudoFormId : string
- id for the "pseudo" form used to show a record. You can change it if the default one corresponds to a possible id in your dao.
- $request : jRequest
- the request object.
- $showPropertiesOrderLinks : bool
- indicate if we show links to allow the user to order records list.
- $templateAssign : string
- the template variable name to display a CRUD content in the main template of the html response.
- $uploadsDirectory : false|string
- full path to the directory where uploaded files will be stored automatically by jForms.
- $viewErrorTemplate : string
- template to show error when a record is not found.
- $viewTemplate : string
- template to display a record.
- __construct() : mixed
- create() : mixed
- display a form to create a record.
- delete() : mixed
- delete a record.
- editupdate() : mixed
- displays a forms to edit an existing record. The form should be prepared with the preupdate before, so a refresh of the page won't cause a reset of the form.
- index() : mixed
- list all records.
- precreate() : mixed
- prepare a form to create a record.
- preupdate() : mixed
- prepare a form in order to edit an existing record, and redirect to the editupdate action.
- savecreate() : mixed
- save data of a form in a new record.
- saveupdate() : mixed
- save data of a form in a new record.
- view() : mixed
- displays a record.
- _afterCreate() : mixed
- redefine this method if you wan to do additionnal things after the creation of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.
- _afterUpdate() : mixed
- redefine this method if you wan to do additionnal things after the update of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.
- _beforeSaveCreate() : mixed
- redefine this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method.
- _beforeSaveUpdate() : mixed
- redefine this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method.
- _checkData() : bool
- you can do your own data check of a form by redefining this method.
- _create() : mixed
- redefine this method if you want to do additionnal things on the response and on the edit template during the create action.
- _createForm() : jFormsBase
- create the form. You can redefine this method to modify dynamically the form Typically, you call jForms::create and then you can call addControl or whatever.
- _delete() : bool
- redefine this method if you want to do additional things before the deletion of a record.
- _editUpdate() : mixed
- redefine this method if you wan to do additionnal things on the response and on the edit template during the editupdate action.
- _filterCreateForm() : null|jFormsBase
- Get or Create the filter form if we use filter.
- _filterSetConditions() : mixed
- this method set conditions according to the form filter submit.
- _getAction() : string
- returned the selector of the action corresponding of the given method of the current controller.
- _getForm() : jFormsBase
- get an existing form. You can redefine this method to modify dynamically the form Typically, you call jForms::get and then you can call addControl or whatever.
- _getResponse() : jResponseHtml
- Returned a simple html response to display CRUD contents. You can redefine this method to return a personnalized response.
- _index() : mixed
- redefine this method if you want to do additional things on the response and on the list template during the index action.
- _indexSetConditions() : mixed
- redefine this method if you want to do additional conditions to the index's select during the index action.
- _preCreate() : mixed
- redefine this method if you want to do additionnal during the precreate action.
- _preUpdate() : mixed
- redefine this method if you want to do additionnal things during preupdate action.
- _view() : mixed
- redefine this method if you want to do additionnal things on the response and on the view template during the view action.
- boolParam() : bool
- same as param(), but convert the value to a boolean value. If it isn't a numerical value, return null.
- fillColumnOrderList() : array<string|int, string>
- floatParam() : float
- same as param(), but convert the value to a float value. If it isn't a numerical value, return null.
- getFileResponse() : jResponseBinary|jResponseHtml
- Return the given file as a response.
- getResponse() : jResponse|jResponseHtml|jResponseJson|jResponseRedirect
- get a response object.
- intParam() : int
- same as param(), but convert the value to an integer value. If it isn't a numerical value, return null.
- param() : mixed
- Gets the value of a request parameter. If not defined, gets its default value.
- params() : array<string|int, mixed>
- redirect() : jResponseRedirect
- get a jReponseRedirect object
- redirectToUrl() : jResponseRedirectUrl
- get a jReponseRedirectUrl object
Properties
$pluginParams
parameters for plugins of the coordinator.
public
array<string|int, mixed>
$pluginParams
= array()
this array should contains all parameters needed by installed plugins for each action, see the documentation of each plugins to know this parameters. keys : name of an action or * for parameters to all action values : array that contains all plugin parameters
Tags
$sensitiveParameters
sensitive parameters.
public
array<string|int, string>
$sensitiveParameters
= array()
List of names of parameters that can have sensitive values like password etc. This list is used by the logger for example, to replace values by a dummy value. See also sensitiveParameters into error_handling section of the configuration.
Tags
$dao
selector of the dao to use for the crud.
protected
string
$dao
= ''
It should be filled by child controller.
Tags
$dbProfile
the jDb profile to use with the dao.
protected
mixed
$dbProfile
= ''
Tags
$editTemplate
template to display the form.
protected
string
$editTemplate
= 'jelix~crud_edit'
Tags
$filterForm
selector of the form to use to filter the results on the "list" template if the filter is enabled It should be filled by child controller.
protected
string
$filterForm
= ''
Tags
$filterFormObj
protected
jFormsBase
$filterFormObj
Tags
$form
selector of the form to use to edit and display a record It should be filled by child controller.
protected
string
$form
= ''
Tags
$listPageSize
number of record to display in the list page.
protected
int
$listPageSize
= 20
Tags
$listTemplate
template to display the list of records.
protected
string
$listTemplate
= 'jelix~crud_list_filter'
Tags
$offsetParameterName
name of the parameter which contains the page offset, for the index action.
protected
string
$offsetParameterName
= 'offset'
Tags
$propertiesForFilter
list of properties to enable the filtering on if empty list (default), it uses the same properties as indicated into the filterForm.
protected
array<string|int, string>
$propertiesForFilter
= array()
Tags
$propertiesForList
list of properties to show in the list page if empty list (default), it shows all properties.
protected
array<string|int, string>
$propertiesForList
= array()
this property is only usefull when you use the default "list" template.
Tags
$propertiesForRecordsOrder
list of properties which serve to order the record list.
protected
array<string|int, string>
$propertiesForRecordsOrder
= array()
if empty list (default), the list is in a natural order. keys are properties name, and values are "asc" or "desc". Values can be changed by the user if showPropertiesOrderLinks is true. In this case, '' means undetermined.
Tags
$pseudoFilterFormId
id for the "pseudo" form used to filter results. You can change it if the default one corresponds to a possible id in your dao.
protected
string
$pseudoFilterFormId
= 'jelix_crud_filter'
Tags
$pseudoFormId
id for the "pseudo" form used to show a record. You can change it if the default one corresponds to a possible id in your dao.
protected
string
$pseudoFormId
= 'jelix_crud_roxor'
Tags
$request
the request object.
protected
jRequest
$request
Tags
$showPropertiesOrderLinks
indicate if we show links to allow the user to order records list.
protected
bool
$showPropertiesOrderLinks
= \true
Tags
$templateAssign
the template variable name to display a CRUD content in the main template of the html response.
protected
string
$templateAssign
= 'MAIN'
Tags
$uploadsDirectory
full path to the directory where uploaded files will be stored automatically by jForms.
protected
false|string
$uploadsDirectory
= ''
Set it to false if you want to handle yourself the uploaded files. Set it with an empty string if you want to stored files in the default var/uploads directory.
Tags
$viewErrorTemplate
template to show error when a record is not found.
protected
string
$viewErrorTemplate
= 'jelix~404.html'
Tags
$viewTemplate
template to display a record.
protected
string
$viewTemplate
= 'jelix~crud_view'
Tags
Methods
__construct()
public
__construct(jRequest $request) : mixed
Parameters
- $request : jRequest
-
the current request object
Tags
Return values
mixed —create()
display a form to create a record.
public
create() : mixed
Tags
Return values
mixed —delete()
delete a record.
public
delete() : mixed
Tags
Return values
mixed —editupdate()
displays a forms to edit an existing record. The form should be prepared with the preupdate before, so a refresh of the page won't cause a reset of the form.
public
editupdate() : mixed
Tags
Return values
mixed —index()
list all records.
public
index() : mixed
Tags
Return values
mixed —precreate()
prepare a form to create a record.
public
precreate() : mixed
Tags
Return values
mixed —preupdate()
prepare a form in order to edit an existing record, and redirect to the editupdate action.
public
preupdate() : mixed
Tags
Return values
mixed —savecreate()
save data of a form in a new record.
public
savecreate() : mixed
Tags
Return values
mixed —saveupdate()
save data of a form in a new record.
public
saveupdate() : mixed
Tags
Return values
mixed —view()
displays a record.
public
view() : mixed
Tags
Return values
mixed —_afterCreate()
redefine this method if you wan to do additionnal things after the creation of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.
protected
_afterCreate(jFormsBase $form, mixed $id, jResponseHtml $resp) : mixed
Parameters
- $form : jFormsBase
-
the form object
- $id : mixed
-
the new id of the inserted record
- $resp : jResponseHtml
-
the response
Tags
Return values
mixed —_afterUpdate()
redefine this method if you wan to do additionnal things after the update of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.
protected
_afterUpdate(jFormsBase $form, mixed $id, jResponseHtml $resp) : mixed
Parameters
- $form : jFormsBase
-
the form object
- $id : mixed
-
the new id of the updated record
- $resp : jResponseHtml
-
the response
Tags
Return values
mixed —_beforeSaveCreate()
redefine this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method.
protected
_beforeSaveCreate(jFormsBase $form, jDaoRecordBase $form_daorec) : mixed
Parameters
- $form : jFormsBase
-
the form
- $form_daorec : jDaoRecordBase
Tags
Return values
mixed —_beforeSaveUpdate()
redefine this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method.
protected
_beforeSaveUpdate(jFormsBase $form, jDaoRecordBase $form_daorec, mixed $id) : mixed
Parameters
- $form : jFormsBase
-
the form
- $form_daorec : jDaoRecordBase
- $id : mixed
-
the new id of the updated record
Tags
Return values
mixed —_checkData()
you can do your own data check of a form by redefining this method.
protected
_checkData(jFormsBase $form, bool $calltype) : bool
You can also do some other things. It is called only if the $form->check() is ok. and before the save of the data.
Parameters
- $form : jFormsBase
-
the current form
- $calltype : bool
-
true for an update, false for a create
Tags
Return values
bool —true if it is ok
_create()
redefine this method if you want to do additionnal things on the response and on the edit template during the create action.
protected
_create(jFormsBase $form, jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
- $form : jFormsBase
-
the form
- $resp : jResponseHtml
-
the response
- $tpl : jtpl
-
the template to display the edit form
Tags
Return values
mixed —_createForm()
create the form. You can redefine this method to modify dynamically the form Typically, you call jForms::create and then you can call addControl or whatever.
protected
_createForm([int|string $formId = null ]) : jFormsBase
Don't do a jForms::get or jForms::fill in this method ! called in methods: index, precreate, create, preupdate, view.
Parameters
- $formId : int|string = null
Tags
Return values
jFormsBase —the form
_delete()
redefine this method if you want to do additional things before the deletion of a record.
protected
_delete(mixed $id, jResponseRedirect $resp) : bool
Parameters
- $id : mixed
-
the id of the record to delete
- $resp : jResponseRedirect
-
the response
Tags
Return values
bool —true if the record can be deleted
_editUpdate()
redefine this method if you wan to do additionnal things on the response and on the edit template during the editupdate action.
protected
_editUpdate(jFormsBase $form, jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
- $form : jFormsBase
-
the form
- $resp : jResponseHtml
-
the response
- $tpl : jtpl
-
the template to display the edit form
Tags
Return values
mixed —_filterCreateForm()
Get or Create the filter form if we use filter.
protected
_filterCreateForm() : null|jFormsBase
Tags
Return values
null|jFormsBase —the form if filter is enable
_filterSetConditions()
this method set conditions according to the form filter submit.
protected
_filterSetConditions(jFormsBase $form, jDaoConditions $cond) : mixed
Parameters
- $form : jFormsBase
- $cond : jDaoConditions
-
the conditions
Tags
Return values
mixed —_getAction()
returned the selector of the action corresponding of the given method of the current controller.
protected
_getAction(string $method) : string
Parameters
- $method : string
-
name of one of method of this controller
Tags
Return values
string —an action selector
_getForm()
get an existing form. You can redefine this method to modify dynamically the form Typically, you call jForms::get and then you can call addControl or whatever.
protected
_getForm([int|string $formId = null ]) : jFormsBase
Don't do a jForms::create or jForms::fill in this method ! called in methods: create, savecreate, editupdate, saveupdate.
Parameters
- $formId : int|string = null
Tags
Return values
jFormsBase —the form
_getResponse()
Returned a simple html response to display CRUD contents. You can redefine this method to return a personnalized response.
protected
_getResponse() : jResponseHtml
Tags
Return values
jResponseHtml —the response
_index()
redefine this method if you want to do additional things on the response and on the list template during the index action.
protected
_index(mixed $resp, mixed $tpl) : mixed
Parameters
- $resp : mixed
-
the response
- $tpl : mixed
-
the template to display the record list
Tags
Return values
mixed —_indexSetConditions()
redefine this method if you want to do additional conditions to the index's select during the index action.
protected
_indexSetConditions(mixed $cond) : mixed
Parameters
- $cond : mixed
-
the conditions
Tags
Return values
mixed —_preCreate()
redefine this method if you want to do additionnal during the precreate action.
protected
_preCreate(jFormsBase $form) : mixed
Parameters
- $form : jFormsBase
-
the form
Tags
Return values
mixed —_preUpdate()
redefine this method if you want to do additionnal things during preupdate action.
protected
_preUpdate(jFormsBase $form) : mixed
Parameters
- $form : jFormsBase
-
the form object
Tags
Return values
mixed —_view()
redefine this method if you want to do additionnal things on the response and on the view template during the view action.
protected
_view(jFormsBase $form, jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
- $form : jFormsBase
-
the form
- $resp : jResponseHtml
-
the response
- $tpl : jtpl
-
the template to display the form content
Tags
Return values
mixed —boolParam()
same as param(), but convert the value to a boolean value. If it isn't a numerical value, return null.
protected
boolParam(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : bool
Parameters
- $parName : string
-
the name of the request parameter
- $parDefaultValue : mixed = null
-
the default returned value if the parameter doesn't exists
- $useDefaultIfEmpty : bool = false
-
true: says to return the default value the value is ""
Tags
Return values
bool —the request parameter value
fillColumnOrderList()
protected
fillColumnOrderList() : array<string|int, string>
Tags
Return values
array<string|int, string> —list of properties on which the list should be ordered
floatParam()
same as param(), but convert the value to a float value. If it isn't a numerical value, return null.
protected
floatParam(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : float
Parameters
- $parName : string
-
the name of the request parameter
- $parDefaultValue : mixed = null
-
the default returned value if the parameter doesn't exists
- $useDefaultIfEmpty : bool = false
-
true: says to return the default value the value is ""
Tags
Return values
float —the request parameter value
getFileResponse()
Return the given file as a response.
protected
getFileResponse(string $filename[, bool $useCache = true ]) : jResponseBinary|jResponseHtml
It reads the file content and will return it into the HTTP Response. Mimetype will be set. Can use HTTP cache optionally.
Returns a 404 response if the file does not exists.
Parameters
- $filename : string
-
path to the file
- $useCache : bool = true
-
true if http cache must be activated, based on the date of the file.
Tags
Return values
jResponseBinary|jResponseHtml —getResponse()
get a response object.
protected
getResponse([string $name = '' ][, bool $useOriginal = false ]) : jResponse|jResponseHtml|jResponseJson|jResponseRedirect
Parameters
- $name : string = ''
-
the name of the response type (ex: "html")
- $useOriginal : bool = false
-
true:don't use the response object redefined by the application
Tags
Return values
jResponse|jResponseHtml|jResponseJson|jResponseRedirect —the response object
intParam()
same as param(), but convert the value to an integer value. If it isn't a numerical value, return null.
protected
intParam(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : int
Parameters
- $parName : string
-
the name of the request parameter
- $parDefaultValue : mixed = null
-
the default returned value if the parameter doesn't exists
- $useDefaultIfEmpty : bool = false
-
true: says to return the default value the value is ""
Tags
Return values
int —the request parameter value
param()
Gets the value of a request parameter. If not defined, gets its default value.
protected
param(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : mixed
Parameters
- $parName : string
-
the name of the request parameter
- $parDefaultValue : mixed = null
-
the default returned value if the parameter doesn't exists
- $useDefaultIfEmpty : bool = false
-
true: says to return the default value if the parameter value is ""
Tags
Return values
mixed —the request parameter value
params()
protected
params() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —all request parameters
redirect()
get a jReponseRedirect object
protected
redirect(string $action[, array<string|int, mixed> $parameters = [] ][, string $anchor = '' ][, bool $temporary = true ]) : jResponseRedirect
Parameters
- $action : string
-
the action selector, like "mymodule~myctrl:mymethod"
- $parameters : array<string|int, mixed> = []
-
parameters of the action
- $anchor : string = ''
-
url anchor
- $temporary : bool = true
-
temporary redirection (true) or permanent redirection (false)
Tags
Return values
jResponseRedirect —redirectToUrl()
get a jReponseRedirectUrl object
protected
redirectToUrl(string $url[, mixed $temporary = true ]) : jResponseRedirectUrl
Parameters
- $url : string
-
the url
- $temporary : mixed = true