ckp - persons/nodes/peers/events complete
[plewww.git] / planetlab / includes / plc_forms.php
1 <?php
2
3 // $Id: plc_details.php 11645 2009-01-21 23:09:49Z thierry $
4
5 require_once 'plc_functions.php';
6
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(...))''
10
11 function plc_form_start ($url, $values, $options=array()) {
12   $method = array_key_exists('method',$options) ? $options['method'] : 'POST';
13   print "<form method=$method action='$url' enctype='multipart/form-data'>";
14   foreach ($values as $key=>$value) {
15     print "<input type=hidden name='$key' value='$value'>";
16   }
17 }
18
19 function plc_form_end($options=array()) {
20   print "</form>";
21 }
22
23 function plc_form_checkbox_text ($name,$value,$selected=false) {
24   if ($selected) $xtra=" selected=selected";
25   return "<input type=checkbox name='$name' value='$value'$xtra>";
26 }
27
28 function plc_form_submit_text ($name,$display) {
29   return "<input type=submit name='$name' value='$display'>";
30 }
31   
32 function plc_form_file_text ($name,$size) {
33   return "<input type=file name='$name' size=$size>";
34 }
35
36 function plc_form_label_text ($name,$display) {
37   return "<label for=$name>$display </label>";
38 }
39  
40 function plc_form_select_text ($name,$values,$label="") {
41   $selector="";
42   $selector.="<select name='$name'>";
43   if ($label) 
44     $selector.="<option value=''>$label</option>";
45   foreach ($values as $chunk) {
46     $display=$chunk['display'];
47     $value=$chunk['value'];
48     $selector .= "<option value='$value'>$display</option>\n";
49   }
50   $selector .= "</select>";
51   return $selector;
52 }
53
54 ?>