X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fmenu.pl;h=cd0ca0d913a17bbadd32f1b1be8dc5d922792826;hb=1e0d413084100ccd892e8c5be95703be5d965de7;hp=ac5ba00207f3242153ef372a04812f5d2a611404;hpb=128bad31d931ed3a3df4390170f7a598748f3a83;p=kivitendo-erp.git
diff --git a/bin/mozilla/menu.pl b/bin/mozilla/menu.pl
index ac5ba0020..cd0ca0d91 100644
--- a/bin/mozilla/menu.pl
+++ b/bin/mozilla/menu.pl
@@ -82,7 +82,7 @@ sub acc_menu {
$::lxdebug->enter_sub;
my $framesize = _calc_framesize() - 2;
- my $menu = Menu->new($::menufile);
+ my $menu = Menu->new("menu.ini");
$mainlevel = $::form->{level};
$::form->{title} = $::locale->text('Lx-Office');
$::form->header;
@@ -105,9 +105,8 @@ sub acc_menu {
sub section_menu {
$::lxdebug->enter_sub;
my ($menu, $level) = @_;
-
- # build tiered menus
my @menuorder = $menu->access_control(\%::myconfig, $level);
+
for my $item (@menuorder) {
my $menuitem = $menu->{$item};
my $label = apply { s/.*--// } $item;
@@ -116,85 +115,74 @@ sub section_menu {
my $spacer = $nbsp x (($item =~ s/--/--/g) * 2);
my $label_icon = $level . "--" . $label . ".png";
+ next if $level && $item ne "$level--$label";
+
$label = $::locale->text($label);
$menuitem->{target} ||= "main_window";
my $anchor = $menu->menuitem(\%::myconfig, $::form, $item, $level);
- next if $menuitem->{HIDDEN};
-
- # multi line hack, sschoeling jul06
- # if a label is too long, try to split it at whitespaces, then join it to chunks of less
- # than 20 chars and store it in an array.
- # use this array later instead of the -ed label
- my @chunks;
- my $l = 20;
- for (split / /, $label) {
- $l += length $_;
- if ($l < 20) {
- $chunks[-1] .= " $_";
- } else {
- $l = length $_;
- push @chunks, $_;
- }
- }
- # end multi line
+ if (!$level) { # toplevel
+ my $ml_ = $::form->escape($ml);
+ my $image = make_image(icon => $item . '.png', size => 24, label => $label, valign => 'middle');
+ my $anchor = "";
- if ($menuitem->{submenu}) {
- if ($::form->{level} && $item =~ /^\Q$::form->{level}\E/) {
- my $image = make_image(submenu => 1);
- print " \n" if $show;
+ print make_item(a => $anchor, img => $image, label => $label, height => 24);
+ section_menu($menu, $item);
- # remove same level items
- $menu->{$_}{HIDDEN} = 1 for grep /^$item/, @menuorder;
+ } elsif ($menuitem->{submenu}) {
+ my $image = make_image(submenu => 1);
+ if ($mainlevel && $item =~ /^\Q$mainlevel\E/) {
+ print make_item(spacer => $spacer, bold => 1, img => $image, label => $label) if $show;
section_menu($menu, $item);
} else {
- print "$spacer$image$label \n" if $show;
-
- # remove same level items
- $menu->{$_}{HIDDEN} = 1 for grep /^$item/, @menuorder;
+ print make_item(spacer => $spacer, a => $anchor, img => $image, label => $label . ' ...') if $show;
}
} elsif ($menuitem->{module}) {
- if ($::form->{$item} && $::form->{level} eq $item) {
- my $image = make_image();
- print qq|$anchor$label ... \n| if $show;
-
- # remove same level items
- $menu->{$_}{HIDDEN} = 1 for grep /^$item/, @menuorder;
- section_menu($menu, $item);
- } elsif ($show) {
- my $image1 = make_image(label => $label, icon => $label_icon);
- my $image2 = make_image(hidden => 1);
- print "$spacer$image$anchor$label \n";
- print "$spacer$anchor$image1$chunks[0] \n"
- for 1..$#chunks;
- }
- } else {
- my $ml_ = $::form->escape($ml);
- my $image = make_image(icon => $item . '.png', size => 24, label => $label, valign => 'middle');
- my $anchor = "";
- print qq|$spacer$image2$anchor$chunks[$_] \n|;
-
- §ion_menu($menu, $item);
+ my $image = make_image(label => $label, icon => $label_icon);
+ print make_item(img => $image, a => $anchor, spacer => $spacer, label => $label) if $show;
+ section_menu($menu, $item) if $show && $::form->{$item} && $::form->{level} eq $item;
}
}
$::lxdebug->leave_sub;
}
-sub _calc_framesize {
- my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i;
- my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
- my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i;
-
- return $is_mobile_browser && $is_mobile_style ? 130
- : $is_lynx_browser ? 240
- : 200;
+sub make_item {
+ my %params = @_;
+ my $anchor = $params{a} || '';
+ my @chunks = multiline($params{label});
+ my $spacer = $params{spacer} || '';
+ my $image = $params{img};
+ my $height = $params{height} || 16;
+ my $a_end = $anchor ? '' : '';
+ my $bold = $params{bold} ? '' : '';
+ my $b_end = $bold ? '' : '';
+ my $hidden_image = make_image(hidden => 1);
+ return join "\n",
+ "$anchor$image$label