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'];
148 $this->expandir = array($this->id_activo);
149 if(isset($this->id_activo))
151 $id = $this->id_activo;
154 $sql = "SELECT $this->padre
156 WHERE $this->id = '".$id."'";
157 $id = $this->db->getOne($sql);
158 $this->expandir[] = $id;
162 parent::MECON_HTML_Arbol(array(), $titulo, $link_append);
163 $this->datos = $this->BuscarHijos(0);
169 * @param TIPO $id DESC
174 function BuscarHijos($id)
176 $sql = "SELECT $this->nombre, $this->id ";
178 $sql .= ", $this->link ";
179 $sql .= "FROM $this->tabla ";
180 if($this->padre or $this->where)
183 $sql .= "$this->padre = '$id'";
186 } elseif ($this->where)
187 $sql .= $this->where;
188 $sql .= $this->order;
189 $result = $this->db->query($sql);
190 if(DB::isError($result))
191 die($result->getMessage());
193 while($row = $result->fetchRow())
197 if(!$this->padre || !in_array($id, $this->expandir)) $sub = array();
198 else $sub = $this->BuscarHijos($id);
199 $link = strval(@$row[2]);
206 if (!is_null($this->id_activo) and $id == $this->id_activo) {