From b4a5824ee89ad3b9d01de4a3fdb3d6f7f0a98ddd Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 30 Nov 2020 19:44:14 +0100 Subject: [PATCH] Code cleaning --- .../class/class.LSattr_html_image.php | 4 ++-- .../class/class.LSattr_html_password.php | 4 ++-- .../class.LSformElement_postaladdress.php | 6 ++--- .../class/class.LSformRule_password.php | 10 ++++---- src/includes/class/class.LSioFormatDriver.php | 24 +++++++++---------- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/includes/class/class.LSattr_html_image.php b/src/includes/class/class.LSattr_html_image.php index f7f8fa32..ab1b36db 100644 --- a/src/includes/class/class.LSattr_html_image.php +++ b/src/includes/class/class.LSattr_html_image.php @@ -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'); } diff --git a/src/includes/class/class.LSattr_html_password.php b/src/includes/class/class.LSattr_html_password.php index c3d08054..76e8e657 100644 --- a/src/includes/class/class.LSattr_html_password.php +++ b/src/includes/class/class.LSattr_html_password.php @@ -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; } diff --git a/src/includes/class/class.LSformElement_postaladdress.php b/src/includes/class/class.LSformElement_postaladdress.php index af021854..b4f94bb5 100644 --- a/src/includes/class/class.LSformElement_postaladdress.php +++ b/src/includes/class/class.LSformElement_postaladdress.php @@ -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)); } diff --git a/src/includes/class/class.LSformRule_password.php b/src/includes/class/class.LSformRule_password.php index 9942ef7e..6e59b6f6 100644 --- a/src/includes/class/class.LSformRule_password.php +++ b/src/includes/class/class.LSformRule_password.php @@ -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"); diff --git a/src/includes/class/class.LSioFormatDriver.php b/src/includes/class/class.LSioFormatDriver.php index f5ca9761..b32d28e2 100644 --- a/src/includes/class/class.LSioFormatDriver.php +++ b/src/includes/class/class.LSioFormatDriver.php @@ -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;