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 HTML_ArbolDB extends HTML_Arbol
38 var $link_append = '';
43 function HTML_ArbolDB($dbdata, $titulo, $link_append = '')
45 if(isset($dbdata['id_padre']))
46 $this->padre = $dbdata['id_padre'];
47 $this->tabla = $dbdata['tabla'];
48 $this->nombre = $dbdata['nombre'];
49 $this->id = $dbdata['id'];
50 // FIXME - Deprecated!
51 if(isset($dbdata['prepend_link']))
52 $link_append = $dbdata['prepend_link'];
53 if(isset($dbdata['link']))
54 $this->link = $dbdata['link'];
55 if(isset($dbdata['where']))
56 $this->where = $dbdata['where'];
57 if(isset($dbdata['order']))
58 $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order'];
59 $this->db = $dbdata['db'];
60 parent::HTML_Arbol(array(), $titulo, $link_append);
61 $this->datos = $this->BuscarHijos(0);
64 function BuscarHijos($id)
66 $sql = "SELECT $this->nombre, $this->id ";
68 $sql .= ", $this->link ";
69 $sql .= "FROM $this->tabla ";
70 if($this->padre or $this->where)
73 $sql .= "$this->padre = '$id'";
76 } elseif ($this->where)
79 $result = $this->db->query($sql);
80 if(DB::isError($result))
81 die($result->getMessage());
83 while($row = $result->fetchRow())
87 if(!$this->padre) $sub = array();
88 else $sub = $this->BuscarHijos($id);
89 $link = strval(@$row[2]);