MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mdhtmlmenu2.class
Ir para a documentação deste ficheiro.
1<?php
2
4{
5 private static $order = 0;
6 private $menuOptions;
7 private $nOrder;
8 private $template;
9 private $action;
10 private $target;
11 private $items;
12 private $jsItems;
13
14 private $themeStyle;
15
16 private $jsMenu;
17
18 function __construct($name='', $template=0, $action='', $target='_blank')
19 {
20 parent::__construct($name);
22
23 $this->themeStyle = $this->manager->getConf('options.mainmenu.style');
24
25 $this->addStyleFile('m_dhtmlmenu2_'.$this->themeStyle.'.css');
26 $page->addScript('jscookmenu/jscookmenu.js');
27 $page->addScript('jscookmenu/jscookmenu_'.$this->themeStyle.'.js');
28
29 $this->items = NULL;
30 $this->template = $template;
31 $this->action = $action;
32 $this->target = $target;
33 $this->menuOptions = array();
34 $this->nOrder = MDHTMLMenu2::$order++;
35 }
36
37 function getTitle()
38 {
39 return $this->caption;
40 }
41
42 function setTitle($title, $image1=null, $image2=null, $module=null, $action=null, $item=null, $args=null)
43 {
44 if ( sizeof($this->menuOptions) )
45 {
46 $this->menuOptions[0][1] = $title;
47 }
48 else
49 {
50 if ( $module && $action )
51 {
52 $control = new HyperLink(NULL,$label);
53 $control->setAction($module,$action,$item,$args);
54 $link = $control->href;
55 }
56
57 $this->menuOptions[] = array('0',$title,'','root', $image1, $image2, $link);
58 }
59 }
60
61 function addOption($label,
62 $module = 'common',
63 $action = 'main',
64 $item = null,
65 $args = null,
66 $normalImage = '',
67 $overImage = '')
68 {
69 $control = new HyperLink(NULL,$label);
70 $control->setAction($module,$action,$item,$args);
71 $this->menuOptions[] = array($control->href, $label, $normalImage,$overImage);
72 }
73
74 public function addUserOption( $transaction,
75 $access,
76 $label,
77 $module = 'common',
78 $action = 'main',
79 $item = '',
80 $args = null,
81 $normalImage = '',
82 $overImage = '' )
83 {
84 if ( $this->manager->perms->checkAccess( $transaction, $access ) )
85 {
86 $this->addOption($label, $module, $action, $item, $args, $normalImage, $overImage);
87 }
88 }
89
90 function addGroupOption($transaction,
91 $access,
92 $label,
93 $module = 'common',
94 $action = 'main',
95 $item = '',
96 $args = null,
97 $normalImage = '',
98 $overImage = '')
99 {
100 if ( $this->manager->perms->CheckAccess($transaction, $access, false, true) )
101 {
102 $this->AddOption($label,$module,$action,$item,$args,$normalImage, $overImage);
103 }
104 }
105
106 function addLink($label, $link = '#', $target = '_self', $normalImage=null,$overImage=null)
107 {
108 $this->menuOptions[] = array($link, $label, "link", $target, $normalImage, $overImage);
109 }
110
111 function getMenu($label)
112 {
113 $subMenu = new MDHTMLMenu2($label);
114 $this->menuOptions[] = $subMenu;
115
116 return $subMenu;
117 }
118
119 function addSeparator()
120 {
121 $this->menuOptions[] = array('-', '', '', 'separator');
122 }
123
124 function hasOptions()
125 {
126 return ( count($this->menuOptions) > 0 );
127 }
128
129 private function getOptionImage($menu, $start)
130 {
131 global $theme;
132 $img = '';
133 $start = (int) $start;
134
135 if ( $menu[$start] )
136 {
137 if ( $menu[$start+1] )
138 {
139 $seq1 = 'class="seq1"';
140 }
141
142 $img = '<img '. $seq1 .' src="'. $this->manager->getUI()->getImageTheme($theme->name, $menu[$start]) .'" />';
143 }
144
145 if ( $menu[$start+1] )
146 {
147 $img .= '<img class="seq2" src="'. $this->manager->getUI()->getImageTheme($theme->name, $menu[$start+1]) .'" />';
148 }
149
150 if ( $img == '' )
151 {
152 $img = null;
153 }
154 else
155 {
156 $img = "'". $img ."'";
157 }
158
159 return $img;
160 }
161
162 private function createMenu()
163 {
164 global $module, $theme;
166 $start = true;
167
168 //$themeDir = $this->manager->GetConf('home.themes'). PATH_SEPARATOR .$theme->name. PATH_SEPARATOR . 'images';
169
170 foreach ( $this->menuOptions as $menu )
171 {
172 if ( ! $startSub )
173 {
174 $compl = ',';
175 }
176 else
177 {
178 $compl = '';
179 }
180
181 if ( is_object($menu) ) // sub-menu
182 {
183
184 $this->jsMenu .= $compl . $menu->createMenu();
185
186 $startSub = false;
187 }
188 else if ( $menu[0] == '0' && $menu[3] ) //main option
189 {
190 if ( ! $start ) // close the existing option
191 {
192 echo "],";
193 }
194
195 $img = $this->getOptionImage($menu, 4);
196
197 // ['icon', 'title', 'url', 'target', 'description'],
198 $this->jsMenu .= "[".$img.", '".$menu[1]."', '".$menu[6]."', null, null,\n";
199 $start = false;
200 $startSub = true;
201 }
202 else if ( $menu[3] == 'separator' )
203 {
204 $this->jsMenu .= ', _cmSplit';
205
206 }
207 else if ( $menu[2] == 'link' )
208 {
209 //array($link, $label, "link", $target, $normalImage, $overImage);
210 $img = $this->getOptionImage($menu, 4);
211
212 $linkURL = "<a href=\"$menu[0]\" target=\"$menu[3]\">$menu[1]</a><br/>\n";
213
214 // ['icon', 'title', 'url', 'target', 'description'],
215 $this->jsMenu .= $compl . " [".$img.", '$menu[1]', '$menu[0]', '$menu[3]', null]\n";
216
217 $startSub = false;
218 }
219 else
220 {
221 $img = $this->getOptionImage($menu, 2);
222
223 $this->jsMenu .= $compl . " [".$img.", '$menu[1]', '$menu[0]', null, null]\n";
224
225 $startSub = false;
226 }
227
228 //MIOLO::var_dump($this->jsMenu);
229 }
230
231 $this->jsMenu .= ']';
232 return $this->jsMenu;
233 }
234
235 public function generateInner()
236 {
237 $this->createMenu();
238
239 $form = ($this->form == NULL) ? $page->name : $this->form->name;
240
241 $themeName = 'Theme'.ucfirst($this->themeStyle);
242
243 $html = "<td id=\"m-container-menu{$this->nOrder}\">";
244 $html .= "<script type=\"text/javascript\" language=\"JavaScript\">\n";
245 $html .= "<!--\n";
246 $html .= "var MAIN_MENU_JS_{$this->nOrder} = [ " . $this->jsMenu . "];\n";
247
248 if ( MUtil::getBooleanValue( $this->manager->getConf('options.mainmenu.clickopen') ) == true )
249 {
250 $html .= "cm$themeName.clickOpen=2 \n";
251 }
252 $html .= "cmDraw( 'm-container-menu{$this->nOrder}', MAIN_MENU_JS_{$this->nOrder}, 'hbr', cm$themeName, '$themeName');\n";
253 $html .= "//-->\n";
254 $html .= "</script>\n";
255 $html .= "</td>";
256 $this->inner = $html;
257
258 //MIOLO::var_dump($this);
259 }
260
261}
262
263?>
addStyleFile( $styleFile)
Definição mcontrol.class:412
__construct($name='', $template=0, $action='', $target='_blank')
addLink($label, $link='#', $target='_self', $normalImage=null, $overImage=null)
getMenu($label)
addUserOption( $transaction, $access, $label, $module='common', $action='main', $item='', $args=null, $normalImage='', $overImage='')
addGroupOption($transaction, $access, $label, $module='common', $action='main', $item='', $args=null, $normalImage='', $overImage='')
setTitle($title, $image1=null, $image2=null, $module=null, $action=null, $item=null, $args=null)
addOption($label, $module='common', $action='main', $item=null, $args=null, $normalImage='', $overImage='')
static getBooleanValue($value)
Definição mutil.class:100
$title
Definição base.php:3