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 = '', $expandir = false)
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'];
150 $this->expandir = array($this->id_activo);
151 if(isset($this->id_activo))
153 $id = $this->id_activo;
156 $sql = "SELECT $this->padre
158 WHERE $this->id = '".$id."'";
159 $id = $this->db->getOne($sql);
160 $this->expandir[] = $id;
165 parent::MECON_HTML_Arbol(array(), $titulo, $link_append);
166 $this->datos = $this->BuscarHijos(0);
172 * @param TIPO $id DESC
177 function BuscarHijos($id)
179 $sql = "SELECT $this->nombre, $this->id ";
181 $sql .= ", $this->link ";
182 $sql .= "FROM $this->tabla ";
183 if($this->padre or $this->where)
186 $sql .= "$this->padre = '$id'";
189 } elseif ($this->where)
190 $sql .= $this->where;
191 $sql .= $this->order;
192 $result = $this->db->query($sql);
193 if(DB::isError($result))
194 die($result->getMessage());
196 while($row = $result->fetchRow())
200 if(!$this->padre || !(!isset($this->expandir) ||
201 in_array($id, $this->expandir)))
203 else $sub = $this->BuscarHijos($id);
204 $link = strval(@$row[2]);
211 if(isset($this->expandir) && in_array($id, $this->expandir) && $id != $this->id_activo)
213 if (!is_null($this->id_activo) and $id == $this->id_activo) {