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 my $framesize = _calc_framesize() - 2;
80 my $menu = Menu->new("menu.ini");
81 $::form->{title} = $::locale->text('kivitendo');
84 my $sections = [ section_menu($menu) ];
86 print $::form->parse_html_template('menu/menu', {
87 framesize => $framesize,
88 sections => $sections,
91 $::lxdebug->leave_sub;
95 $::lxdebug->enter_sub;
96 my ($menu, $level, $id_prefix) = @_;
97 my @menuorder = $menu->access_control(\%::myconfig, $level);
102 for my $item (@menuorder) {
103 my $menuitem = $menu->{$item};
104 my $label = apply { s/.*--// } $item;
105 my $ml = apply { s/--.*// } $item;
106 my $spacer = "s" . (0 + $item =~ s/--/--/g);
107 my $label_icon = $level . "--" . $label . ".png";
109 next if $level && $item ne "$level--$label";
111 $label = $::locale->text($label);
113 $menuitem->{module} ||= $::form->{script};
114 $menuitem->{action} ||= "section_menu";
115 $menuitem->{target} ||= "main_window";
116 $menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}";
119 foreach my $key (keys %$menuitem) {
120 next if $key =~ /target|module|action|href/;
121 $menuitem->{href} .= "&" . $::form->escape($key, 1) . "=";
122 my ($value, $conf) = split(/=/, $menuitem->{$key}, 2);
123 $value = $::myconfig{$value} . "/$conf" if ($conf);
124 $menuitem->{href} .= $::form->escape($value, 1);
127 my $anchor = $menuitem->{href};
132 target => $menuitem->{target},
133 item_id => "$id_prefix\_$id",
137 if (!$level) { # toplevel
138 push @items, { %common_args,
139 img => make_image(icon => $item . '.png', size => 24, label => $label),
143 push @items, section_menu($menu, $item, "$id_prefix\_$id");
144 } elsif ($menuitem->{submenu}) {
145 push @items, { %common_args,
146 img => make_image(submenu => 1),
149 push @items, section_menu($menu, $item, "$id_prefix\_$id");
150 } elsif ($menuitem->{module}) {
151 push @items, { %common_args,
152 img => make_image(label => $label, icon => $label_icon),
161 $::lxdebug->leave_sub;
168 my $icon = $params{icon};
169 my $size = $params{size} || 16;
171 return unless _show_images();
173 my $icon_found = $icon && -f _icon_path($icon, $size);
176 src => $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png",
177 alt => $params{label},
178 width => $icon_found ? $size : 24,
179 height => $icon_found ? $size : 15,
183 sub _calc_framesize {
184 my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i;
185 my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
186 my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i;
188 return $is_mobile_browser && $is_mobile_style ? 130
189 : $is_lynx_browser ? 240
194 # don't show images in links
195 _calc_framesize() != 240;
199 my ($label, $size) = @_;
203 return "image/icons/${size}x${size}/$label";