X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/4cf359b26dbb47d985591feb13d4b5a4d6904065..641b493b06032b0832c9a882dbcecca590ea3d1d:/lib/MECON/HTML/ArbolDB.php?ds=sidebyside diff --git a/lib/MECON/HTML/ArbolDB.php b/lib/MECON/HTML/ArbolDB.php index a931a2c..dedf3b9 100644 --- a/lib/MECON/HTML/ArbolDB.php +++ b/lib/MECON/HTML/ArbolDB.php @@ -126,7 +126,7 @@ class MECON_HTML_ArbolDB extends MECON_HTML_Arbol * @return void * @access public */ - function MECON_HTML_ArbolDB($dbdata, $titulo, $link_append = '') + function MECON_HTML_ArbolDB($dbdata, $titulo, $link_append = '', $expandir = false) { if(isset($dbdata['id_padre'])) $this->padre = $dbdata['id_padre']; @@ -141,9 +141,29 @@ class MECON_HTML_ArbolDB extends MECON_HTML_Arbol $this->link = $dbdata['link']; if(isset($dbdata['where'])) $this->where = $dbdata['where']; + if(isset($dbdata['habilitado'])) + $this->habilitado = $dbdata['habilitado']; if(isset($dbdata['order'])) $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order']; $this->db = $dbdata['db']; + + if(!$expandir) + { + $this->expandir = array($this->id_activo); + if(isset($this->id_activo)) + { + $id = $this->id_activo; + while($id != 0) + { + $sql = "SELECT $this->padre + FROM $this->tabla + WHERE $this->id = '".$id."'"; + $id = $this->db->getOne($sql); + $this->expandir[] = $id; + } + } + } + parent::MECON_HTML_Arbol(array(), $titulo, $link_append); $this->datos = $this->BuscarHijos(0); } @@ -170,6 +190,8 @@ class MECON_HTML_ArbolDB extends MECON_HTML_Arbol $sql .= ' AND'; } elseif ($this->where) $sql .= $this->where; + if(isset($this->habilitado)) + $sql .= " AND ".$this->habilitado." = 1 "; $sql .= $this->order; $result = $this->db->query($sql); if(DB::isError($result)) @@ -179,7 +201,9 @@ class MECON_HTML_ArbolDB extends MECON_HTML_Arbol { $titulo = $row[0]; $id = $row[1]; - if(!$this->padre) $sub = array(); + if(!$this->padre || !(!isset($this->expandir) || + in_array($id, $this->expandir))) + $sub = array(); else $sub = $this->BuscarHijos($id); $link = strval(@$row[2]); $d = array( @@ -188,6 +212,8 @@ class MECON_HTML_ArbolDB extends MECON_HTML_Arbol 'id' => $id, 'sub' => $sub ); + if(isset($this->expandir) && in_array($id, $this->expandir) && $id != $this->id_activo) + $d['bold'] = 1; if (!is_null($this->id_activo) and $id == $this->id_activo) { $d['activo'] = 1; }