';
foreach ($records as $record) {
// Scelta fra piĆ¹ valori
echo '
';
if (preg_match("/list\[(.+?)\]/", $record['tipo'], $m)) {
$m = explode(",", $m[1]);
$list = "";
for($j = 0; $j < sizeof($m); $j ++) {
if ($j != 0) $list .= ",";
$list .= "\\\"" . $m[$j] . "\\\": \\\"" . $m[$j] . "\\\"";
}
echo '
{[ "type": "select", "label": "' . $record['nome'] . '", "name": "' . $record['idimpostazione'] . '", "required": 0, "class": "", "values": "list=' . $list . '", "value": "' . $record['valore'] . '", "extra": "" ]}';
}
// query
else if (preg_match("/^query=(.+?)$/", $record['tipo'], $m)) {
echo '
{[ "type": "select", "label": "' . $record['nome'] . '", "name": "' . $record['idimpostazione'] . '", "required": 0, "class": "", "values": "' . $record["tipo"] . '", "value": "' . $record['valore'] . '", "extra": "" ]}';
}
// Boolean (checkbox)
else if ($record['tipo'] == 'boolean') {
$checkbox .= $record['idimpostazione'] . ",";
echo '
{[ "type": "checkbox", "label": "' . $record['nome'] . '", "name": "' . $record['idimpostazione'] . '", "placeholder": "' . _("Attivo") . '", "required": 0, "class": "", "value": "", "extra": "';
if ($record['valore'] == 1) echo ' checked';
echo '" ]}';
}
else if ($record['tipo'] == 'textarea') {
echo '
{[ "type": "textarea", "label": "' . $record['nome'] . '", "name": "' . $record['idimpostazione'] . '", "required": 0, "class": "autosize", "value": "' . $record['valore'] . '", "extra": "" ]}';
}
// Campo di testo normale
else {
$tipo = (preg_match("/password/i", $record['nome'], $m)) ? "password" : "text";
echo '
{[ "type": "' . $tipo . '", "label": "' . $record['nome'] . '", "name": "' . $record['idimpostazione'] . '", "required": 0, "class": "", "value": "' . $record['valore'] . '", "extra": "" ]}';
}
echo '
';
}
echo '