X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/71acf4950362871b3ad6bc168d08db422edf0509..7daf31ceedd9e6b0aba992d962fc8c66a1c5d8fd:/lib/MECON/HTML/Arbol/ArbolDB.php diff --git a/lib/MECON/HTML/Arbol/ArbolDB.php b/lib/MECON/HTML/Arbol/ArbolDB.php index 111c4e5..78dfd5f 100644 --- a/lib/MECON/HTML/Arbol/ArbolDB.php +++ b/lib/MECON/HTML/Arbol/ArbolDB.php @@ -20,6 +20,7 @@ Boston, MA 02111-1307 USA ------------------------------------------------------------------------------- Creado: jue jul 17 15:33:41 ART 2003 Autor: Gonzalo Merayo + Leandro Lucarella ------------------------------------------------------------------------------- $Id$ -----------------------------------------------------------------------------*/ @@ -29,45 +30,48 @@ require_once 'DB.php'; class HTML_ArbolDB extends HTML_Arbol { - var $padre = null; - var $tabla; - var $nombre; - var $id; - var $link = null; - var $prepend_link = null; - var $where = ''; - var $order = ''; - var $db; + var $padre = ''; + var $tabla; + var $nombre; + var $id; + var $id_activo; + var $link = ''; + var $link_append = ''; + var $where = ''; + var $order = ''; + var $db; - function HTML_ArbolDB($dbdata, $imagen) + function HTML_ArbolDB($dbdata, $titulo, $link_append = '') { if(isset($dbdata['id_padre'])) - $this->padre = $dbdata['id_padre']; - $this->tabla = $dbdata['tabla']; - $this->nombre = $dbdata['nombre']; - $this->id = $dbdata['id']; + $this->padre = $dbdata['id_padre']; + $this->tabla = $dbdata['tabla']; + $this->nombre = $dbdata['nombre']; + $this->id = $dbdata['id']; + $this->id_activo = @$dbdata['id_activo']; + // FIXME - Deprecated! if(isset($dbdata['prepend_link'])) - $this->prepend_link = $dbdata['prepend_link']; + $link_append = $dbdata['prepend_link']; if(isset($dbdata['link'])) - $this->link = $dbdata['link']; + $this->link = $dbdata['link']; if(isset($dbdata['where'])) - $this->where = $dbdata['where']; + $this->where = $dbdata['where']; if(isset($dbdata['order'])) - $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order']; - $this->db = $dbdata['db']; - $dat = $this->BuscarHijos(0); - parent::HTML_Arbol($dat, $imagen); + $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order']; + $this->db = $dbdata['db']; + parent::HTML_Arbol(array(), $titulo, $link_append); + $this->datos = $this->BuscarHijos(0); } function BuscarHijos($id) { $sql = "SELECT $this->nombre, $this->id "; - if(!is_null($this->link)) - $sql .= ", $this->link "; + if($this->link) + $sql .= ", $this->link "; $sql .= "FROM $this->tabla "; - if(!is_null($this->padre) or $this->where) + if($this->padre or $this->where) $sql .= 'WHERE '; - if(!is_null($this->padre)) { + if($this->padre) { $sql .= "$this->padre = '$id'"; if ($this->where) $sql .= ' AND'; @@ -82,15 +86,19 @@ class HTML_ArbolDB extends HTML_Arbol { $titulo = $row[0]; $id = $row[1]; - if(is_null($this->padre)) $sub = array(); + if(!$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 + $link = strval(@$row[2]); + $d = array( + 'titulo'=> $titulo, + 'link' => $link, + 'id' => $id, + 'sub' => $sub ); + if (!is_null($this->id_activo) and $id == $this->id_activo) { + $d['activo'] = 1; + } + $dat[] = $d; } return $dat;