source: trunk/phpgwapi/templates/default/navbar.inc.php @ 7655

Revision 7655, 18.7 KB checked in by douglasz, 11 years ago (diff)

Ticket #3236 - Melhorias de performance no codigo do Expresso.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * phpGroupWare                                                             *
4        * http://www.phpgroupware.org                                              *
5        * --------------------------------------------                             *
6        *  This program is free software; you can redistribute it and/or modify it *
7        *  under the terms of the GNU General Public License as published by the   *
8        *  Free Software Foundation; either version 2 of the License, or (at your  *
9        *  option) any later version.                                              *
10        \**************************************************************************/
11
12
13        function parse_navbar($force = False)
14        {
15                $GLOBALS['celepar_tpl'] = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
16
17                $GLOBALS['celepar_tpl']->set_file(
18                        array(
19                                'navbar' => 'navbar.tpl'
20                        )
21                );
22
23                $GLOBALS['celepar_tpl']->set_block('navbar','navbar_header','navbar_header');
24                $GLOBALS['celepar_tpl']->set_block('navbar','extra_blocks_header','extra_block_header');
25                $GLOBALS['celepar_tpl']->set_block('navbar','extra_block_row','extra_block_row');
26                $GLOBALS['celepar_tpl']->set_block('navbar','extra_block_spacer','extra_block_spacer');
27                $GLOBALS['celepar_tpl']->set_block('navbar','extra_blocks_footer','extra_blocks_footer');
28                $GLOBALS['celepar_tpl']->set_block('navbar','sidebox_hide_header','sidebox_hide_header');
29                $GLOBALS['celepar_tpl']->set_block('navbar','sidebox_hide_footer','sidebox_hide_footer');
30                $GLOBALS['celepar_tpl']->set_block('navbar','appbox','appbox');
31                $GLOBALS['celepar_tpl']->set_block('navbar','navbar_footer','navbar_footer');
32               
33                $GLOBALS['celepar_tpl']->set_var('my_preferences', lang("My Preferences"));
34                $GLOBALS['celepar_tpl']->set_var('title_my_preferences', lang("Click here to change your Expresso password and other preferences"));
35                $GLOBALS['celepar_tpl']->set_var('title_suggestions', lang("Send your critics, doubts or suggestions"));
36                $GLOBALS['celepar_tpl']->set_var('suggestions', lang("Suggestions"));
37                $GLOBALS['celepar_tpl']->set_var('help', lang("Help"));
38                $GLOBALS['celepar_tpl']->set_var('title_help', lang("Click here for help"));
39                $GLOBALS['celepar_tpl']->set_var('template',$GLOBALS['phpgw_info']['server']['template_set']);
40
41                $var['img_root'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images';
42                $var['dir_root'] = $GLOBALS['phpgw_info']['server']['webserver_url'];
43                $var['table_bg_color'] = $GLOBALS['phpgw_info']['theme']['navbar_bg'];
44
45                $show_menu_event = 'onClick';
46       
47
48                $applications = '';
49
50                //      == 'icons_and_text')
51
52                $max_icons=$GLOBALS['phpgw_info']['user']['preferences']['common']['max_icons'];
53                 
54                if(!$max_icons)
55                {
56                        $max_icons=200;
57                }
58               
59                $i = 0;
60                foreach($GLOBALS['phpgw_info']['navbar'] as $app => $app_data)
61                {
62                        $current_app = False;
63                                if($app != 'preferences' && $app != 'about' && $app != 'logout')
64                                {
65                                        $icon = '<a href="'.$app_data['url'].'">';
66                                        $title = $GLOBALS['phpgw_info']['apps'][$app]['title'];
67                                        if($app == 'home') $title = lang('Home');
68                                        if ($GLOBALS['phpgw_info']['flags']['currentapp'] == $app)
69                                        {
70                                                $icon .= '<img id="'.str_replace('_','',$app).'id" src="' . $app_data['icon'] . '" alt="' . $title . '" title="'. $title . '" border="0" width="35" height="35" nowrap="nowrap"/></a>';
71                                                $current_app = True;
72                                        }
73                                        else
74                                                $icon .= '<img id="'.str_replace('_','',$app).'id" src="' . $app_data['icon'] . '" alt="' . $title . '" title="'. $title . '" border="0" width="24" height="24" nowrap="nowrap"/></a>';
75
76                                        if($app=='home')
77                                        {
78                                                if($GLOBALS['phpgw_info']['user']['preferences']['common']['start_and_logout_icons']=='no')
79                                                {
80                                                        continue;
81                                                }
82                                        }
83                               
84                                        // Verifica qual o formato da Barra de navegação:
85                                        // Icone ou Texto, ou Icone e Texto
86                                       
87
88                                        if($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format']=='icons') {
89                                                $title_extra = $title;
90                                                $title = '';
91                                        }
92                                        else if($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format']=='text'){
93                                                $icon = '';
94                                        }
95
96                                        if($i< $max_icons) {
97
98                                                if($GLOBALS['phpgw_info']['user']['preferences']['common']['start_and_logout_icons']=='no')
99                                                {
100                                                        $tdwidth = 100/($max_icons);
101                                                }
102                                                else
103                                                {
104                                                        $tdwidth = 100/($max_icons+2);
105                                                }
106                                               
107                                                $app_icons .= '<td nowrap '.
108                                                'onmouseover="javascript:'.($current_app?'return true;':'').'this.className=\'navbar_butOver\'; zoom_in(this.firstChild.firstChild.id)" '.
109                                                'onmouseout="javascript:'.($current_app?'return true;':'').'this.className=\'navbar_but\'; '.($current_app?'':'zoom_out(this.firstChild.firstChild.id)').'" '.
110                                                'class="'.($current_app?'navbar_butOut':'navbar_but').'">';
111
112                                                if(isset($GLOBALS['phpgw_info']['flags']['navbar_target']) && $GLOBALS['phpgw_info']['flags']['navbar_target'])
113                                                {
114                                                        $app_icons .= ' target="' . $GLOBALS['phpgw_info']['flags']['navbar_target'] . '"';
115                                                }                                               
116                                                $app_icons .=  $icon;
117                                        }
118                                       
119                                                                               
120                                        $icon = '<img align="center" src="' . $app_data['icon'] . '" alt="' . $title . '" width="16" title="'. $title . '" border="0" />';
121                               
122                                        $app_extra_icons .= '<tr>';
123
124                                        if($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format']!='text')
125                                        {
126                                                $app_extra_icons .= '<td class="extraIconsRow"><a href="' . $app_data['url'] . '"';
127
128                                                if(isset($GLOBALS['phpgw_info']['flags']['navbar_target']) && $GLOBALS['phpgw_info']['flags']['navbar_target'])
129                                                {
130                                                        $app_extra_icons .= ' target="' . $GLOBALS['phpgw_info']['flags']['navbar_target'] . '"';
131                                                }
132
133                                                $app_extra_icons .= ' >' . $icon . '</a></td>';
134                                        }
135
136
137                                                $app_extra_icons .= '<td align="left" class="extraIconsRow" style=""><a href="'.$app_data['url'] . '"';
138
139                                                if(isset($GLOBALS['phpgw_info']['flags']['navbar_target']) && $GLOBALS['phpgw_info']['flags']['navbar_target'])
140                                                {
141                                                        $app_extra_icons .= ' target="' . $GLOBALS['phpgw_info']['flags']['navbar_target'] . '"';
142                                                }
143
144                                                $app_extra_icons .= '>' . $title_extra . '</a></td></tr>';
145
146                                        unset($icon);
147                                        unset($title);
148                                        ++$i;
149                                }
150                        }
151                       
152                        if($GLOBALS['phpgw_info']['user']['preferences']['common']['start_and_logout_icons']!='no')     
153                        {
154                       
155                                $hint = $GLOBALS['phpgw_info']['navbar']['logout']['title'];
156                                $icon = '<img id="logout_id" width="24" height="24" src="'.$GLOBALS['phpgw_info']['navbar']['logout']['icon'].'"  alt="'.$hint.'" title="'.$hint.'">';
157                               
158                                if($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format']=='icons') {
159                                       
160                                                $title = '';
161                                }
162                                else if($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format']=='text'){
163                                       
164                                                $icon = '';
165                                }                       
166                                $app_icons .= '<td nowrap '.
167                                'onmouseover="javascript:this.className=\'navbar_butOver\'; zoom_in(this.firstChild.firstChild.id)" '.
168                                'onmouseout="javascript:this.className=\'navbar_but\'; zoom_out(this.firstChild.firstChild.id)" '.
169                                'class="navbar_but"><a onclick="location.href=\''.$GLOBALS['phpgw_info']['navbar']['logout']['url'].'\'">'.$icon.'</td>';
170                        }                       //                      window.location.href=\''.$GLOBALS['phpgw_info']['navbar']['logout']['url'].'\'
171                       
172                        $var['app_icons'] = $app_icons;
173                       
174                        $hint = $GLOBALS['phpgw_info']['navbar']['logout']['title'];
175                        $icon = '<img src="'.$GLOBALS['phpgw_info']['navbar']['logout']['icon'].'"  alt="'.$hint.'" title="'.$hint.'">';
176                        $title = $GLOBALS['phpgw_info']['navbar']['logout']['title'];
177                       
178                        $app_extra_icons .= '<td  class="extraIconsRow">
179                                <a href="'.$GLOBALS['phpgw_info']['navbar']['logout']['url'].'">'.$icon.'</a></td>';
180
181                        $app_extra_icons .= '<td class="extraIconsRow">
182                                <a href="'.$GLOBALS['phpgw_info']['navbar']['logout']['url'].'">'.$title.'</a></td>';
183
184                               
185                                $app_extra_icons_div = '
186                                <script language="javascript">
187                                new ypSlideOutMenu("menu1", "down", 5, 24, 160, 200,\'left\')
188                                </script>
189                                <div id="menu1Container">
190                                <div id="menu1Content" style="position: relative; left: 0; text-align: left;">
191
192                                <div id="extraIcons">
193
194                                <table cellspacing="0" cellpadding="0" border="0" width="100%">
195                                <tr>
196                                <td colspan="2" nowrap="nowrap" align="right" style="background-color:#dddddd;padding:1px;">
197                                <a href="#" '.$show_menu_event.'="ypSlideOutMenu.hide(\'menu1\')" title="'.lang('close').'">
198                                <img style="" border="0" src="'.$var['img_root'].'/close.png"/></a></span></td></tr>                           
199                                '.$app_extra_icons.'</table>
200                                </div>
201
202                                </div>
203                                </div>
204                                ';
205
206                                $var['app_extra_icons_div']= $app_extra_icons_div;                             
207                                $var['app_extra_icons_icon']= '<td width="26" valign="top" align="right" style="zIndex:10000;padding-right:3px;padding-top:10px;"><a title="'.lang('show_more_apps').'" href="#"  onMouseOver="ypSlideOutMenu.showMenu(\'menu1\')" onClick="javascript:ypSlideOutMenu.hide(\'menu1\');showBar()"><img src="'.$var['img_root'].'/extra_icons.png" border="0" /></a></td>';
208
209
210                        if(isset($GLOBALS['phpgw_info']['flags']['app_header']))
211                        {
212                                $var['current_app_title'] = $GLOBALS['phpgw_info']['flags']['app_header'];
213                        }
214                        else
215                        {
216                                $var['current_app_title']=$GLOBALS['phpgw_info']['navbar'][$GLOBALS['phpgw_info']['flags']['currentapp']]['title'];
217                        }
218
219                        if(isset($GLOBALS['phpgw_info']['navbar']['admin']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers'])
220                        {
221                                $var['current_users'] = '<a href="'
222                                . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions') . '">'
223                                . lang('Current users') . ': ' . $GLOBALS['phpgw']->session->total() . '</a>';
224                        }
225                        $now = time();
226                        $var['user_info'] = '<b>'.$GLOBALS['phpgw']->common->display_fullname() .'</b>'. ' - '
227                        . lang($GLOBALS['phpgw']->common->show_date($now,'l')) . ' '
228                        . $GLOBALS['phpgw']->common->show_date($now,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
229                       
230                        if($GLOBALS['phpgw_info']['server']['use_frontend_name'])
231                                $var['frontend_name'] = " - ".$GLOBALS['phpgw_info']['server']['use_frontend_name'];
232
233                        /*
234                         *      Forçar termo de aceite por parte do usuário
235                         */
236
237                        if(($GLOBALS['phpgw_info']['user']['agree_terms'] != 1) && ($GLOBALS['phpgw_info']['server']['use_agree_term']=='True')) //Ele deverá confirmar o termo de aceite.
238                        {
239                                $agreeterm_url = $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/termo_aceite.php';
240                               
241                                if ($GLOBALS['phpgw_info']['server']['use_https'] == 2)
242                                        $agreeterm_url = 'https://' . $agreeterm_url;
243                                else
244                                        $agreeterm_url = 'http://' . $agreeterm_url;
245                               
246                                echo '<script>' .
247                                                'if(location.href.indexOf("termo_aceite.php") == -1){' .
248                                                        'location.href = "' . $agreeterm_url . '"' .
249                                                '}' .
250                                         '</script>';
251                        }
252
253                        if ($GLOBALS['phpgw_info']['server']['max_pwd_age'] && $GLOBALS['phpgw_info']['server']['max_pwd_age'] > 0 )
254                            {
255                                $aux = time() - (86400*$GLOBALS['phpgw_info']['server']['max_pwd_age']);
256                            }
257                        else
258                            {
259                                $aux = $GLOBALS['phpgw_info']['server']['max_pwd_age'];
260                            }
261
262                        if(($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == '0'  && (($GLOBALS['phpgw_info']['user']['agree_terms'] == 1) || ($GLOBALS['phpgw_info']['server']['use_agree_term']!='True'))) ||
263                                $GLOBALS['phpgw_info']['user']['lastpasswd_change'] < $aux)
264                        {
265                                //$changepasswd_url = $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/changepassword.php?cd=1';
266                                $changepasswd_url = nearest_to_me(). $GLOBALS['phpgw_info']['server']['webserver_url'].'/preferences/changepassword.php?cd=1';
267                                if ($GLOBALS['phpgw_info']['server']['use_https'] > 0)
268                                        $changepasswd_url = 'https://' . $changepasswd_url;
269                                else
270                                        $changepasswd_url = 'http://' . $changepasswd_url;
271                               
272                                echo '<script>' .
273                                                'if(location.href.indexOf("changepassword.php") == -1){' .
274                                                        'location.href = "' . $changepasswd_url . '"' .
275                                                '}' .
276                                         '</script>';
277                               
278                                /*
279                                $api_messages = lang('You are required to change your password during your first login')
280                                . '<br> Click this image on the navbar: <img src="'
281                                . $GLOBALS['phpgw']->common->image('preferences','navbar.gif').'">';
282                                */
283                        }
284                        /*
285                        elseif($GLOBALS['phpgw_info']['user']['lastpasswd_change'] < time() - (86400*30))
286                        {
287                                $api_messages = lang('it has been more then %1 days since you changed your password',30);
288                        }
289                        */
290                        /*
291                        // This is gonna change
292                        if(isset($cd))
293                        {
294                                $var['messages'] = $api_messages . '<br>' . checkcode($cd);
295                        }*/
296
297                        $var['logo_file'] = $GLOBALS['phpgw']->common->image('phpgwapi',$GLOBALS['phpgw_info']['server']['login_logo_file']?$GLOBALS['phpgw_info']['server']['login_logo_file']:'logo');
298                        $var['logo_url'] = $GLOBALS['phpgw_info']['server']['login_logo_url']?$GLOBALS['phpgw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
299                        $var['logo_title'] = $GLOBALS['phpgw_info']['server']['login_logo_title']?$GLOBALS['phpgw_info']['server']['login_logo_title']:'www.eGroupWare.org';
300                        $var['hide_bar_txt'] = lang("Hide header and toolbar");
301                        $var['show_bar_txt'] = lang("Show header and toolbar");
302                        $GLOBALS['celepar_tpl']->set_var($var);
303                        $GLOBALS['celepar_tpl']->pfp('out','navbar_header');
304
305                        /******************************************************\
306                        * The sidebox menu's                                   *
307                        \******************************************************/
308
309                        $menu_title = lang('General Menu');
310
311                        $file['Home'] = $GLOBALS['phpgw_info']['navbar']['home']['url'];
312                        if($GLOBALS['phpgw_info']['user']['apps']['preferences'])
313                        {
314                                $file['Preferences'] = $GLOBALS['phpgw_info']['navbar']['preferences']['url'];
315                        }
316                        $file += array(
317                                array(
318                                        'text'    => lang('About %1',$GLOBALS['phpgw_info']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']]['title']),
319                                        'no_lang' => True,
320                                        'link'    => $GLOBALS['phpgw_info']['navbar']['about']['url']
321                                ),
322                                'Logout'=>$GLOBALS['phpgw_info']['navbar']['logout']['url']
323                        );
324
325                        if($GLOBALS['phpgw_info']['user']['preferences']['common']['auto_hide_sidebox']==1)
326                        {
327                                $GLOBALS['celepar_tpl']->set_var('show_menu_event',$show_menu_event);
328                                $GLOBALS['celepar_tpl']->set_var('lang_show_menu',lang('show menu'));
329                                $GLOBALS['celepar_tpl']->pparse('out','sidebox_hide_header');
330
331                                display_sidebox('',$menu_title,$file);
332                                $GLOBALS['phpgw']->hooks->single('sidebox_menu',$GLOBALS['phpgw_info']['flags']['currentapp']);
333
334                                $GLOBALS['celepar_tpl']->pparse('out','sidebox_hide_footer');
335
336                                $var['sideboxcolstart']='';
337
338                                $GLOBALS['celepar_tpl']->set_var($var);
339                                $GLOBALS['celepar_tpl']->pparse('out','appbox');
340                                $var['remove_padding'] = 'style="padding-left:0px;"';
341                                $var['sideboxcolend'] = '';
342                        }
343                        else
344                        {
345                                $var['menu_link'] = '';
346                                $var['sideboxcolstart'] = '<td id="tdSidebox" valign="top">';
347                                $var['remove_padding'] = '';
348                                $GLOBALS['celepar_tpl']->set_var($var);
349                                $GLOBALS['celepar_tpl']->pparse('out','appbox');
350
351                                display_sidebox('',$menu_title,$file);
352                                $GLOBALS['phpgw']->hooks->single('sidebox_menu',$GLOBALS['phpgw_info']['flags']['currentapp']);
353
354                                $var['sideboxcolend'] = '</td>';
355                        }
356
357                        $GLOBALS['celepar_tpl']->set_var($var);
358                        $GLOBALS['celepar_tpl']->pparse('out','navbar_footer');
359
360                        // If the application has a header include, we now include it
361                        if(!@$GLOBALS['phpgw_info']['flags']['noappheader'] && @isset($_GET['menuaction']))
362                        {
363                                list($app,$class,$method) = explode('.',$_GET['menuaction']);
364                                if(is_array($GLOBALS[$class]->public_functions) && $GLOBALS[$class]->public_functions['header'])
365                                {
366                                        $GLOBALS[$class]->header();
367                                }
368                        }
369                        $GLOBALS['phpgw']->hooks->process('after_navbar');
370                        return;
371                }
372
373                function display_sidebox($appname,$menu_title,$file)
374                {
375                        if(!$appname || ($appname==$GLOBALS['phpgw_info']['flags']['currentapp'] && $file))
376                        {
377                                $var['lang_title']=$menu_title;//$appname.' '.lang('Menu');
378                                $GLOBALS['celepar_tpl']->set_var($var);
379                                $GLOBALS['celepar_tpl']->pfp('out','extra_blocks_header');
380
381                                foreach($file as $text => $url)
382                                {
383                                        sidebox_menu_item($url,$text);
384                                }
385
386                                $GLOBALS['celepar_tpl']->pparse('out','extra_blocks_footer');
387                        }
388                }
389
390                function sidebox_menu_item($item_link='',$item_text='')
391                {
392                        if($item_text === '_NewLine_' || $item_link === '_NewLine_')
393                        {
394                                $GLOBALS['celepar_tpl']->pparse('out','extra_block_spacer');
395                        }
396                        else
397                        {
398                                $var['icon_or_star']='<img src="'.$GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images'.'/orange-ball.png" width="9" height="9" alt="ball"/>';
399                                $var['target'] = '';
400                                if(is_array($item_link))
401                                {
402                                        if(isset($item_link['icon']))
403                                        {
404                                                $app = isset($item_link['app']) ? $item_link['app'] : $GLOBALS['phpgw_info']['flags']['currentapp'];
405                                                $var['icon_or_star'] = '<img src="'.$GLOBALS['phpgw']->common->image($app,$item_link['icon']).'"/>';
406                                        }
407                                        $var['lang_item'] = isset($item_link['no_lang']) && $item_link['no_lang'] ? $item_link['text'] : lang($item_link['text']);
408                                        $var['item_link'] = $item_link['link'];
409                                        if ($item_link['target'])
410                                        {
411                                                $var['target'] = ' target="' . $item_link['target'] . '"';
412                                        }
413                                }
414                                else
415                                {
416                                        $var['lang_item'] = lang($item_text);
417                                        $var['item_link'] = $item_link;
418                                }
419                                $GLOBALS['celepar_tpl']->set_var($var);
420                                $GLOBALS['celepar_tpl']->pparse('out','extra_block_row');
421                        }
422                }
423
424                function parse_navbar_end()
425                {
426                        $GLOBALS['celepar_tpl'] = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
427
428                        $GLOBALS['celepar_tpl']->set_file(
429                                array(
430                                        'footer' => 'footer.tpl'
431                                )
432                        );
433                       
434                        $var = Array(
435                                'img_root'       => $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images',
436                                'table_bg_color' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
437                                'version'        => $GLOBALS['phpgw_info']['server']['versions']['phpgwapi']
438                        );
439                        $GLOBALS['phpgw']->hooks->process('navbar_end');
440                       
441
442                        if($GLOBALS['phpgw_info']['user']['preferences']['common']['show_generation_time'])
443                        {
444                                $mtime = microtime();
445                                $mtime = explode(' ',$mtime);
446                                $mtime = $mtime[1] + $mtime[0];
447                                $tend = $mtime;
448                                $totaltime = ($tend - $GLOBALS['page_start_time']);
449
450                                $var['page_generation_time'] = '<div id="divGenTime"><br/><span>'.lang('Page was generated in %1 seconds',$totaltime).'</span></div>';
451                        }
452
453                        $var['powered_by'] = lang('Powered by phpGroupWare version %1',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
454                        $GLOBALS['celepar_tpl']->set_var($var);
455                        $GLOBALS['celepar_tpl']->pfp('out','footer');
456                }
Note: See TracBrowser for help on using the repository browser.