Code cleaning

This commit is contained in:
Benjamin Renard 2020-11-30 19:44:14 +01:00
parent 106a2d9f04
commit b4a5824ee8
5 changed files with 23 additions and 25 deletions

View file

@ -36,14 +36,14 @@ class LSattr_html_image extends LSattr_html {
*
* @retval LSformElement L'element du formulaire ajouté
*/
function addToForm (&$form,$idForm,$data=NULL) {
function addToForm (&$form, $idForm, $data=NULL) {
$element=$form -> addElement('image', $this -> name, $this -> getLabel(), $this -> config, $this);
if(!$element) {
LSerror :: addErrorCode('LSform_06',$this -> name);
return;
}
if ($data && count($data)>1) {
if ($data && count($data) > 1) {
LSerror :: addErrorCode('LSattr_html_03','password');
}

View file

@ -37,9 +37,9 @@ class LSattr_html_password extends LSattr_html {
* @retval LSformElement L'element du formulaire ajouté
*/
public function addToForm (&$form,$idForm,$data=NULL) {
$element=$form -> addElement('password', $this -> name, $this -> getLabel(), $this -> config, $this);
$element = $form -> addElement('password', $this -> name, $this -> getLabel(), $this -> config, $this);
if(!$element) {
LSerror :: addErrorCode('LSform_06',$this -> name);
LSerror :: addErrorCode('LSform_06', $this -> name);
return;
}

View file

@ -53,13 +53,13 @@ class LSformElement_postaladdress extends LSformElement_textarea {
else {
LSerror::addErrorCode('LSformElement_postaladdress_01', $map_url_pattern_generate_function);
}
}
elseif ($map_url_pattern_format) {
}
elseif ($map_url_pattern_format) {
$pattern = $this -> attr_html -> attribute -> ldapObject -> getFData($map_url_pattern_format);
$pattern = str_replace("\n"," ",$pattern);
$pattern = urlencode($pattern);
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('pattern', $pattern);
}
}
else {
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('pattern', LSformElement_postaladdress__generate_pattern($this));
}

View file

@ -63,18 +63,18 @@ class LSformRule_password extends LSformRule {
$minValidRegex = count($regex);
self :: log_debug("password must match with $minValidRegex regex on ".count($regex));
$valid=0;
$valid = 0;
foreach($regex as $r) {
if ($r[0] != '/') {
LSerror :: addErrorCode('LSformRule_password_01');
continue;
}
if (preg_match($r, $value)) {
self :: log_debug("password match with regex '$r'");
self :: log_debug("password match with regex '$r'");
$valid++;
}
else
self :: log_debug("password does not match with regex '$r'");
}
else
self :: log_debug("password does not match with regex '$r'");
}
if ($valid < $minValidRegex) {
self :: log_warning("password match with only $valid regex on ".count($regex).". $minValidRegex valid regex is required");

View file

@ -112,28 +112,26 @@ class LSioFormatDriver {
*
* @retval array All objects data of the loaded file formated
**/
public function getAllFormated($fields,$generated_fields) {
public function getAllFormated($fields, $generated_fields) {
if (!is_array($fields)) return False;
if (!is_array($generated_fields)) $generated_fields=array();
$all=$this -> getAll();
$all = $this -> getAll();
if (!is_array($all)) return False;
$retall=array();
$retall = array();
foreach($all as $one) {
$retone=array();
$retone = array();
foreach($fields as $key => $attr) {
if (!isset($one[$key])) continue;
if (!isset($retone[$attr])) $retone[$attr]=array();
$retone[$attr][]=$one[$key];
if (!isset($retone[$attr])) $retone[$attr] = array();
$retone[$attr][] = $one[$key];
}
if (is_array($generated_fields)) {
foreach ($generated_fields as $attr => $format) {
$value=getFData($format,$retone);
if (!empty($value)) {
$retone[$attr]=array($value);
}
foreach ($generated_fields as $attr => $format) {
$value = getFData($format, $retone);
if (!empty($value)) {
$retone[$attr] = array($value);
}
}
$retall[]=$retone;
$retall[] = $retone;
}
return $retall;