X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c5657fe89f6eb75d36c126a11017439bd9d24895..3ab26ffcd0c8bfbf08508624c9ea07fbc6b4352a:/bin/mozilla/menu.pl diff --git a/bin/mozilla/menu.pl b/bin/mozilla/menu.pl index fd66bfac0..7e280ffd5 100644 --- a/bin/mozilla/menu.pl +++ b/bin/mozilla/menu.pl @@ -44,75 +44,43 @@ use URI; use List::MoreUtils qw(apply); -my $nbsp = ' '; - -# end of main - -sub display { +sub render { $::lxdebug->enter_sub; - my $callback = $::form->unescape($::form->{callback}); - $callback = URI->new($callback)->rel($callback) if $callback; - $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; - my $framesize = _calc_framesize(); - - $::form->header(doctype => 'frameset'); - - print qq| - - - - - - - - You need a browser that can read frames to see this page. - - - -|; - - $::lxdebug->leave_sub; -} - -sub acc_menu { - $::lxdebug->enter_sub; + $::form->use_stylesheet(qw(css/icons16.css css/icons24.css)); - my $framesize = _calc_framesize() - 2; my $menu = Menu->new("menu.ini"); - $::form->{title} = $::locale->text('kivitendo'); - $::form->header; - my $sections = section_menu($menu); + my $sections = [ section_menu($menu) ]; - print $::form->parse_html_template('menu/menu', { - framesize => $framesize, + $::lxdebug->leave_sub; + $::form->parse_html_template('menu/menu', { sections => $sections, + inline => 1, }); - - $::lxdebug->leave_sub; } sub section_menu { - $::lxdebug->enter_sub; - my ($menu, $level) = @_; + $::lxdebug->enter_sub(2); + my ($menu, $level, $id_prefix) = @_; my @menuorder = $menu->access_control(\%::myconfig, $level); my @items; + my $id = 0; + for my $item (@menuorder) { my $menuitem = $menu->{$item}; - my $label = apply { s/.*--// } $item; + my $olabel = apply { s/.*--// } $item; my $ml = apply { s/--.*// } $item; - my $spacer = "spacer" . (0 + $item =~ s/--/--/g); - my $label_icon = $level . "--" . $label . ".png"; + my $icon_class = apply { y/ /-/ } $item; + my $spacer = "s" . (0 + $item =~ s/--/--/g); - next if $level && $item ne "$level--$label"; + next if $level && $item ne "$level--$olabel"; - $label = $::locale->text($label); + my $label = $::locale->text($olabel); $menuitem->{module} ||= $::form->{script}; $menuitem->{action} ||= "section_menu"; - $menuitem->{target} ||= "main_window"; $menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}"; # add other params @@ -126,89 +94,37 @@ sub section_menu { my $anchor = $menuitem->{href}; + my %common_args = ( + l => $label, + s => $spacer, + id => "$id_prefix\_$id", + ); + if (!$level) { # toplevel - push @items, make_item( - img => make_image(icon => $item . '.png', size => 24, label => $label), - label => $label, - height => 24, - class => 'menu', - spacer => $spacer, - subitems => section_menu($menu, $item) - ); + push @items, { %common_args, + i => "icon24 $icon_class", # make_image(size => 24, label => $item), + c => 'm', + }; + push @items, section_menu($menu, $item, "$id_prefix\_$id"); } elsif ($menuitem->{submenu}) { - push @items, make_item( - target => $menuitem->{target}, - spacer => $spacer, - img => make_image(submenu => 1), - label => $label, - class => 'submenu', - subitems => section_menu($menu, $item), - ); + push @items, { %common_args, + i => "icon16 submenu", #make_image(label => 'submenu'), + c => 'sm', + }; + push @items, section_menu($menu, $item, "$id_prefix\_$id"); } elsif ($menuitem->{module}) { - push @items, make_item( - target => $menuitem->{target}, - img => make_image(label => $label, icon => $label_icon), - href => $anchor, - spacer => $spacer, - label => $label, - class => 'item', - ); + push @items, { %common_args, + i => "icon16 $icon_class", #make_image(size => 16, label => $item), + h => $anchor, + c => 'i', + }; } + } continue { + $id++; } - $::lxdebug->leave_sub; - return \@items; -} - -sub make_item { - my %params = @_; - $params{spacer} ||= ''; - $params{height} ||= 16; - return { - %params, -# chunks => [ multiline($params{label}) ], - }; -} - -# 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 -sub multiline { - my ($label) = @_; - my @chunks; - my $l = 20; - for (split / /, $label) { - $l += length $_; - if ($l < 20) { - $chunks[-1] .= " $_"; - } else { - $l = length $_; - push @chunks, $_; - } - } - return @chunks; -} - -sub make_image { - my (%params) = @_; - - my $icon = $params{icon}; - my $size = $params{size} || 16; - - return unless _show_images(); - - my $icon_found = $icon && -f _icon_path($icon, $size); - my $padding = $size == 16 && $icon_found ? $nbsp x 2 - : $size == 24 ? $nbsp - : ''; - - return { - src => $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png", - alt => $params{label}, - width => $icon_found ? $size : 24, - height => $icon_found ? $size : 15, - } + $::lxdebug->leave_sub(2); + return @items; } sub _calc_framesize { @@ -226,14 +142,6 @@ sub _show_images { _calc_framesize() != 240; } -sub _icon_path { - my ($label, $size) = @_; - - $size ||= 16; - - return "image/icons/${size}x${size}/$label"; -} - 1; __END__