mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2025-03-28 22:51:35 +01:00
LSform: fix/improve handling config
Permit to fix handling ajaxSubmit form.
This commit is contained in:
parent
00132e32ad
commit
aeea76ab2a
1 changed files with 20 additions and 4 deletions
|
@ -33,6 +33,7 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass');
|
||||||
class LSform extends LSlog_staticLoggerClass {
|
class LSform extends LSlog_staticLoggerClass {
|
||||||
var $ldapObject;
|
var $ldapObject;
|
||||||
var $idForm;
|
var $idForm;
|
||||||
|
var $config;
|
||||||
var $can_validate = true;
|
var $can_validate = true;
|
||||||
var $elements = array();
|
var $elements = array();
|
||||||
var $_rules = array();
|
var $_rules = array();
|
||||||
|
@ -72,9 +73,23 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
$this -> submit = $submit;
|
$this -> submit = $submit;
|
||||||
}
|
}
|
||||||
$this -> ldapObject =& $ldapObject;
|
$this -> ldapObject =& $ldapObject;
|
||||||
|
$this -> config = $ldapObject -> getConfig('LSform');
|
||||||
LSsession :: loadLSclass('LSformElement');
|
LSsession :: loadLSclass('LSformElement');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a configuration parameter (or default value)
|
||||||
|
*
|
||||||
|
* @param[] $param The configuration parameter
|
||||||
|
* @param[] $default The default value (default : null)
|
||||||
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
|
*
|
||||||
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
|
**/
|
||||||
|
public function getConfig($param, $default=null, $cast=null) {
|
||||||
|
return LSconfig :: get($param, $default, $cast, $this -> config);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow conversion of LSform to string
|
* Allow conversion of LSform to string
|
||||||
*
|
*
|
||||||
|
@ -121,7 +136,7 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
);
|
);
|
||||||
LStemplate :: assign('LSform_object',$LSform_object);
|
LStemplate :: assign('LSform_object',$LSform_object);
|
||||||
|
|
||||||
$layout_config=LSconfig :: get("LSobjects.".$LSform_object['type'].".LSform.layout");
|
$layout_config = $this -> getConfig("layout");
|
||||||
|
|
||||||
if (!isset($this -> dataEntryFormConfig['disabledLayout']) || $this -> dataEntryFormConfig['disabledLayout']==false) {
|
if (!isset($this -> dataEntryFormConfig['disabledLayout']) || $this -> dataEntryFormConfig['disabledLayout']==false) {
|
||||||
if (is_array($layout_config)) {
|
if (is_array($layout_config)) {
|
||||||
|
@ -176,7 +191,7 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
LStemplate :: assign('LSform_fields',$fields);
|
LStemplate :: assign('LSform_fields',$fields);
|
||||||
|
|
||||||
$JSconfig = array (
|
$JSconfig = array (
|
||||||
'ajaxSubmit' => ((isset($this -> config['LSform']['ajaxSubmit']))?$this -> config['LSform']['ajaxSubmit']:1)
|
'ajaxSubmit' => intval($this -> getConfig('ajaxSubmit', true, 'boolean')),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!empty($this -> warnings)) {
|
if (!empty($this -> warnings)) {
|
||||||
|
@ -255,7 +270,7 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
}
|
}
|
||||||
LStemplate :: assign('LSform_fields',$fields);
|
LStemplate :: assign('LSform_fields',$fields);
|
||||||
|
|
||||||
$layout_config=LSconfig :: get("LSobjects.".$LSform_object['type'].".LSform.layout");
|
$layout_config = $this -> getConfig("layout");
|
||||||
if (is_array($layout_config)) {
|
if (is_array($layout_config)) {
|
||||||
LStemplate :: assign('LSform_layout',$layout_config);
|
LStemplate :: assign('LSform_layout',$layout_config);
|
||||||
}
|
}
|
||||||
|
@ -705,7 +720,7 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
public function applyDataEntryForm($dataEntryForm) {
|
public function applyDataEntryForm($dataEntryForm) {
|
||||||
$dataEntryForm=(string)$dataEntryForm;
|
$dataEntryForm=(string)$dataEntryForm;
|
||||||
$objType = $this -> ldapObject -> getType();
|
$objType = $this -> ldapObject -> getType();
|
||||||
$config=LSconfig :: get("LSobjects.".$objType.".LSform.dataEntryForm.".$dataEntryForm);
|
$config = $this -> getConfig("dataEntryForm.$dataEntryForm");
|
||||||
if (is_array($config)) {
|
if (is_array($config)) {
|
||||||
if (!is_array($config['displayedElements'])) {
|
if (!is_array($config['displayedElements'])) {
|
||||||
LSerror :: addErrorCode('LSform_08',$dataEntryForm);
|
LSerror :: addErrorCode('LSform_08',$dataEntryForm);
|
||||||
|
@ -739,6 +754,7 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
public static function listAvailableDataEntryForm($type) {
|
public static function listAvailableDataEntryForm($type) {
|
||||||
$retval=array();
|
$retval=array();
|
||||||
if (LSsession ::loadLSobject($type)) {
|
if (LSsession ::loadLSobject($type)) {
|
||||||
|
// Static method: couldn't use $this -> getConfig()
|
||||||
$config=LSconfig :: get("LSobjects.".$type.".LSform.dataEntryForm");
|
$config=LSconfig :: get("LSobjects.".$type.".LSform.dataEntryForm");
|
||||||
if (is_array($config)) {
|
if (is_array($config)) {
|
||||||
foreach($config as $name => $conf) {
|
foreach($config as $name => $conf) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue