1
0
Fork 0
forked from blallo/rss-bridge

[core] remove JSON based paramter definition related code

bye bye JSON

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-22 01:33:14 +02:00
parent f0e502ce37
commit dc4f16fbe4

View file

@ -45,18 +45,10 @@ CARD;
$hasGlobalParameter = array_key_exists('global', $bridgeElement->parameters); $hasGlobalParameter = array_key_exists('global', $bridgeElement->parameters);
if($hasGlobalParameter){ if($hasGlobalParameter){
if(is_array($bridgeElement->parameters['global'])){ $globalParameters = $bridgeElement->parameters['global'];
$globalParameters = $bridgeElement->parameters['global'];
}else{
$globalParameters = json_decode($bridgeElement->parameters['global'], true);
}
} }
foreach($bridgeElement->parameters as $parameterName => $parameter){ foreach($bridgeElement->parameters as $parameterName => $parameter){
if(!is_array($parameter)){
$parameter = json_decode($parameter, true);
}
if(!is_numeric($parameterName) && $parameterName == 'global') if(!is_numeric($parameterName) && $parameterName == 'global')
continue; continue;
@ -86,48 +78,40 @@ CARD;
if(!isset($inputEntry['defaultValue'])) if(!isset($inputEntry['defaultValue']))
$inputEntry['defaultValue'] = ''; $inputEntry['defaultValue'] = '';
$idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . (isset($inputEntry['identifier'])?urlencode($inputEntry['identifier']):urlencode($id)); $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . urlencode($id);
$card .= '<label for="' . $idArg . '">' . $inputEntry['name'] . ' : </label>' . PHP_EOL; $card .= '<label for="' . $idArg . '">' . $inputEntry['name'] . ' : </label>' . PHP_EOL;
if(!isset($inputEntry['type']) || $inputEntry['type'] == 'text') { if(!isset($inputEntry['type']) || $inputEntry['type'] == 'text') {
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="text" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . (isset($inputEntry['identifier'])?$inputEntry['identifier']:$id) . '" /><br />' . PHP_EOL; $card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="text" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $id . '" /><br />' . PHP_EOL;
} else if($inputEntry['type'] == 'number') { } else if($inputEntry['type'] == 'number') {
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="number" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . (isset($inputEntry['identifier'])?$inputEntry['identifier']:$id) . '" /><br />' . PHP_EOL; $card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="number" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $id . '" /><br />' . PHP_EOL;
} else if($inputEntry['type'] == 'list') { } else if($inputEntry['type'] == 'list') {
$card .= '<select ' . $additionalInfoString . ' id="' . $idArg . '" name="' . (isset($inputEntry['identifier'])?$inputEntry['identifier']:$id) . '" >'; $card .= '<select ' . $additionalInfoString . ' id="' . $idArg . '" name="' . $id . '" >';
foreach($inputEntry['values'] as $name=>$value) { foreach($inputEntry['values'] as $name=>$value) {
if(is_array($value) && is_numeric($name)){ if(is_array($value)){
$listValues=$value; $card.='<optgroup label="'.htmlentities($name).'">';
if($inputEntry['defaultValue'] === $listValues['name'] || $inputEntry['defaultValue'] === $listValues['value']) foreach($value as $subname=>$subvalue){
$card .= '<option value="' . $listValues['value'] . '" selected>' . $listValues['name'] . '</option>';
else
$card .= '<option value="' . $listValues['value'] . '">' . $listValues['name'] . '</option>';
}else{
if(is_array($value)){
$card.='<optgroup label="'.htmlentities($name).'">';
foreach($value as $subname=>$subvalue){
if($inputEntry['defaultValue'] === $subname || $inputEntry['defaultValue'] === $subvalue) if($inputEntry['defaultValue'] === $subname || $inputEntry['defaultValue'] === $subvalue)
$card .= '<option value="' . $subvalue . '" selected>' . $subname . '</option>'; $card .= '<option value="' . $subvalue . '" selected>' . $subname . '</option>';
else else
$card .= '<option value="' . $subvalue . '">' . $subname . '</option>'; $card .= '<option value="' . $subvalue . '">' . $subname . '</option>';
}
$card.='</optgroup>';
}else{
if($inputEntry['defaultValue'] === $name || $inputEntry['defaultValue'] === $value)
$card .= '<option value="' . $value . '" selected>' . $name . '</option>';
else
$card .= '<option value="' . $value . '">' . $name . '</option>';
} }
$card.='</optgroup>';
}else{
if($inputEntry['defaultValue'] === $name || $inputEntry['defaultValue'] === $value)
$card .= '<option value="' . $value . '" selected>' . $name . '</option>';
else
$card .= '<option value="' . $value . '">' . $name . '</option>';
} }
} }
$card .= '</select><br >'; $card .= '</select><br >';
} else if($inputEntry['type'] == 'checkbox') { } else if($inputEntry['type'] == 'checkbox') {
if($inputEntry['defaultValue'] === 'checked') if($inputEntry['defaultValue'] === 'checked')
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="checkbox" name="' . (isset($inputEntry['identifier'])?$inputEntry['identifier']:$id) . '" checked /><br />' . PHP_EOL; $card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="checkbox" name="' . $id . '" checked /><br />' . PHP_EOL;
else else
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="checkbox" name="' . (isset($inputEntry['identifier'])?$inputEntry['identifier']:$id) . '" /><br />' . PHP_EOL; $card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="checkbox" name="' . $id . '" /><br />' . PHP_EOL;
} }
} }