X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/6c963757fb2c5e038b93c67fff64997180c33c09..51a1428cd773aa45b8da0bb9b715784c16c93c44:/lib/MECON/HTML/ArbolDB.php?ds=inline diff --git a/lib/MECON/HTML/ArbolDB.php b/lib/MECON/HTML/ArbolDB.php index fc0ca68..dedf3b9 100644 --- a/lib/MECON/HTML/ArbolDB.php +++ b/lib/MECON/HTML/ArbolDB.php @@ -28,20 +28,105 @@ $Id$ require_once 'MECON/HTML/Arbol.php'; require_once 'DB.php'; +/** + * DESC + * + * @access public + */ class MECON_HTML_ArbolDB extends MECON_HTML_Arbol { + + /** + * DESC + * + * @var string $padre + * @access public + */ var $padre = ''; + + /** + * DESC + * + * @var TIPO $tabla + * @access public + */ var $tabla; + + /** + * DESC + * + * @var string $nombre + * @access public + */ var $nombre; + + /** + * DESC + * + * @var TIPO $id + * @access public + */ var $id; + + /** + * DESC + * + * @var TIPO $id_activo + * @access public + */ var $id_activo; + + /** + * DESC + * + * @var string $link + * @access public + */ var $link = ''; + + /** + * DESC + * + * @var string $link_append + * @access public + */ var $link_append = ''; + + /** + * DESC + * + * @var string $where + * @access public + */ var $where = ''; + + /** + * DESC + * + * @var string $order + * @access public + */ var $order = ''; + + /** + * DESC + * + * @var DB $db + * @access public + */ var $db; - function MECON_HTML_ArbolDB($dbdata, $titulo, $link_append = '') + /** + * Constructor + * + * @param TIPO $dbdata DESC + * @param TIPO $titulo DESC + * @param string $link_append DESC + * + * @return void + * @access public + */ + function MECON_HTML_ArbolDB($dbdata, $titulo, $link_append = '', $expandir = false) { if(isset($dbdata['id_padre'])) $this->padre = $dbdata['id_padre']; @@ -56,13 +141,41 @@ 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); } - + + /** + * DESC + * + * @param TIPO $id DESC + * + * @return TIPO + * @access public + */ function BuscarHijos($id) { $sql = "SELECT $this->nombre, $this->id "; @@ -77,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)) @@ -86,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( @@ -95,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; }