$x $y "; } function boxes($options) { $x = "".tra("[check all that apply]")."
\n"; foreach ($options as $name => $text) { $x .= " $text
\n"; } return $x; } function radio($radio_name, $options) { $x = ""; foreach ($options as $name => $text) { $x .= " $text
\n"; } return $x; } function show_choice($choice, $outer_radio) { $rname = $choice["rname"]; $text = $choice["text"]; $radio_name = $choice["radio_name"]; $x = ""; if ($rname) { $x .= ""; } $x .= $text; if ($radio_name) { $y = radio($radio_name, $choice["options"]); } else { $y = boxes($choice["options"]); $other_name = $choice['other_name']; $y .= tra("Other:")." "; } list_item2($x, $y); } function show_choices($choices, $outer_radio) { foreach ($choices as $choice) { show_choice($choice, $outer_radio); } } function generate_functions($choices) { echo "\n"; } function new_response($uid, $xml) { $now = time(); return mysql_query("insert into response (uid, create_time, update_time, xml) values ('$uid', $now, $now, '$xml')"); } function update_response($uid, $xml) { $now = time(); return mysql_query("update response set update_time=$now, xml='$xml' where uid='$uid'"); } function select_response($uid) { $result = mysql_query("select * from response where uid='$uid'"); $response = mysql_fetch_object($result); mysql_free_result($result); return $response; } function parse_form_choice($x, $choice) { $radio_name= $choice["radio_name"]; if ($radio_name) { $x[$radio_name] = get_str($radio_name); } else { $options = $choice["options"]; foreach ($options as $name=>$text) { $x[$name] = get_str($name); } $other_name = $choice['other_name']; $x[$other_name] = get_str($other_name); } return $x; } function parse_form_choices($x, $choices) { foreach ($choices as $choice) { $x = parse_form_choice($x, $choice); } return $x; } function gen_xml_choice($x, $choice) { $xml = ""; $radio_name= $choice["radio_name"]; if ($radio_name) { $val = urlencode($x[$radio_name]); $xml .= "<$radio_name>$val\n"; } else { $options = $choice["options"]; foreach ($options as $name=>$text) { $val = urlencode($x[$name]); $xml .= "<$name>$val\n"; } $other_name = $choice['other_name']; $text = urlencode($x[$other_name]); $xml .= "<$other_name>$text\n"; } return $xml; } function gen_xml_choices($x, $choices) { foreach ($choices as $choice) { $xml .= gen_xml_choice($x, $choice); } return $xml; } ?>