1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
2 -------------------------------------------------------------------------------
3 Ministerio de EconomÃa
5 -------------------------------------------------------------------------------
6 This file is part of meconlib.
8 meconlib is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your option)
13 meconlib is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License; if not,
18 write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Creado: jue jul 17 15:33:41 ART 2003
22 Autor: Gonzalo Merayo <gmeray@mecon.gov.ar>
23 Leandro Lucarella <llucar@mecon.gov.ar>
24 -------------------------------------------------------------------------------
26 -----------------------------------------------------------------------------*/
28 require_once 'MECON/HTML/Arbol.php';
29 require_once 'DB.php';
31 class MECON_HTML_ArbolDB extends MECON_HTML_Arbol
39 var $link_append = '';
44 function MECON_HTML_ArbolDB($dbdata, $titulo, $link_append = '')
46 if(isset($dbdata['id_padre']))
47 $this->padre = $dbdata['id_padre'];
48 $this->tabla = $dbdata['tabla'];
49 $this->nombre = $dbdata['nombre'];
50 $this->id = $dbdata['id'];
51 $this->id_activo = @$dbdata['id_activo'];
52 // FIXME - Deprecated!
53 if(isset($dbdata['prepend_link']))
54 $link_append = $dbdata['prepend_link'];
55 if(isset($dbdata['link']))
56 $this->link = $dbdata['link'];
57 if(isset($dbdata['where']))
58 $this->where = $dbdata['where'];
59 if(isset($dbdata['order']))
60 $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order'];
61 $this->db = $dbdata['db'];
62 parent::MECON_HTML_Arbol(array(), $titulo, $link_append);
63 $this->datos = $this->BuscarHijos(0);
66 function BuscarHijos($id)
68 $sql = "SELECT $this->nombre, $this->id ";
70 $sql .= ", $this->link ";
71 $sql .= "FROM $this->tabla ";
72 if($this->padre or $this->where)
75 $sql .= "$this->padre = '$id'";
78 } elseif ($this->where)
81 $result = $this->db->query($sql);
82 if(DB::isError($result))
83 die($result->getMessage());
85 while($row = $result->fetchRow())
89 if(!$this->padre) $sub = array();
90 else $sub = $this->BuscarHijos($id);
91 $link = strval(@$row[2]);
98 if (!is_null($this->id_activo) and $id == $this->id_activo) {