From 88bd305a4cf8eee63e4b8b81f714395584e3bb52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 29 Aug 2012 19:59:57 +0200 Subject: [PATCH] menuitem nach menu.pl verlagert. links in template generiert --- bin/mozilla/menu.pl | 36 +++++++++++++++++++++++++------ templates/webpages/menu/menu.html | 13 +++++++---- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/bin/mozilla/menu.pl b/bin/mozilla/menu.pl index 1b818d1bf..1181cbd82 100644 --- a/bin/mozilla/menu.pl +++ b/bin/mozilla/menu.pl @@ -113,29 +113,29 @@ sub section_menu { $label = $::locale->text($label); - $menuitem->{target} ||= "main_window"; + menuitem($menuitem); - my $anchor = $menu->menuitem(\%::myconfig, $::form, $item, $level); + my $anchor = $menuitem->{href}; if (!$level) { # toplevel my $ml_ = $::form->escape($ml); my $image = make_image(icon => $item . '.png', size => 24, label => $label); - my $anchor = ""; + my $anchor = "menu.pl?action=acc_menu&level=$ml_"; - push @items, make_item(a => $anchor, img => $image, label => $label, height => 24, class => 'menu'); + push @items, make_item(href => $anchor, img => $image, label => $label, height => 24, class => 'menu'); push @items, section_menu($menu, $item); } elsif ($menuitem->{submenu}) { my $image = make_image(submenu => 1); if ($mainlevel && $item =~ /^\Q$mainlevel\E/) { - push @items, make_item(spacer => $spacer, bold => 1, img => $image, label => $label, class => 'submenu') if $show; + push @items, make_item(target => $menuitem->{target}, spacer => $spacer, bold => 1, img => $image, label => $label, class => 'submenu') if $show; push @items, section_menu($menu, $item); } else { - push @items, make_item(spacer => $spacer, a => $anchor, img => $image, label => $label . ' ...', class => 'submenu') if $show; + push @items, make_item(spacer => $spacer, href => $anchor, img => $image, label => $label . ' ...', class => 'submenu') if $show; } } elsif ($menuitem->{module}) { my $image = make_image(label => $label, icon => $label_icon); - push @items, make_item(img => $image, a => $anchor, spacer => $spacer, label => $label, class => 'item') if $show; + push @items, make_item(target => $menuitem->{target}, img => $image, href => $anchor, spacer => $spacer, label => $label, class => 'item') if $show; push @items, section_menu($menu, $item) if $show && $::form->{$item} && $::form->{level} eq $item; } } @@ -143,6 +143,28 @@ sub section_menu { return @items; } +sub menuitem { + my ($item, $name) = @_; + + $item->{module} ||= $::form->{script}; + $item->{action} ||= "section_menu"; + $item->{target} ||= "main_window"; + $item->{href} ||= "$item->{module}?action=$item->{action}"; + + # add other params + foreach my $key (keys %$item) { + next if $key =~ /target|module|action|href/; + $item->{href} .= "&" . $::form->escape($key, 1) . "="; + my ($value, $conf) = split(/=/, $item->{$key}, 2); + $value = $::myconfig{$value} . "/$conf" if ($conf); + $item->{href} .= $::form->escape($value, 1); + } + +# my $str = ""; +# +# return $str; +} + sub make_item { my %params = @_; $params{a} ||= ''; diff --git a/templates/webpages/menu/menu.html b/templates/webpages/menu/menu.html index 29ba13e80..5e1c1c7db 100644 --- a/templates/webpages/menu/menu.html +++ b/templates/webpages/menu/menu.html @@ -1,7 +1,6 @@ - +[%- USE L %]