X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/fcfef745c429ee47bc1cd691b8d67166e4f645e4..1ea8f55789a0a38e7916de61221f37a8aedeacef:/lib/MECON/HTML/Arbol/ArbolDB.php?ds=inline diff --git a/lib/MECON/HTML/Arbol/ArbolDB.php b/lib/MECON/HTML/Arbol/ArbolDB.php index 09f53be..6937df8 100644 --- a/lib/MECON/HTML/Arbol/ArbolDB.php +++ b/lib/MECON/HTML/Arbol/ArbolDB.php @@ -1,67 +1,65 @@ 'Nivel0a', - 'link' => 'blabla', - 'sub' => array(//sub0 - array( - 'titulo' => 'Nivel1a', - 'link' => 'blabla', - 'sub' => array(//sub1 - array( - 'titulo' => 'Nivel3a', - 'link' => 'blabla', - 'activado' => 1 - ), - array( - 'titulo' => 'Nivel3b', - 'link' => 'blabla', - 'sub' => array(//sub2 - array( - 'titulo' => 'Nivel4', - 'link' => 'blabla' - ) - )//sub2 - ), - array( - 'titulo' => 'Nivel3c', - 'link' => 'blabla' - ) - )//sub1 - ), - array( - 'titulo' => 'Nivel1b', - 'link' => 'blabla', - 'activado' => 1 - ), - array( - 'titulo' => 'Nivel1c', - 'link' => 'blabla' - ) - )//sub0 - ), - array( - 'titulo' => 'Nivel0b', - 'link' => 'blabla' - ), - array( - 'titulo' => 'Nivel0c', - 'link' => 'blabla' - ) - ); - - parent::Arbol($dat); + if(isset($dbdata['id_padre'])) + $this->padre = $dbdata['id_padre']; + $this->tabla = $dbdata['tabla']; + $this->nombre = $dbdata['nombre']; + $this->id = $dbdata['id']; + if(isset($dbdata['prepend_link'])) + $this->prepend_link = $dbdata['prepend_link']; + if(isset($dbdata['link'])) + $this->link = $dbdata['link']; + $this->db = $dbdata['db']; + $dat = $this->BuscarHijos(0); + parent::HTML_Arbol($dat, $imagen); } -} + + function BuscarHijos($id) + { + $sql = "SELECT $this->nombre, $this->id "; + if(!is_null($this->link)) + $sql .= ", $this->link "; + $sql .= "FROM $this->tabla "; + if(!is_null($this->padre)) + $sql .= "WHERE $this->padre = '$id'"; + $result = $this->db->query($sql); + if(DB::isError($result)) + die($result->getMessage()); + $dat = array(); + while($row = $result->fetchRow()) + { + $titulo = $row[0]; + $id = $row[1]; + if(is_null($this->padre)) $sub = array(); + else $sub = $this->BuscarHijos($id); + if(!is_null($this->link)) $link = $this->prepend_link.$row[2]; + else $link = $this->prepend_link.$id; + $dat[] = array( + 'titulo'=> $titulo, + 'link' => $link, + 'sub' => $sub + ); + } + return $dat; + } +} ?>