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);
48 $::lxdebug->enter_sub;
50 $::form->use_stylesheet(qw(css/icons16.css css/icons24.css));
52 my $menu = Menu->new("menu.ini");
54 my $sections = [ section_menu($menu) ];
56 $::lxdebug->leave_sub;
57 $::form->parse_html_template('menu/menu', {
58 sections => $sections,
64 $::lxdebug->enter_sub(2);
65 my ($menu, $level, $id_prefix) = @_;
66 my @menuorder = $menu->access_control(\%::myconfig, $level);
71 for my $item (@menuorder) {
72 my $menuitem = $menu->{$item};
73 my $olabel = apply { s/.*--// } $item;
74 my $ml = apply { s/--.*// } $item;
75 my $icon_class = apply { y/ /-/ } $item;
76 my $spacer = "s" . (0 + $item =~ s/--/--/g);
78 next if $level && $item ne "$level--$olabel";
80 my $label = $::locale->text($olabel);
82 $menuitem->{module} ||= $::form->{script};
83 $menuitem->{action} ||= "section_menu";
84 $menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}";
87 foreach my $key (keys %$menuitem) {
88 next if $key =~ /target|module|action|href/;
89 $menuitem->{href} .= "&" . $::form->escape($key, 1) . "=";
90 my ($value, $conf) = split(/=/, $menuitem->{$key}, 2);
91 $value = $::myconfig{$value} . "/$conf" if ($conf);
92 $menuitem->{href} .= $::form->escape($value, 1);
95 my $anchor = $menuitem->{href};
100 t => $menuitem->{target},
101 id => "$id_prefix\_$id",
105 if (!$level) { # toplevel
106 push @items, { %common_args,
107 i => "icon24 $icon_class", # make_image(size => 24, label => $item),
110 push @items, section_menu($menu, $item, "$id_prefix\_$id");
111 } elsif ($menuitem->{submenu}) {
112 push @items, { %common_args,
113 i => "icon16 submenu", #make_image(label => 'submenu'),
116 push @items, section_menu($menu, $item, "$id_prefix\_$id");
117 } elsif ($menuitem->{module}) {
118 push @items, { %common_args,
119 i => "icon16 $icon_class", #make_image(size => 16, label => $item),
128 $::lxdebug->leave_sub(2);
132 sub _calc_framesize {
133 my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i;
134 my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
135 my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i;
137 return $is_mobile_browser && $is_mobile_style ? 130
138 : $is_lynx_browser ? 240
143 # don't show images in links
144 _calc_framesize() != 240;