_row_added(tableId, rowNr) _field_changed(tableId, rowNr, fieldId, field) */ private $tablename = ""; private $fields = array(); public $editmode = false; public $fields_details = null; public $keyfield = ""; public function HaproxyHtmlList($tablename, $fields){ $this->tablename = $tablename; $this->fields = $fields; } public function Draw($data){ $this->haproxy_htmllist($data, $this->fields, $this->editmode, $this->fields_details); } function haproxy_htmllist_get_values(){ $values = array(); for($x=0; $x<99; $x++) { $value = array(); $add_item = false; foreach($this->fields as $item){ $itemname = $item['name']; $value[$itemname] = $_POST[$itemname.$x]; if ($item['type'] == 'textarea') $value[$itemname] = base64_encode($value[$itemname]); $add_item |= isset($_POST[$itemname.$x]); } if ($add_item) { if ($this->keyfield != "") { if (isset($_POST[$this->tablename."_key".$x])) $key = $_POST[$this->tablename."_key".$x]; else $key = $_POST[$this->keyfield.$x]; } else $key = ""; if (isset($values[$key])) $values[] = $value; else $values[$key] = $value; } } return $values; } private function haproxy_htmllist_drawcell($item, $itemvalue, $editable, $itemname, $counter) { $itemnamenr = $itemname . $counter; $itemtype = $item['type']; if ($editable) { $itemtype = $item['type']; if ($itemtype == "select"){ echo_html_select($itemnamenr, $item['items'], $itemvalue,"","html_listitem_change(\"{$this->tablename}\",\"{$itemname}\",\"{$counter}\",this);", "width:{$item['size']}"); } else if ($itemtype == "checkbox"){ $checked = $itemvalue=='yes' ? " checked" : ""; echo ""; } else if ($itemtype == "textarea"){ echo ""; } else echo ""; } else { if ($itemtype == "select"){ echo $item['items'][$itemvalue]['name']; } else if ($itemtype == "checkbox"){ echo $itemvalue=='yes' ? gettext('yes') : gettext('no'); } else if ($itemtype == "textarea"){ echo '
'; echo str_replace("\n","
", htmlspecialchars(base64_decode($itemvalue))); echo '
'; } else echo htmlspecialchars($itemvalue); } } function haproxy_htmllist($rowvalues,$items,$editstate=false,$itemdetails=null){ $tablename = $this->tablename; global $g, $counter; echo ""; foreach($items as $item){ echo ""; } echo ""; if (is_array($rowvalues)){ foreach($rowvalues as $keyid => $value){ if ($this->keyfield != "") { if (preg_match("/[^0-9]/", $keyid)) $itemvalue = $keyid; else $itemvalue = $value[$this->keyfield]; $key = ""; } else $key = ""; if (!$editstate) { echo ""; $leftitem = true; foreach($items as $item) { $tdclass = $leftitem ? "vtable listlr" : "vtable listr"; echo ""; $leftitem = false; } echo " "; echo ""; } $displaystyle = $editstate ? "" : "display: none;"; echo ""; foreach($items as $item){ $itemname = $item['name']; $itemvalue = $value[$itemname]; echo ""; $key = ""; } echo " "; echo ""; if (isset($itemdetails)) { $colspan = count($items)-1; echo ""; ?> "; $itemnr = 0; echo "
"; $itemcount = count($itemdetails); foreach($itemdetails as $item) { echo "
"; $tdclass = "";//$leftitem ? "vtable listlr" : "vtable listr"; echo $item['columnheader'] . ": "; $itemname = $item['name']; $itemvalue = $value[$itemname]; if (isset($item['customdrawcell'])) { $item['customdrawcell']($item, $itemvalue, false); } else $this->haproxy_htmllist_drawcell($item, $itemvalue, false, $itemname, $counter); $leftitem = false; $itemnr++; if ($itemcount != $itemnr) echo ", "; echo "
"; } echo "
"; echo "
{$item['columnheader']}
"; $itemname = $item['name']; $itemvalue = $value[$itemname]; if (isset($item['customdrawcell'])) { $item['customdrawcell']($item, $itemvalue, false); } else $this->haproxy_htmllist_drawcell($item, $itemvalue, false, $itemname, $counter); echo "
".$key; if (isset($item['customdrawcell'])) { $item['customdrawcell']($item, $itemvalue, true, $item['name'].$counter); } else $this->haproxy_htmllist_drawcell($item, $itemvalue, true, $itemname, $counter); echo "
"; $leftitem = true; foreach($itemdetails as $item) { echo ""; $tdclass = "";//$leftitem ? "vtable listlr" : "vtable listr"; echo ""; echo ""; $leftitem = false; echo ""; } echo "
"; echo "{$item['columnheader']}: "; echo ""; $itemname = $item['name']; $itemvalue = $value[$itemname]; echo "{$item['description']}
"; if (isset($item['customdrawcell'])) { $item['customdrawcell']($item, $itemvalue, true, $itemname . $counter); } else $this->haproxy_htmllist_drawcell($item, $itemvalue, true, $itemname, $counter); echo "
"; echo ""; echo ""; echo ""; } if (isset($itemdetails)) { $colspan = count($items)-1; echo ""; echo " "; echo ""; echo ""; echo ""; } $counter++; } } echo " "; } } function haproxy_htmllist($tablename,$rowvalues,$items,$editstate=false,$itemdetails=null){ $list = new HaproxyHtmlList($tablename, $items); $list->haproxy_htmllist($rowvalues, $items, $editstate, $itemdetails); } function haproxy_htmllist_get_values($html_list){ $list = new HaproxyHtmlList("-", $html_list); return $list->haproxy_htmllist_get_values(); } function haproxy_htmllist_js(){ ?>