5 require_once 'plc_functions.php';
6 require_once 'plc_forms.php';
9 <link href="/planetlab/css/plc_details.css" rel="stylesheet" type="text/css" />
13 // the basic idea is to define an area for displaying details like
15 // and we add in-line editing capabilities
24 var $input_type="text";
26 function PlcDetails ($editable) {
27 $this->editable=$editable;
29 $this->field_width="";
30 $this->field_height="2";
33 // start the details area, with an optional caption
34 function start ($caption="") { print $this->start_html("$caption");}
35 function start_html ($caption="") {
36 $html="<table class=plc_details><thead>";
37 if ($caption) $html .= "<caption>$caption</caption>";
38 $html .= "</thead><tbody>";
42 function end() { print $this->end_html(); }
43 function end_html () {
44 return "</tbody></table>\n";
47 // starts an inner form if the details are editable
48 // accpets same args as PlcForm
49 function form_start ($url,$values,$method="POST") { print $this->form_start_html($url,$values,$method); }
50 function form_start_html ($url,$values,$method="POST") {
51 $this->form = new PlcForm ($url,$values,$method);
52 return $this->form->start_html();
55 function form_end () { print $this->form_end_html(); }
56 function form_end_html () {
57 if ( ! $this->form) return "";
58 $html = $this->form->end_html();
63 // must be embedded in a line or a single
64 // xxx need a way to ask for confirmation
65 function submit_html ($name,$display) {
66 if ( ! $this->form) return "";
67 if ( ! $this->editable) return "";
68 return $this->form->submit_html($name,$display);
71 // give a form_varname if the field can be edited
72 function line ($title,$value,$form_varname="") {
73 print $this->line_html ($title,$value,$form_varname);
75 function line_html ($title,$value,$form_varname="") {
76 if ( ! ($this->editable && $form_varname) ) {
77 return "<tr><th>$title</th><td>$value</td></tr>";
80 $html .= "<tr><th><label for=$form_varname>$title</label></th>";
81 $html .= "<td><input type='$this->input_type' name='$form_varname' value='$value'";
82 if ($this->input_type == "textarea") {
83 if ($this->field_width) $html .= " cols=$this->field_width/";
84 if ($this->field_height) $html .= " rows=$this->field_height/";
86 if ($this->field_width) $html .= " size=$this->field_width/";
88 $html .= "></td></tr>";
93 // same but the values are multiple and displayed in an embedded vertical table (not editable)
94 function lines($title,$list) { print $this->lines_html($title,$list); }
95 function lines_html($title,$list) {
96 return $this->line_html($title,plc_vertical_table($list,"foo"));
100 function single($title,$align=NULL) { print $this->single_html($title,$align);}
101 function single_html($title,$align=NULL) {
102 $result="<tr><td colspan=2";
103 if ($align) $result .= " style='text-align:$align'";
104 $result .=">$title</td></tr>";
108 // a dummy line for getting some air
109 function space () { print $this->space_html(); }
110 function space_html () { return "<tr><td colspan=2> </td></tr>\n"; }
112 function set_field_width ($field_width) {
113 $old=$this->field_width;
114 $this->field_width=$field_width;
117 function set_field_height ($field_height) {
118 $old=$this->field_height;
119 $this->field_height=$field_height;
123 function set_input_type ($input_type) {
124 $old=$this->input_type;
125 $this->input_type=$input_type;