1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 ######################################################################
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
15 # Contributors: Christopher Browne
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #######################################################################
31 # the frame layout with refractured menu
34 # DS. 2002-03-25 Created
35 # 2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de>
36 # 2010-08-19 - Icons for sub entries and single click behavior, unlike XUL-Menu
37 # JS switchable HTML-menu - Sven Donath <lxo@dexo.de>
38 #######################################################################
45 use List::MoreUtils qw(apply);
50 $::lxdebug->enter_sub;
52 my $callback = $::form->unescape($::form->{callback});
53 $callback = URI->new($callback)->rel($callback) if $callback;
54 $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/;
55 my $framesize = _calc_framesize();
57 $::form->header(doctype => 'frameset');
60 <frameset rows="28px,*" cols="*" framespacing="0" frameborder="0">
61 <frame src="controller.pl?action=FrameHeader/header" scrolling="NO">
62 <frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" id="menuframe" name="menuframe">
63 <frame src="$::form->{script}?action=acc_menu" name="acc_menu" scrolling="auto" noresize marginwidth="0">
64 <frame src="$callback" name="main_window" scrolling="auto">
67 You need a browser that can read frames to see this page.
73 $::lxdebug->leave_sub;
77 $::lxdebug->enter_sub;
79 $::form->{stylesheet} = [ qw(css/icons16.css css/icons24.css ) ];
81 my $framesize = _calc_framesize() - 2;
82 my $menu = Menu->new("menu.ini");
83 $::form->{title} = $::locale->text('kivitendo');
86 my $sections = [ section_menu($menu) ];
88 print $::form->parse_html_template('menu/menu', {
89 framesize => $framesize,
90 sections => $sections,
93 $::lxdebug->leave_sub;
97 $::lxdebug->enter_sub;
98 my ($menu, $level, $id_prefix) = @_;
99 my @menuorder = $menu->access_control(\%::myconfig, $level);
104 for my $item (@menuorder) {
105 my $menuitem = $menu->{$item};
106 my $olabel = apply { s/.*--// } $item;
107 my $ml = apply { s/--.*// } $item;
108 my $icon_class = apply { y/ /-/ } $item;
109 my $spacer = "s" . (0 + $item =~ s/--/--/g);
111 next if $level && $item ne "$level--$olabel";
113 my $label = $::locale->text($olabel);
115 $menuitem->{module} ||= $::form->{script};
116 $menuitem->{action} ||= "section_menu";
117 $menuitem->{target} ||= "main_window";
118 $menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}";
121 foreach my $key (keys %$menuitem) {
122 next if $key =~ /target|module|action|href/;
123 $menuitem->{href} .= "&" . $::form->escape($key, 1) . "=";
124 my ($value, $conf) = split(/=/, $menuitem->{$key}, 2);
125 $value = $::myconfig{$value} . "/$conf" if ($conf);
126 $menuitem->{href} .= $::form->escape($value, 1);
129 my $anchor = $menuitem->{href};
134 t => $menuitem->{target},
135 id => "$id_prefix\_$id",
139 if (!$level) { # toplevel
140 push @items, { %common_args,
141 i => "icon24 $icon_class", # make_image(size => 24, label => $item),
144 push @items, section_menu($menu, $item, "$id_prefix\_$id");
145 } elsif ($menuitem->{submenu}) {
146 push @items, { %common_args,
147 i => "icon16 submenu", #make_image(label => 'submenu'),
150 push @items, section_menu($menu, $item, "$id_prefix\_$id");
151 } elsif ($menuitem->{module}) {
152 push @items, { %common_args,
153 i => "icon16 $icon_class", #make_image(size => 16, label => $item),
162 $::lxdebug->leave_sub;
166 sub _calc_framesize {
167 my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i;
168 my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
169 my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i;
171 return $is_mobile_browser && $is_mobile_style ? 130
172 : $is_lynx_browser ? 240
177 # don't show images in links
178 _calc_framesize() != 240;