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';
36 class MECON_HTML_ArbolDB extends MECON_HTML_Arbol
74 * @var TIPO $id_activo
90 * @var string $link_append
93 var $link_append = '';
122 * @param TIPO $dbdata DESC
123 * @param TIPO $titulo DESC
124 * @param string $link_append DESC
129 function MECON_HTML_ArbolDB($dbdata, $titulo, $link_append = '')
131 if(isset($dbdata['id_padre']))
132 $this->padre = $dbdata['id_padre'];
133 $this->tabla = $dbdata['tabla'];
134 $this->nombre = $dbdata['nombre'];
135 $this->id = $dbdata['id'];
136 $this->id_activo = @$dbdata['id_activo'];
137 // FIXME - Deprecated!
138 if(isset($dbdata['prepend_link']))
139 $link_append = $dbdata['prepend_link'];
140 if(isset($dbdata['link']))
141 $this->link = $dbdata['link'];
142 if(isset($dbdata['where']))
143 $this->where = $dbdata['where'];
144 if(isset($dbdata['order']))
145 $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order'];
146 $this->db = $dbdata['db'];
147 parent::MECON_HTML_Arbol(array(), $titulo, $link_append);
148 $this->datos = $this->BuscarHijos(0);
154 * @param TIPO $id DESC
159 function BuscarHijos($id)
161 $sql = "SELECT $this->nombre, $this->id ";
163 $sql .= ", $this->link ";
164 $sql .= "FROM $this->tabla ";
165 if($this->padre or $this->where)
168 $sql .= "$this->padre = '$id'";
171 } elseif ($this->where)
172 $sql .= $this->where;
173 $sql .= $this->order;
174 $result = $this->db->query($sql);
175 if(DB::isError($result))
176 die($result->getMessage());
178 while($row = $result->fetchRow())
182 if(!$this->padre) $sub = array();
183 else $sub = $this->BuscarHijos($id);
184 $link = strval(@$row[2]);
191 if (!is_null($this->id_activo) and $id == $this->id_activo) {