3 require_once 'MECON/HTML/Arbol.php';
8 class HTML_ArbolDB extends HTML_Arbol
15 var $prepend_link = null;
20 function HTML_ArbolDB($dbdata, $imagen)
22 if(isset($dbdata['id_padre']))
23 $this->padre = $dbdata['id_padre'];
24 $this->tabla = $dbdata['tabla'];
25 $this->nombre = $dbdata['nombre'];
26 $this->id = $dbdata['id'];
27 if(isset($dbdata['prepend_link']))
28 $this->prepend_link = $dbdata['prepend_link'];
29 if(isset($dbdata['link']))
30 $this->link = $dbdata['link'];
31 if(isset($dbdata['where']))
32 $this->where = $dbdata['where'];
33 if(isset($dbdata['order']))
34 $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order'];
35 $this->db = $dbdata['db'];
36 $dat = $this->BuscarHijos(0);
37 parent::HTML_Arbol($dat, $imagen);
40 function BuscarHijos($id)
42 $sql = "SELECT $this->nombre, $this->id ";
43 if(!is_null($this->link))
44 $sql .= ", $this->link ";
45 $sql .= "FROM $this->tabla ";
46 if(!is_null($this->padre) or $this->where)
48 if(!is_null($this->padre)) {
49 $sql .= "$this->padre = '$id'";
52 } elseif ($this->where)
55 $result = $this->db->query($sql);
56 if(DB::isError($result))
57 die($result->getMessage());
59 while($row = $result->fetchRow())
63 if(is_null($this->padre)) $sub = array();
64 else $sub = $this->BuscarHijos($id);
65 if(!is_null($this->link)) $link = $this->prepend_link.$row[2];
66 else $link = $this->prepend_link.$id;