X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/4c80b40da97be7e87af6a6e421677122e1e581f9..387525736846a1dad72e99ccf416708ff811c92c:/lib/MECON/HTML/Arbol/ArbolDB.php?ds=sidebyside diff --git a/lib/MECON/HTML/Arbol/ArbolDB.php b/lib/MECON/HTML/Arbol/ArbolDB.php index 13e9d99..6937df8 100644 --- a/lib/MECON/HTML/Arbol/ArbolDB.php +++ b/lib/MECON/HTML/Arbol/ArbolDB.php @@ -7,20 +7,25 @@ require_once 'DB.php'; class HTML_ArbolDB extends HTML_Arbol { - var $padre; + var $padre = null; var $tabla; var $nombre; var $id; - var $link; + var $link = null; + var $prepend_link = null; var $db; function HTML_ArbolDB($dbdata, $imagen) { - $this->padre = $dbdata['id_padre']; + if(isset($dbdata['id_padre'])) + $this->padre = $dbdata['id_padre']; $this->tabla = $dbdata['tabla']; $this->nombre = $dbdata['nombre']; $this->id = $dbdata['id']; - $this->link = $dbdata['link']; + 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); @@ -28,9 +33,12 @@ class HTML_ArbolDB extends HTML_Arbol function BuscarHijos($id) { - $sql = "SELECT $this->nombre, $this->id - FROM $this->tabla - WHERE $this->padre = '$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()); @@ -39,10 +47,14 @@ class HTML_ArbolDB extends HTML_Arbol { $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' => $this->link.$id, - 'sub' => $this->BuscarHijos($id) + 'link' => $link, + 'sub' => $sub ); } return $dat;