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);
52 $::lxdebug->enter_sub;
54 my $callback = $::form->unescape($::form->{callback});
55 $callback = URI->new($callback)->rel($callback) if $callback;
56 $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/;
57 my $framesize = _calc_framesize();
59 $::form->header(doctype => 'frameset');
62 <frameset rows="28px,*" cols="*" framespacing="0" frameborder="0">
63 <frame src="controller.pl?action=FrameHeader/header" scrolling="NO">
64 <frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" id="menuframe" name="menuframe">
65 <frame src="$::form->{script}?action=acc_menu" name="acc_menu" scrolling="auto" noresize marginwidth="0">
66 <frame src="$callback" name="main_window" scrolling="auto">
69 You need a browser that can read frames to see this page.
75 $::lxdebug->leave_sub;
79 $::lxdebug->enter_sub;
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) = @_;
99 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 = "spacer" . (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};
129 if (!$level) { # toplevel
130 push @items, make_item(
131 img => make_image(icon => $item . '.png', size => 24, label => $label),
136 subitems => section_menu($menu, $item)
138 } elsif ($menuitem->{submenu}) {
139 push @items, make_item(
140 target => $menuitem->{target},
142 img => make_image(submenu => 1),
145 subitems => section_menu($menu, $item),
147 } elsif ($menuitem->{module}) {
148 push @items, make_item(
149 target => $menuitem->{target},
150 img => make_image(label => $label, icon => $label_icon),
158 $::lxdebug->leave_sub;
164 $params{spacer} ||= '';
165 $params{height} ||= 16;
169 # chunks => [ multiline($params{label}) ],
173 # multi line hack, sschoeling jul06
174 # if a label is too long, try to split it at whitespaces, then join it to chunks of less
175 # than 20 chars and store it in an array.
176 # use this array later instead of the -ed label
181 for (split / /, $label) {
184 $chunks[-1] .= " $_";
196 my $icon = $params{icon};
197 my $size = $params{size} || 16;
199 return unless _show_images();
201 my $icon_found = $icon && -f _icon_path($icon, $size);
202 my $padding = $size == 16 && $icon_found ? $nbsp x 2
203 : $size == 24 ? $nbsp
207 src => $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png",
208 alt => $params{label},
209 width => $icon_found ? $size : 24,
210 height => $icon_found ? $size : 15,
214 sub _calc_framesize {
215 my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i;
216 my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
217 my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i;
219 return $is_mobile_browser && $is_mobile_style ? 130
220 : $is_lynx_browser ? 240
225 # don't show images in links
226 _calc_framesize() != 240;
230 my ($label, $size) = @_;
234 return "image/icons/${size}x${size}/$label";