]> git.llucax.com Git - mecon/meconlib.git/blob - lib/MECON/HTML/Arbol.php
c64b585d3dcd90465e503e34613b305aaacafc3c
[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, $titulo_str)\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         $titulo = new HTML_Table(array('width'=>'132',\r
23                                        'height'=>'26',\r
24                                        'border' => '0',\r
25                                        'cellspacing' => '0',\r
26                                          'cellpadding' => '0',\r
27                                          'align'=>'center',\r
28                  'background'=>'/MECON/images/arbol_titulo.gif'));\r
29         $titulo->addRow(array($titulo_str), array('align'=>'center',\r
30                                                   'class'=>'arboltitulo'));\r
31         $this->addRow(array($titulo), array('bgcolor' => '#FFFFFF'));\r
32         $this->expandir($dat, 0);\r
33     }\r
34     \r
35     function expandir($dat, $n)\r
36     {\r
37         $imagen = '';\r
38         $bullets = array('',\r
39                          '/MECON/images/arbol_bullet_1.gif',\r
40                          '/MECON/images/arbol_bullet_2.gif',\r
41                          '/MECON/images/arbol_bullet_3.gif');\r
42         $tabulados = array(0, 7, 13, 20);\r
43         $classes = array('menu', 'menu1', 'menu1', 'menu2');\r
44         \r
45         $atr = array('border' => '0',\r
46                      'width'  => $tabulados[$n],\r
47                      'height' => '10');\r
48         $imagen =& new HTML_Image($bullets[$n], 'bullet', $atr);\r
49         foreach($dat as $e)\r
50         {\r
51             $e['titulo'] = $imagen->toHTML().$e['titulo'];\r
52             if(isset($e['activado']) && $e['activado'] != 0) $class = 'menu_activo';\r
53             else $class = $classes[$n];\r
54             if(!is_null($e['link']))\r
55               $e['titulo'] = '<a href="'.$e['link'].'" class="'.$class.'">'.$e['titulo'].'</a>';\r
56             $this->t_interna->addRow(array($e['titulo']), array('class' => $class));\r
57             if(isset($e['sub']))\r
58               $this->expandir($e['sub'], $n+1);\r
59         }\r
60     }\r
61 \r
62     function toHTML()\r
63     {\r
64         echo '<link rel="stylesheet" href="/MECON/css/arbol.css">';\r
65         $this->addRow(array($this->t_interna->toHTML()));\r
66         return parent::toHTML();\r
67     }\r
68 };\r
69 \r
70 ?>\r