generico: * {[ "type": "text", "required": 1, "class": "", "value": "$idintervento$", "extra": "" ]} * * campo di testo normale e non modificabile * {[ "type": "span", "value": "$testo$" ]} * * '; break; case 'select' : $values = isset($json['values']) ? $json['values'] : ""; if (isset($json['multiple']) && $json['multiple'] == 1) array_push($attributi, "multiple"); if (isset($json['ajax-source']) && $json['ajax-source'] != "") { array_push($valori["class"], "superselectajax"); array_push($attributi, "data-source"); $valori["data-source"] = $json['ajax-source']; } else array_push($valori["class"], "superselect"); $placeholder = isset($json['placeholder']) ? $json['placeholder'] : "- Seleziona un'opzione -"; if (strpos($value, "Seleziona") !== false) { $placeholder = $value; $value = ""; } $html .= ' da query else if (preg_match_all("/^query=(.+?)$/", $values, $m)) { $q = $m[1][0]; $q = str_replace("", ".\"", $q); $q = str_replace("?>", ".\"", $q); eval("\$query = \"" . $q . "\";"); $rs = $dbo->fetchArray($query); if (!isset($json['multiple']) || ! $json['multiple']) { $html .= ' '; } // se non presente, carica eventuale valore predefinito if (($value == "0" || $value == "") && isset($json['valore_predefinito']) && $json['valore_predefinito'] != "") $value = get_var($json['valore_predefinito']); $prev = ""; for($i = 0; $i < sizeof($rs); $i ++) { if (isset($rs[$i]["optgroup"])) { if ($prev != $rs[$i]["optgroup"]) { $html .= ' '; $prev = $rs[$i]["optgroup"]; } $rs[$i]['descrizione'] = "   " . $rs[$i]['descrizione']; } $sub_attr = array(); if (in_array($rs[$i]['id'], explode(',', $value)) || ($rs[$i]['id'] == $value)) array_push($sub_attr, 'selected="true"'); if (isset($rs[$i]['_bgcolor_']) && $rs[$i]['_bgcolor_'] != '') array_push($sub_attr, 'style="background:' . $rs[$i]['_bgcolor_'] . '; color:' . color_inverse($rs[$i]['_bgcolor_']) . ';"'); // Leggo ulteriori campi oltre a id e descrizione per inserirli nell'option nella forma "data-nomecampo1", "data-nomecampo2", ecc foreach ($rs[$i] as $k => $v) { if ($k != 'id' && $k != 'descrizione' && $k != 'optgroup') array_push($sub_attr, 'data-' . $k . '="' . $v . '"'); } $html .= ' '; } } // Generazione '; if (in_array("disabled", $attributi) || in_array("readonly", $attributi)) $html .= ' '; if (in_array("readonly", $attributi)) { $html .= ' '; } break; case 'textarea' : $html .= ' '; unset($value); break; case 'checkbox' : if ($value == 1) { array_push($attributi, "checked"); $valori["checked"] = "true"; $value = "on"; } if (in_array("readonly", $attributi)) array_push($attributi, "disabled"); array_push($attributi, 'type'); $valori["type"] = "checkbox"; $placeholder = (isset($json["placeholder"])) ? $json["placeholder"] : $json["label"]; $html .= '
'; if (in_array("readonly", $attributi)) $html .= ' '; $html .= '
'; unset($valori["class"][0]); unset($value); break; case 'image' : unset($valori["class"][0]); // Form upload if ($value == '') { array_push($attributi, 'type'); $valori["type"] = "file"; $html .= ' '; } // Visualizzazione immagine e spunta per cancellazione else { array_push($valori["class"], "img-thumbnail"); array_push($valori["class"], "img-responsive"); $html .= '
'; } unset($value); break; default : $html .= " " . $value . "\n"; break; } if (isset($json['icon-after'])) { $html .= ' '; } if (isset($json['icon-before']) || isset($json['icon-after'])) { $html .= ' '; } $html .= ' '; if(isset($script_value) && $script_value != ""){ $html .= ' '; } if (isset($json['extra'])) array_push($attributi, trim($json['extra'])); if (isset($value)) { array_push($attributi, 'value'); $valori["value"] = $value; } $result = array(); foreach ($attributi as $attributo) { $valore = $attributo; if (isset($valori[$attributo]) && $valori[$attributo] != "") { if (is_array($valori[$attributo])) $valore .= '="' . implode(" ", $valori[$attributo]) . '"'; else $valore .= '="' . $valori[$attributo] . '"'; } array_push($result, $valore); } $html = str_replace("|attr|", implode(" ", $result), $html); return $html; } ?>