From 590708a7a8d02ecd60267271f276e975c08d56c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 23 Jun 2015 16:08:46 +0200 Subject: [PATCH] =?utf8?q?Menu:=20HTML=20Men=C3=BC=20parsing=20n+1=20besei?= =?utf8?q?tigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Layout/MenuLeft.pm | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/SL/Layout/MenuLeft.pm b/SL/Layout/MenuLeft.pm index 3c869bbb1..4c1901cc8 100644 --- a/SL/Layout/MenuLeft.pm +++ b/SL/Layout/MenuLeft.pm @@ -39,21 +39,23 @@ sub end_content { } sub section_menu { - $::lxdebug->enter_sub(2); - my ($menu, $level, $id_prefix) = @_; - my @menuorder = $menu->access_control(\%::myconfig, $level); + my ($menu) = @_; + my @menuorder = @{ $menu->{ORDER} }; my @items; - - my $id = 0; + my @id_stack = (-1); for my $item (@menuorder) { my $menuitem = $menu->{$item}; my $olabel = apply { s/.*--// } $item; my $ml = apply { s/--.*// } $item; my $icon_class = apply { $_ = lc $_; s/[^a-z0-9_-]/-/g } $menuitem->{ICON}; - my $spacer = "s" . (0 + $item =~ s/--/--/g); + my $level = (0 + $item =~ s/--/--/g); + my $spacer = "s" . $level; - next if $level && $item ne "$level--$olabel"; + # do id stack + push @id_stack, -1 if $level > $#id_stack; + pop @id_stack while $level < $#id_stack; + $id_stack[-1]++; my $label = $::locale->text($olabel); @@ -63,32 +65,24 @@ sub section_menu { # add other params foreach my $key (keys %$menuitem) { - next if $key =~ /target|module|action|href/; + next if $key =~ /target|module|action|href|ICON/; $menuitem->{href} .= "&" . $::form->escape($key, 1) . "="; my ($value, $conf) = split(/=/, $menuitem->{$key}, 2); $value = $::myconfig{$value} . "/$conf" if ($conf); $menuitem->{href} .= $::form->escape($value, 1); } - my @common_args = ($label, $spacer, "$id_prefix\_$id"); + my @common_args = ($label, $spacer, join '_', @id_stack); - if (!$level) { # toplevel + if ($spacer eq 's0') { # toplevel push @items, [ @common_args, "icon24 $icon_class", 'm' ]; - # make_image(size => 24, label => $item), - push @items, section_menu($menu, $item, "$id_prefix\_$id"); } elsif ($menuitem->{submenu}) { push @items, [ @common_args, "icon16 submenu", 'sm' ]; - #make_image(label => 'submenu'), - push @items, section_menu($menu, $item, "$id_prefix\_$id"); } elsif ($menuitem->{module}) { push @items, [ @common_args, "icon16 $icon_class", 'i', $menuitem->{href}, $menuitem->{target} ]; - #make_image(size => 16, label => $item), } - } continue { - $id++; } - $::lxdebug->leave_sub(2); return @items; } -- 2.20.1