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'];
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 ";
{
$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(
'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;
}