]> git.llucax.com Git - mecon/meconlib.git/blob - lib/MECON/HTML/Arbol.php
73af521289b39c6d4dd914aefede066c215da81f
[mecon/meconlib.git] / lib / MECON / HTML / Arbol.php
1 <?\r
2 \r
3 require_once 'HTML/Table.php';\r
4 require_once 'HTML/Image.php';\r
5 \r
6 class HTML_Arbol extends HTML_Table\r
7 {\r
8     var $t_interna;\r
9     \r
10     function HTML_Arbol($dat, $imagen)\r
11     {\r
12         parent::HTML_Table(array ('width'=>'132',\r
13                                   'border'   => '0',\r
14                                   'cellspacing'   => '0',\r
15                                   'cellpadding'   => '0',\r
16                                   'bgcolor'   => '#003868'));\r
17         $this->t_interna = new HTML_Table(array ('width'=>'132',\r
18                                   'border'   => '0',\r
19                                   'cellspacing'   => '2',\r
20                                   'cellpadding'   => '0',\r
21                                   'class'   => 'bodytext'));\r
22 /*        $this->addRow(array(new HTML_Image($imagen,'',array('width'=>'132',\r
23                                                             'height'=>'26',\r
24                                                             'border'=>'0'))));*/\r
25         $this->addRow(array('aa'), array('background'=>'MECON/images/arbol_titulo.gif'));\r
26         $this->expandir($dat, 0);\r
27     }\r
28     \r
29     function expandir($dat, $n)\r
30     {\r
31         $imagen = '';\r
32         $bullets = array('',\r
33                          '/MECON/images/arbol_bullet_1.gif',\r
34                          '/MECON/images/arbol_bullet_2.gif',\r
35                          '/MECON/images/arbol_bullet_3.gif');\r
36         $tabulados = array(0, 7, 13, 20);\r
37         $classes = array('menu', 'menu1', 'menu1', 'menu2');\r
38         \r
39         $atr = array('border' => '0',\r
40                      'width'  => $tabulados[$n],\r
41                      'height' => '10');\r
42         $imagen =& new HTML_Image($bullets[$n], 'bullet', $atr);\r
43         foreach($dat as $e)\r
44         {\r
45             $e['titulo'] = $imagen->toHTML().$e['titulo'];\r
46             if(isset($e['activado']) && $e['activado'] != 0) $class = 'menu_activo';\r
47             else $class = $classes[$n];\r
48             if(!is_null($e['link']))\r
49               $e['titulo'] = '<a href="'.$e['link'].'" class="'.$class.'">'.$e['titulo'].'</a>';\r
50             $this->t_interna->addRow(array($e['titulo']), array('class' => $class));\r
51             if(isset($e['sub']))\r
52               $this->expandir($e['sub'], $n+1);\r
53         }\r
54     }\r
55 \r
56     function toHTML()\r
57     {\r
58         echo '<link rel="stylesheet" href="/MECON/css/arbol.css">';\r
59         $this->addRow(array($this->t_interna->toHTML()));\r
60         return parent::toHTML();\r
61     }\r
62 };\r
63 \r
64 ?>\r