From e8b8dd1730d3ac83be75cc018a84f2f08d92bfa0 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 7 Jul 2021 17:48:45 +0200 Subject: [PATCH] supannRessourceEtat & supannRessourceEtatDate: fix parsing & formating optional components value --- .../class.LSformElement_supannRessourceEtat.php | 4 ++-- .../class.LSformElement_supannRessourceEtatDate.php | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/includes/class/class.LSformElement_supannRessourceEtat.php b/src/includes/class/class.LSformElement_supannRessourceEtat.php index fd62d1d8..a6a7624c 100644 --- a/src/includes/class/class.LSformElement_supannRessourceEtat.php +++ b/src/includes/class/class.LSformElement_supannRessourceEtat.php @@ -73,7 +73,7 @@ class LSformElement_supannRessourceEtat extends LSformElement_supannCompositeAtt 'ressource' => $matches['ressource'], 'etat' => $matches['etat'], ); - if (isset($matches['sous_etat'])) + if (isset($matches['sous_etat']) && !is_empty($matches['sous_etat'])) $parseValue['sous_etat'] = $matches['sous_etat']; return $parseValue; } @@ -91,7 +91,7 @@ class LSformElement_supannRessourceEtat extends LSformElement_supannCompositeAtt if (!$value['ressource'] || !$value['etat']) return null; $ret = "{".$value['ressource']."}".$value['etat']; - if ($value['sous_etat']) + if (isset($value['sous_etat']) && !is_empty($matches['sous_etat'])) $ret .= ":".$value['sous_etat']; return $ret; } diff --git a/src/includes/class/class.LSformElement_supannRessourceEtatDate.php b/src/includes/class/class.LSformElement_supannRessourceEtatDate.php index b259f4b3..afca3040 100644 --- a/src/includes/class/class.LSformElement_supannRessourceEtatDate.php +++ b/src/includes/class/class.LSformElement_supannRessourceEtatDate.php @@ -85,8 +85,8 @@ class LSformElement_supannRessourceEtatDate extends LSformElement_supannComposit 'ressource' => $matches['ressource'], 'etat' => $matches['etat'], ); - foreach(array('sous_etat', 'date_debut', 'date_fin') as $c => $cconf) - if (isset($matches[$c])) + foreach(array('sous_etat', 'date_debut', 'date_fin') as $c) + if (isset($matches[$c]) && !is_empty($matches[$c])) $parseValue[$c] = $matches[$c]; return $parseValue; } @@ -104,9 +104,11 @@ class LSformElement_supannRessourceEtatDate extends LSformElement_supannComposit if (!$value['ressource'] || !$value['etat']) return null; $ret = "{".$value['ressource']."}".$value['etat']; - $ret .= ":".($value['sous_etat']?$value['sous_etat']:''); - $ret .= ":".($value['date_debut']?$value['date_debut']:''); - $ret .= ":".($value['date_fin']?$value['date_fin']:''); + foreach(array('sous_etat', 'date_debut', 'date_fin') as $c) { + $ret .= ":"; + if (isset($value[$c]) && !is_empty($value[$c])) + $ret .= $value[$c]; + } return $ret; } return False;