supannRessourceEtat & supannRessourceEtatDate: fix parsing & formating optional components value

This commit is contained in:
Benjamin Renard 2021-07-07 17:48:45 +02:00
parent 3c6ce596d9
commit e8b8dd1730
2 changed files with 9 additions and 7 deletions

View file

@ -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;
}

View file

@ -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;