5 require_once 'plc_functions.php';
7 // the rationale behind having function names with _text is that
8 // the first functions that we had were actually printing the stuff instead of returning it
9 // so basically the foo (...) function should do ``print (foo_text(...))''
11 // options unused so far
12 function plc_form_start ($full_url, $values, $options=array()) {
13 if ( ! $values ) $values = array();
14 // extract var=value settings from url if any
15 $split=split_url($full_url);
17 $url_values=$split['values'];
18 if ( $url_values ) $values=array_merge($values,$url_values);
19 $method = array_key_exists('method',$options) ? $options['method'] : 'POST';
20 print "<form method=$method action='$url' enctype='multipart/form-data'>";
21 if ($values) foreach ($values as $key=>$value) {
22 print plc_form_hidden_text($key,$value);
26 function plc_form_end($options=array()) {
30 function plc_form_hidden_text ($key,$value) {
31 return "<input type=hidden name='$key' value='$value'/>";
33 function plc_form_hidden ($key,$value) { print plc_form_hidden_text($key,$value); }
35 function plc_form_checkbox_text ($name,$value,$selected=false) {
36 if ($selected) $xtra=" selected=selected";
37 return "<input type=checkbox name='$name' value='$value'$xtra/>";
40 function plc_form_submit_text ($name,$display) {
41 return "<input type=submit name='$name' value='$display'/>";
43 function plc_form_submit ($name, $display) { print plc_form_submit_text($name,$display); }
45 function plc_form_file_text ($name,$size) {
46 return "<input type=file name='$name' size=$size/>";
49 function plc_form_label_text ($name,$display) {
50 return "<label for=$name>$display </label>";
53 function plc_form_text_text ($name,$value,$size) {
54 return "<input type=text name='$name' size=$size value='$value'>";
56 function plc_form_textarea_text ($name,$value,$cols,$rows) {
57 return "<textarea name='$name' cols=$cols rows=$rows>$value</textarea>";
60 function plc_form_select_text ($name,$values,$label="") {
61 $encoded=htmlentities($label,ENT_QUOTES);
63 $selector.="<select name='$name'>";
65 $selector.="<option value=''>$encoded</option>";
66 foreach ($values as $chunk) {
67 $display=htmlentities($chunk['display'],ENT_QUOTES);
68 $value=$chunk['value'];
69 $selector .= "<option value='$value'";
70 if ($chunk['selected']) $selector .= " selected=selected";
71 $selector .= ">$display</option>\n";
73 $selector .= "</select>";
77 function plc_form_simple_button ($full_url,$text,$method="POST") {
78 $split=split_url($full_url);
80 $values=$split['values'];
81 $button=plc_form_submit_text("anonymous",$text);
82 if ($values) foreach ($values as $key=>$value)
83 $button .= plc_form_hidden_text($key,$value);
84 return "<form method=$method action=$url>$button</form>";