Jelix 1.7.18

jControllerDaoCrudDfk extends jController
in package

a base class for crud controllers, for DAO which have a primary key based on two fields, a "static" field (a field that we know the value and which is a criteria to to select all viewed record), and a "dynamic" field (the value of the field is created by the user or autoincremented).

Tags
subpackage

controllers

since
1.1

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.
$dpkName  : mixed
name of the request parameter and of the field in the dao, for the dynamic primary key.
$editTemplate  : string
template to display the form.
$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.
$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.
$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.
$spkName  : mixed
name of the request parameter and of the field in the dao, for the static primary key.
$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.
$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
overload 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
overload 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
overload this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method.
_beforeSaveUpdate()  : mixed
overload 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 overloading this method.
_create()  : mixed
overload this method if you wan to do additionnal things on the response and on the edit template during the create action.
_delete()  : bool
overload this method if you want to do additionnal things before the deletion of a record.
_editUpdate()  : mixed
overload this method if you wan to do additionnal things on the response and on the edit template during the editupdate action.
_getAction()  : string
returned the selector of the action corresponding of the given method of the current controller.
_getPk()  : mixed
_getResponse()  : jResponseHtml
Returned a simple html response to display CRUD contents. You can override this method to return a personnalized response.
_index()  : mixed
overload this method if you wan to do additionnal things on the response and on the list template during the index action.
_indexSetConditions()  : mixed
overload this method if you wan to do additionnal conditions to the index's select during the index action.
_isPkAutoIncrement()  : mixed
_preCreate()  : mixed
overload this method if you want to do additionnal during the precreate action.
_preUpdate()  : mixed
overload this method if you want to do additionnal things during preupdate action.
_view()  : mixed
overload 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.
floatParam()  : float
same as param(), but convert the value to a float value. If it isn't a numerical value, return null.
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>

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

$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
since
1.6.16

$dpkName

name of the request parameter and of the field in the dao, for the dynamic primary key.

protected mixed $dpkName = 'id'

$form

selector of the form to use to edit and display a record It should be filled by child controller.

protected string $form = ''

$offsetParameterName

name of the parameter which contains the page offset, for the index action.

protected string $offsetParameterName = 'offset'

$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.

$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.

$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_cruddf_roxor'

indicate if we show links to allow the user to order records list.

protected bool $showPropertiesOrderLinks = rue

$spkName

name of the request parameter and of the field in the dao, for the static primary key.

protected mixed $spkName = 'spk'

$templateAssign

the template variable name to display a CRUD content in the main template of the html response.

protected string $templateAssign = 'MAIN'

$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.

Methods

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
Return values
mixed

preupdate()

prepare a form in order to edit an existing record, and redirect to the editupdate action.

public preupdate() : mixed
Return values
mixed

_afterCreate()

overload 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

Return values
mixed

_afterUpdate()

overload 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

Return values
mixed

_beforeSaveUpdate()

overload 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

Return values
mixed

_checkData()

you can do your own data check of a form by overloading this method.

protected _checkData(string $spk, 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
$spk : string

the static value of the primary key of the record

$form : jFormsBase

the current form

$calltype : bool

true for an update, false for a create

Return values
bool

true if it is ok

_create()

overload this method if you wan 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

Return values
mixed

_delete()

overload this method if you want to do additionnal things before the deletion of a record.

protected _delete(mixed $spk, mixed $dpk, jResponseHtml $resp) : bool
Parameters
$spk : mixed

the static value of the primary key of the record to delete

$dpk : mixed

the dynamic value of the primary key of the record to delete

$resp : jResponseHtml

the response

Return values
bool

true if the record can be deleted

_editUpdate()

overload 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

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

Return values
string

an action selector

_getPk()

protected _getPk(mixed $spk, mixed $dpk[, mixed $dao = null ]) : mixed
Parameters
$spk : mixed
$dpk : mixed
$dao : mixed = null
Return values
mixed

_index()

overload this method if you wan to do additionnal things on the response and on the list template during the index action.

protected _index(jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
$resp : jResponseHtml

the response

$tpl : jtpl

the template to display the record list

Return values
mixed

_indexSetConditions()

overload this method if you wan to do additionnal conditions to the index's select during the index action.

protected _indexSetConditions(jDaoConditions $cond) : mixed
Parameters
$cond : jDaoConditions

the conditions

Return values
mixed

_isPkAutoIncrement()

protected _isPkAutoIncrement([mixed $dao = null ]) : mixed
Parameters
$dao : mixed = null
Return values
mixed

_view()

overload 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

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 ""

Return values
bool

the request parameter value

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 ""

Return values
float

the request parameter value

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 ""

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 ""

Return values
mixed

the request parameter value

params()

protected params() : array<string|int, mixed>
Return values
array<string|int, mixed>

all request parameters

Search results