MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mdhtmlmenu.class
Ir para a documentação deste ficheiro.
1<?php
3{
4 private $js_array_options;
5 static $order = 0;
6 private $nOrder;
7 private $template;
8 private $action;
9 private $target;
10 private $items;
11 private $jsItems;
12
13 function __construct($name='', $template=0, $action='', $target='_blank')
14 {
15 parent::__construct($name);
17 $this->AddStyleFile('m_dhtmlmenu.css');
18 $page->AddScript('tigra/menu.js');
19 $this->items = NULL;
20 $this->template = $template;
21 $this->action = $action;
22 $this->target = $target;
23 $this->js_array_options = array();
24 $this->nOrder = MDHTMLMenu::$order++;
25 }
26
27 private function GetJsItems($items)
28 {
29 if ($items != NULL)
30 {
31 foreach($items as $it)
32 {
33 $i .= "['{$it[1]}'";
34 $i .= ($it[0] !== NULL) ? (($it[0] != '0') ? ",'{$it[0]}'" : ',null') : ',null';
35 if ($this->action != '')
36 {
37 $it[2] = str_replace('#',$it[0], $this->action);
38 }
39 $i .= ($it[2] != NULL ? ",{$it[2]}" : ',null') . ',';
40 $i .= $this->GetJsItems($this->items[$it[0]]);
41 $i .= "],";
42 }
43 return $i;
44 }
45 }
46
47 function SetTitle($title) {
48 if (sizeof($this->js_array_options)) {
49 $this->js_array_options[0][1] = $title;
50 }
51 else {
52 $this->js_array_options[] = array('0',$title,'','root');
53 }
54 }
55
56 function AddOption($label,$module='main',$action='',$item=null,$args=null)
57 {
58 $control = new HyperLink(NULL,$label);
59 $control->SetAction($module,$action,$item,$args);
60 $this->js_array_options[] = array($control->href,$label,sizeof($this->js_array_options)-1,0);
61 }
62
63 function AddUserOption($transaction, $access,$label,$module='main',$action='',$item='',$args=null)
64 {
65
66 if ( $this->manager->perms->CheckAccess($transaction, $access))
67 {
68 $this->AddOption($label,$module,$action,$item,$args);
69 }
70 }
71
72 function AddLink($label, $link = '#', $target = '_self')
73 {
74// $this->js_array_options[] = array($link,$label,sizeof($this->js_array_options)-1,0);
75 $this->js_array_options[] = array($link,$label,"{'tw':'$target'}",0);
76 }
77
78 function AddSeparator()
79 {
80 }
81
82 function HasOptions()
83 {
84 return (count($this->js_array_options) > 0);
85 }
86
87 function SetItemsFromArray($array, $key='3', $data='0,1,2')
88 {
89 $o = new TreeArray($array,$key,$data);
90 $this->items = $o->tree;
91 $this->jsItems = $this->GetJsItems($this->items['root']) ;
92 }
93
94 function GetParameters() {
95 global $module, $theme;
96
97 if (file_exists($this->manager->GetConf('home.themes').'/'.$theme->name.'/m_dhtmlmenu.css'))
98 $arquivo_css = $this->manager->GetConf('home.themes').'/'.$theme->name.'/m_dhtmlmenu.css';
99 if (file_exists($this->manager->GetConf('home.modules').'/'.$module. $this->manager->GetConf('home.module.themes').'/'.$theme->name.'/theme.css'))
100 $arquivo_css = $this->manager->GetConf('home.modules').'/'.$module.$this->manager->GetConf('home.module.themes').'/'. $theme->name.'/m_dhtmlmenu.css';
101
102 $fp = fopen ($arquivo_css, "r") or die("Arquivo não encontrado");
103 $conteudo = fread($fp, filesize ($arquivo_css));
104 fclose($fp);
105
106 preg_match_all("/&&&(.*?)&&&/s", $conteudo, $trecho, PREG_SET_ORDER);
107 $trecho = trim($trecho[0][1]);
108
109 $parametros = array();
110 $niveis = explode("\n",$trecho);
111
112 foreach($niveis as $nivel => $valor) {
113 $partes = explode(";",$valor);
114 for ($i = 1; $i < sizeof($partes); $i++) {
115 $pares = explode(":",$partes[$i]);
116 $parametros[$partes[0]][$pares[0]] = $pares[1];
117 }
118 }
119
120 return $parametros;
121 }
122
123 function CalculatePosition() {
124 global $MIOLO;
125
126 $parametros = $this->GetParameters();
127
128 $session = $MIOLO->session;
129 $x = $session->GetValue("num_mainmenu");
130
131 $posicao = "var MENU_POS = [
132 {
133 // item sizes
134 'height': ". $parametros[0]['height'] .",
135 'width': ". $parametros[0]['width'] .",
136 // menu block offset from the origin:
137 // for root level origin is upper left corner of the page
138 // for other levels origin is upper left corner of parent item
139 'block_top': 0,
140 'block_left': ". ($x * ($parametros[0]['width'] + 4)) .",
141 // offsets between items of the same level
142 'top': ". $parametros[0]['top'] .",
143 'left': ". $parametros[0]['left'] .",
144 // time in milliseconds before menu is hidden after cursor has gone out
145 // of any items
146 'hide_delay': ". $parametros[0]['hide_delay'] .",
147 'expd_delay': ". $parametros[0]['expd_delay'] .",
148 'css' : {
149 'outer': ['m0l0oout', 'm0l0oover', 'm0l0odown'],
150 'inner': ['m0l0iout', 'm0l0iover', 'm0l0idown']
151 }
152 },
153 {
154 'height': ". $parametros[1]['height'] .",
155 'width': ". $parametros[1]['width'] .",
156 'block_top': ". $parametros[1]['block_top'] .",
157 'block_left': ". $parametros[1]['block_left'] .",
158 'top': ". $parametros[1]['top'] .",
159 'left': ". $parametros[1]['left'] .",
160 'css': {
161 'outer' : ['m0l1oout', 'm0l1oover'],
162 'inner' : ['m0l1iout', 'm0l1iover']
163 }
164 },
165 {
166 'block_top': ". $parametros[2]['block_top'] .",
167 'block_left': ". $parametros[2]['block_left'] .",
168 'css': {
169 'outer': ['m0l2oout', 'm0l2oover'],
170 'inner': ['m0l1iout', 'm0l2iover']
171 }
172 }
173 ];\n";
174
175 $x++;
176 $session->SetValue("num_mainmenu",$x);
177
178 return $posicao;
179 }
180
181 function GenerateInner()
182 {
183 $this->SetItemsFromArray($this->js_array_options);
184 $tree = $this->nOrder;
186 $form = ($this->form == NULL) ? $page->name : $this->form->name;
187 $html = "<script type=\"text/javascript\" language=\"JavaScript\">\n";
188 $html .= "<!--\n";
189 $html .= "var MENU_ITEMS_{$tree} = [ " . $this->jsItems . "];\n";
190 $html .= $this->CalculatePosition();
191 $html .= "new menu (MENU_ITEMS_{$tree}, MENU_POS);\n";
192 $html .= "//-->\n";
193 $html .= "</script>\n";
194 $this->inner = $html;
195 }
196}
197?>
__construct($name='', $template=0, $action='', $target='_blank')
static $order
Definição mdhtmlmenu.class:5
AddLink($label, $link='#', $target='_self')
AddOption($label, $module='main', $action='', $item=null, $args=null)
SetTitle($title)
AddUserOption($transaction, $access, $label, $module='main', $action='', $item='', $args=null)
SetItemsFromArray($array, $key='3', $data='0, 1, 2')
$title
Definição base.php:3