From: Sven Schöling Date: Mon, 20 Aug 2012 08:33:04 +0000 (+0200) Subject: html menü rewrite v1 X-Git-Tag: release-3.0.0beta1~223 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c6a27f90a8e644ed00910aeddaff38c74b513032;p=kivitendo-erp.git html menü rewrite v1 --- diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 43bf6680b..2386d3733 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -33,6 +33,7 @@ use SL::Locale; use SL::Common; use SL::Form; use SL::Helper::DateTime; +use SL::Controller::LoginScreen; use SL::InstanceConfiguration; use SL::Template::Plugin::HTMLFixes; diff --git a/SL/Menu.pm b/SL/Menu.pm index ab35fed1a..bc1b4e753 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -66,32 +66,27 @@ sub menuitem { my $module = $self->{$item}{module} || $form->{script}; my $action = $self->{$item}{action} || "section_menu"; my $target = $self->{$item}{target} || ""; - my $level = $form->escape($item); - - my $style = 'style="vertical-align:top"'; - my $target_token = ($target) - ? "target='$target'" : ''; + my $target_token = ($target) ? "target='$target'" : ''; my $href = ($self->{$item}{href}) ? $form->escape($self->{$item}{href}) - : "$module?action=$action&level=$level"; - - my @vars = ($self->{$item}{href}) - ? qw(module target href) - : qw(module action target href); - -# map { delete $self->{$item}{$_} } @vars; + : "$module?action=$action"; +# my @vars = ($self->{$item}{href}) +# ? qw(module target href) +# : qw(module action target href); +# # add other params foreach my $key (keys %{ $self->{$item} }) { + next if $key =~ /target|module|action/; $href .= "&" . $form->escape($key, 1) . "="; my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); $value = $myconfig->{$value} . "/$conf" if ($conf); $href .= $form->escape($value, 1); } - my $str = ""; + my $str = ""; $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/menu.pl b/bin/mozilla/menu.pl index d464c85d7..1b818d1bf 100644 --- a/bin/mozilla/menu.pl +++ b/bin/mozilla/menu.pl @@ -87,17 +87,10 @@ sub acc_menu { $::form->{title} = $::locale->text('kivitendo'); $::form->header; - print qq| - - -
\n\n|; - - section_menu($menu); - - print qq|
- - -|; + print $::form->parse_html_template('menu/menu', { + framesize => $framesize, + sections => [ section_menu($menu) ], + }); $::lxdebug->leave_sub; } @@ -106,6 +99,7 @@ sub section_menu { $::lxdebug->enter_sub; my ($menu, $level) = @_; my @menuorder = $menu->access_control(\%::myconfig, $level); + my @items; for my $item (@menuorder) { my $menuitem = $menu->{$item}; @@ -125,44 +119,40 @@ sub section_menu { if (!$level) { # toplevel my $ml_ = $::form->escape($ml); - my $image = make_image(icon => $item . '.png', size => 24, label => $label, valign => 'middle'); + my $image = make_image(icon => $item . '.png', size => 24, label => $label); my $anchor = "
"; - print make_item(a => $anchor, img => $image, label => $label, height => 24); - section_menu($menu, $item); + push @items, make_item(a => $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/) { - print make_item(spacer => $spacer, bold => 1, img => $image, label => $label) if $show; - section_menu($menu, $item); + push @items, make_item(spacer => $spacer, bold => 1, img => $image, label => $label, class => 'submenu') if $show; + push @items, section_menu($menu, $item); } else { - print make_item(spacer => $spacer, a => $anchor, img => $image, label => $label . ' ...') if $show; + push @items, make_item(spacer => $spacer, a => $anchor, img => $image, label => $label . ' ...', class => 'submenu') if $show; } } elsif ($menuitem->{module}) { 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; + push @items, make_item(img => $image, a => $anchor, spacer => $spacer, label => $label, class => 'item') if $show; + push @items, section_menu($menu, $item) if $show && $::form->{$item} && $::form->{level} eq $item; } } $::lxdebug->leave_sub; + return @items; } 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", - "$bold$spacer$anchor$image$chunks[0]$a_end$b_end\n", - map "$bold$spacer$hidden_image$anchor$chunks[$_]$a_end$b_end\n", - 1..$#chunks; + $params{a} ||= ''; + $params{spacer} ||= ''; + $params{height} ||= 16; + + return { + %params, + chunks => [ multiline($params{label}) ], + }; } # multi line hack, sschoeling jul06 @@ -190,23 +180,20 @@ sub make_image { my $label = $params{label}; my $icon = $params{icon}; - my $hidden = $params{hidden}; my $size = $params{size} || 16; - my $valign = $params{valign} || 'text-top'; return unless _show_images(); my $icon_found = $icon && -f _icon_path($icon, $size); my $image_url = $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png"; - my $style = $hidden ? "visibility:hidden" : "vertical-align:$valign"; - my $width = $hidden ? "width='$size'" : ''; + my $width = $icon_found ? $size : 24; - my $padding = $size == 16 && $icon_found || $hidden ? $nbsp x 2 - : $size == 24 ? $nbsp - : ''; + my $padding = $size == 16 && $icon_found ? $nbsp x 2 + : $size == 24 ? $nbsp + : ''; - return "$padding"; + return "$padding"; } sub _calc_framesize { diff --git a/templates/webpages/menu/menu.html b/templates/webpages/menu/menu.html new file mode 100644 index 000000000..29ba13e80 --- /dev/null +++ b/templates/webpages/menu/menu.html @@ -0,0 +1,26 @@ + + + + +
+ +[%- FOREACH item IN sections %] + +[%- END %] +
+ +