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 -------------------------------------------------------------------------------
25 -----------------------------------------------------------------------------*/
27 require_once 'MECON/HTML/Arbol.php';
28 require_once 'DB.php';
30 class HTML_ArbolDB extends HTML_Arbol
37 var $prepend_link = null;
42 function HTML_ArbolDB($dbdata, $imagen)
44 if(isset($dbdata['id_padre']))
45 $this->padre = $dbdata['id_padre'];
46 $this->tabla = $dbdata['tabla'];
47 $this->nombre = $dbdata['nombre'];
48 $this->id = $dbdata['id'];
49 if(isset($dbdata['prepend_link']))
50 $this->prepend_link = $dbdata['prepend_link'];
51 if(isset($dbdata['link']))
52 $this->link = $dbdata['link'];
53 if(isset($dbdata['where']))
54 $this->where = $dbdata['where'];
55 if(isset($dbdata['order']))
56 $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order'];
57 $this->db = $dbdata['db'];
58 $dat = $this->BuscarHijos(0);
59 parent::HTML_Arbol($dat, $imagen);
62 function BuscarHijos($id)
64 $sql = "SELECT $this->nombre, $this->id ";
65 if(!is_null($this->link))
66 $sql .= ", $this->link ";
67 $sql .= "FROM $this->tabla ";
68 if(!is_null($this->padre) or $this->where)
70 if(!is_null($this->padre)) {
71 $sql .= "$this->padre = '$id'";
74 } elseif ($this->where)
77 $result = $this->db->query($sql);
78 if(DB::isError($result))
79 die($result->getMessage());
81 while($row = $result->fetchRow())
85 if(is_null($this->padre)) $sub = array();
86 else $sub = $this->BuscarHijos($id);
87 if(!is_null($this->link)) $link = $this->prepend_link.$row[2];
88 else $link = $this->prepend_link.$id;