diff --git a/lib/HTMLUtils.php b/lib/HTMLUtils.php index 756ee09..03763af 100644 --- a/lib/HTMLUtils.php +++ b/lib/HTMLUtils.php @@ -44,11 +44,18 @@ CARD; $hasGlobalParameter = array_key_exists('global', $bridgeElement->parameters); - if($hasGlobalParameter) - $globalParameters = json_decode($bridgeElement->parameters['global'], true); + if($hasGlobalParameter){ + if(is_array($bridgeElement->parameters['global'])){ + $globalParameters = $bridgeElement->parameters['global']; + }else{ + $globalParameters = json_decode($bridgeElement->parameters['global'], true); + } + } foreach($bridgeElement->parameters as $parameterName => $parameter){ - $parameter = json_decode($parameter, true); + if(!is_array($parameter)){ + $parameter = json_decode($parameter, true); + } if(!is_numeric($parameterName) && $parameterName == 'global') continue; @@ -61,7 +68,7 @@ CARD; $card .= HTMLUtils::getFormHeader($bridgeName); - foreach($parameter as $inputEntry) { + foreach($parameter as $id=>$inputEntry) { $additionalInfoString = ''; if(isset($inputEntry['required']) && $inputEntry['required'] === true) @@ -79,29 +86,37 @@ CARD; if(!isset($inputEntry['defaultValue'])) $inputEntry['defaultValue'] = ''; - $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . urlencode($inputEntry['identifier']); + $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . (isset($inputEntry['identifier'])?urlencode($inputEntry['identifier']):urlencode($id)); $card .= '' . PHP_EOL; if(!isset($inputEntry['type']) || $inputEntry['type'] == 'text') { - $card .= '
' . PHP_EOL; + $card .= '
' . PHP_EOL; } else if($inputEntry['type'] == 'number') { - $card .= '
' . PHP_EOL; + $card .= '
' . PHP_EOL; } else if($inputEntry['type'] == 'list') { - $card .= ''; - foreach($inputEntry['values'] as $listValues) { + foreach($inputEntry['values'] as $name=>$value) { + if(is_array($value) && is_numeric($name)){ + $listValues=$value; if($inputEntry['defaultValue'] === $listValues['name'] || $inputEntry['defaultValue'] === $listValues['value']) $card .= ''; else $card .= ''; - } + }else{ + if($inputEntry['defaultValue'] === $name || $inputEntry['defaultValue'] === $value) + $card .= ''; + else + $card .= ''; + } + } $card .= '
'; } else if($inputEntry['type'] == 'checkbox') { if($inputEntry['defaultValue'] === 'checked') - $card .= '
' . PHP_EOL; + $card .= '
' . PHP_EOL; else - $card .= '
' . PHP_EOL; + $card .= '
' . PHP_EOL; } }