X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/09fe7f33a735ecc3f4a3112ad716f674983b00cc..3ab26ffcd0c8bfbf08508624c9ea07fbc6b4352a:/bin/mozilla/menu.pl diff --git a/bin/mozilla/menu.pl b/bin/mozilla/menu.pl index 27643486a..7e280ffd5 100644 --- a/bin/mozilla/menu.pl +++ b/bin/mozilla/menu.pl @@ -28,203 +28,120 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ####################################################################### # -# thre frame layout with refractured menu +# the frame layout with refractured menu # # CHANGE LOG: # DS. 2002-03-25 Created # 2004-12-14 - New Optik - Marco Welter +# 2010-08-19 - Icons for sub entries and single click behavior, unlike XUL-Menu +# JS switchable HTML-menu - Sven Donath ####################################################################### -my $menufile = "menu.ini"; -use SL::Menu; -use Data::Dumper; -use URI; - use strict; -my $framesize = ($ENV{HTTP_USER_AGENT} =~ /links/i) ? "240" : "190"; -my $mainlevel; - -1; - -# end of main +use SL::Menu; +use URI; -sub display { - $main::lxdebug->enter_sub(); +use List::MoreUtils qw(apply); - my $form = $main::form; +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 =~ /^(\.\/)?$/; + $::form->use_stylesheet(qw(css/icons16.css css/icons24.css)); - $form->header; + my $menu = Menu->new("menu.ini"); - print qq| - - - - - - - - You need a browser that can read frames to see this page. - - - -|; + my $sections = [ section_menu($menu) ]; - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; + $::form->parse_html_template('menu/menu', { + sections => $sections, + inline => 1, + }); } -sub acc_menu { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my $locale = $main::locale; - - $mainlevel = $form->{level}; - $mainlevel =~ s/\Q$mainlevel\E--//g; - my $menu = new Menu "$menufile"; - - $form->{title} = $locale->text('Accounting Menu'); - - $form->header; - - print qq| - +sub section_menu { + $::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 $olabel = apply { s/.*--// } $item; + my $ml = apply { s/--.*// } $item; + my $icon_class = apply { y/ /-/ } $item; + my $spacer = "s" . (0 + $item =~ s/--/--/g); + + next if $level && $item ne "$level--$olabel"; + + my $label = $::locale->text($olabel); + + $menuitem->{module} ||= $::form->{script}; + $menuitem->{action} ||= "section_menu"; + $menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}"; + + # add other params + foreach my $key (keys %$menuitem) { + next if $key =~ /target|module|action|href/; + $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); + } -|; - print qq|
\n\n|; + my $anchor = $menuitem->{href}; + + my %common_args = ( + l => $label, + s => $spacer, + id => "$id_prefix\_$id", + ); + + if (!$level) { # toplevel + 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, { %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, { %common_args, + i => "icon16 $icon_class", #make_image(size => 16, label => $item), + h => $anchor, + c => 'i', + }; + } + } continue { + $id++; + } - §ion_menu($menu); + $::lxdebug->leave_sub(2); + return @items; +} - print qq|
|; - print qq| - - -|; +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; - $main::lxdebug->leave_sub(); + return $is_mobile_browser && $is_mobile_style ? 130 + : $is_lynx_browser ? 240 + : 200; } -sub section_menu { - $main::lxdebug->enter_sub(); - my ($menu, $level) = @_; - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - my $zeige; - - # build tiered menus - my @menuorder = $menu->access_control(\%myconfig, $level); - while (@menuorder) { - my $item = shift @menuorder; - my $label = $item; - my $ml = $item; - $label =~ s/\Q$level\E--//g; - $ml =~ s/--.*//; - if ($ml eq $mainlevel) { $zeige = 1; } - else { $zeige = 0; } - my $spacer = " " x (($item =~ s/--/--/g) * 1); - $label =~ s/.*--//g; - my $label_icon = $label . ".gif"; - my $mlab = $label; - $label = $locale->text($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 - my @chunks = (); - my ($i,$l) = (-1, 20); - map { - if (($l += length $_) < 20) { - $chunks[$i] .= " $_"; - } else { - $l = length $_; - $chunks[++$i] = $_; - - } - } split / /, $label; - map { s/ / / } @chunks; - # end multi line - - $label =~ s/ / /g; - $menu->{$item}{target} = "main_window" unless $menu->{$item}{target}; - - if ($menu->{$item}{submenu}) { - $menu->{$item}{$item} = !$form->{$item}; - if ($form->{level} && $item =~ /^\Q$form->{level}\E/) { - - # expand menu - if ($zeige) { - print - qq|$spacer$label\n|; - } - - # remove same level items - map { shift @menuorder } grep /^$item/, @menuorder; - §ion_menu($menu, $item); - } else { - if ($zeige) { - print qq|| - . $menu->menuitem(\%myconfig, \%$form, $item, $level) - . qq|$label ...\n|; - } - - # remove same level items - map { shift @menuorder } grep /^$item/, @menuorder; - } - } else { - if ($menu->{$item}{module}) { - if ($form->{$item} && $form->{level} eq $item) { - $menu->{$item}{$item} = !$form->{$item}; - if ($zeige) { - print - qq|$spacer| - . $menu->menuitem(\%myconfig, \%$form, $item, $level) - . qq|$label\n|; - } - - # remove same level items - map { shift @menuorder } grep /^$item/, @menuorder; - §ion_menu($menu, $item); - } else { - if ($zeige) { - if (scalar @chunks <= 1) { - print - qq|$spacer| - . $menu->menuitem(\%myconfig, \%$form, $item, $level) - . qq|$label\n|; - } else { - my $tmpitem = $menu->menuitem(\%myconfig, \%$form, $item, $level); - print - qq|$spacer| - . $tmpitem - . qq|$chunks[0]\n|; - map { - print - qq|$spacer| - . $tmpitem - . qq|$chunks[$_]\n|; - } 1..$#chunks; - } - } - } - } else { - my $ml_ = $form->escape($ml); - print - qq| $label    \n|; - §ion_menu($menu, $item); - - #print qq|
\n|; - } - } - } - $main::lxdebug->leave_sub(); +sub _show_images { + # don't show images in links + _calc_framesize() != 240; } + +1; + +__END__