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 #######################################################################
46 use List::MoreUtils qw(apply);
48 my $menufile = "menu.ini";
55 $::lxdebug->enter_sub;
57 my $callback = $::form->unescape($::form->{callback});
58 $callback = URI->new($callback)->rel($callback) if $callback;
59 $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/;
60 my $framesize = _calc_framesize();
62 $::form->header(doctype => 'frameset');
65 <frameset rows="28px,*" cols="*" framespacing="0" frameborder="0">
66 <frame src="controller.pl?action=FrameHeader/header" scrolling="NO">
67 <frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" id="menuframe" name="menuframe">
68 <frame src="$::form->{script}?action=acc_menu" name="acc_menu" scrolling="auto" noresize marginwidth="0">
69 <frame src="$callback" name="main_window" scrolling="auto">
72 You need a browser that can read frames to see this page.
78 $::lxdebug->leave_sub;
82 $::lxdebug->enter_sub;
84 my $framesize = _calc_framesize() - 2;
85 my $menu = Menu->new("menu.ini");
86 $mainlevel = $::form->{level};
87 $::form->{title} = $::locale->text('kivitendo');
93 <div align="left">\n<table width="$framesize" border="0">\n|;
97 print qq|</table></div>
102 $::lxdebug->leave_sub;
106 $::lxdebug->enter_sub;
107 my ($menu, $level) = @_;
108 my @menuorder = $menu->access_control(\%::myconfig, $level);
110 for my $item (@menuorder) {
111 my $menuitem = $menu->{$item};
112 my $label = apply { s/.*--// } $item;
113 my $ml = apply { s/--.*// } $item;
114 my $show = $ml eq $mainlevel;
115 my $spacer = $nbsp x (($item =~ s/--/--/g) * 2);
116 my $label_icon = $level . "--" . $label . ".png";
118 next if $level && $item ne "$level--$label";
120 $label = $::locale->text($label);
122 $menuitem->{target} ||= "main_window";
124 my $anchor = $menu->menuitem(\%::myconfig, $::form, $item, $level);
126 if (!$level) { # toplevel
127 my $ml_ = $::form->escape($ml);
128 my $image = make_image(icon => $item . '.png', size => 24, label => $label, valign => 'middle');
129 my $anchor = "<a href='menu.pl?action=acc_menu&level=$ml_' class='nohover' title='$label'>";
131 print make_item(a => $anchor, img => $image, label => $label, height => 24);
132 section_menu($menu, $item);
134 } elsif ($menuitem->{submenu}) {
135 my $image = make_image(submenu => 1);
136 if ($mainlevel && $item =~ /^\Q$mainlevel\E/) {
137 print make_item(spacer => $spacer, bold => 1, img => $image, label => $label) if $show;
138 section_menu($menu, $item);
140 print make_item(spacer => $spacer, a => $anchor, img => $image, label => $label . ' ...') if $show;
142 } elsif ($menuitem->{module}) {
143 my $image = make_image(label => $label, icon => $label_icon);
144 print make_item(img => $image, a => $anchor, spacer => $spacer, label => $label) if $show;
145 section_menu($menu, $item) if $show && $::form->{$item} && $::form->{level} eq $item;
148 $::lxdebug->leave_sub;
153 my $anchor = $params{a} || '';
154 my @chunks = multiline($params{label});
155 my $spacer = $params{spacer} || '';
156 my $image = $params{img};
157 my $height = $params{height} || 16;
158 my $a_end = $anchor ? '</a>' : '';
159 my $bold = $params{bold} ? '<b>' : '';
160 my $b_end = $bold ? '</b>' : '';
161 my $hidden_image = make_image(hidden => 1);
163 "<tr><td class='hover' height='$height'>$bold$spacer$anchor$image$chunks[0]$a_end$b_end</td></tr>\n",
164 map "<tr style='vertical-align:top'><td class='hover'>$bold$spacer$hidden_image$anchor$chunks[$_]$a_end$b_end</td></tr>\n",
168 # multi line hack, sschoeling jul06
169 # if a label is too long, try to split it at whitespaces, then join it to chunks of less
170 # than 20 chars and store it in an array.
171 # use this array later instead of the -ed label
176 for (split / /, $label) {
179 $chunks[-1] .= " $_";
191 my $label = $params{label};
192 my $icon = $params{icon};
193 my $hidden = $params{hidden};
194 my $size = $params{size} || 16;
195 my $valign = $params{valign} || 'text-top';
197 return unless _show_images();
199 my $icon_found = $icon && -f _icon_path($icon, $size);
201 my $image_url = $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png";
202 my $style = $hidden ? "visibility:hidden" : "vertical-align:$valign";
203 my $width = $hidden ? "width='$size'" : '';
205 my $padding = $size == 16 && $icon_found || $hidden ? $nbsp x 2
206 : $size == 24 ? $nbsp
209 return "<img src='$image_url' border='0' style='$style' title='$label' $width>$padding";
212 sub _calc_framesize {
213 my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i;
214 my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
215 my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i;
217 return $is_mobile_browser && $is_mobile_style ? 130
218 : $is_lynx_browser ? 240
223 # don't show images in links
224 _calc_framesize() != 240;
228 my ($label, $size) = @_;
232 return "image/icons/${size}x${size}/$label";