kivitendo/SL/Controller/Layout/MenuLeft.pm @ 0f69c726
4a12c839 | Sven Schöling | package SL::Controller::Layout::MenuLeft;
|
||
d319704a | Moritz Bunkus | |||
3289bcb2 | Sven Schöling | use strict;
|
||
4a12c839 | Sven Schöling | use parent qw(SL::Controller::Layout::Base);
|
||
3289bcb2 | Sven Schöling | |||
f2078516 | Sven Schöling | use URI;
|
||
d319704a | Moritz Bunkus | |||
829f6742 | Sven Schöling | use List::MoreUtils qw(apply);
|
||
0f179c9a | Sven Schöling | sub new {
|
||
my ($class, @slurp) = @_;
|
||||
my $self = $class->SUPER::new(@slurp);
|
||||
$self->use_stylesheet(qw(css/icons16.css css/icons24.css));
|
||||
$self;
|
||||
4a12c839 | Sven Schöling | }
|
||
d319704a | Moritz Bunkus | |||
4a12c839 | Sven Schöling | sub render {
|
||
my ($self) = @_;
|
||||
my $sections = [ section_menu($self->menu) ];
|
||||
7adc5519 | Sven Schöling | |||
4a12c839 | Sven Schöling | $self->SUPER::render('menu/menu', { no_menu => 1, no_output => 1 },
|
||
7adc5519 | Sven Schöling | sections => $sections,
|
||
4a12c839 | Sven Schöling | );
|
||
d319704a | Moritz Bunkus | }
|
||
sub section_menu {
|
||||
3880d657 | Sven Schöling | $::lxdebug->enter_sub(2);
|
||
5d73281e | Sven Schöling | my ($menu, $level, $id_prefix) = @_;
|
||
829f6742 | Sven Schöling | my @menuorder = $menu->access_control(\%::myconfig, $level);
|
||
c6a27f90 | Sven Schöling | my @items;
|
||
829f6742 | Sven Schöling | |||
5d73281e | Sven Schöling | my $id = 0;
|
||
829f6742 | Sven Schöling | for my $item (@menuorder) {
|
||
my $menuitem = $menu->{$item};
|
||||
62822c6a | Sven Schöling | my $olabel = apply { s/.*--// } $item;
|
||
829f6742 | Sven Schöling | my $ml = apply { s/--.*// } $item;
|
||
62822c6a | Sven Schöling | my $icon_class = apply { y/ /-/ } $item;
|
||
5d73281e | Sven Schöling | my $spacer = "s" . (0 + $item =~ s/--/--/g);
|
||
005b4d9b | Sven Schöling | |||
62822c6a | Sven Schöling | next if $level && $item ne "$level--$olabel";
|
||
829f6742 | Sven Schöling | |||
62822c6a | Sven Schöling | my $label = $::locale->text($olabel);
|
||
829f6742 | Sven Schöling | |||
62d7ed6e | Sven Schöling | $menuitem->{module} ||= $::form->{script};
|
||
$menuitem->{action} ||= "section_menu";
|
||||
fdd40c9d | Sven Schöling | $menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}";
|
||
62d7ed6e | Sven Schöling | |||
# add other params
|
||||
fdd40c9d | Sven Schöling | foreach my $key (keys %$menuitem) {
|
||
62d7ed6e | Sven Schöling | next if $key =~ /target|module|action|href/;
|
||
$menuitem->{href} .= "&" . $::form->escape($key, 1) . "=";
|
||||
fdd40c9d | Sven Schöling | my ($value, $conf) = split(/=/, $menuitem->{$key}, 2);
|
||
62d7ed6e | Sven Schöling | $value = $::myconfig{$value} . "/$conf" if ($conf);
|
||
fdd40c9d | Sven Schöling | $menuitem->{href} .= $::form->escape($value, 1);
|
||
62d7ed6e | Sven Schöling | }
|
||
829f6742 | Sven Schöling | |||
88bd305a | Sven Schöling | my $anchor = $menuitem->{href};
|
||
829f6742 | Sven Schöling | |||
5d73281e | Sven Schöling | my %common_args = (
|
||
3c058d7f | Sven Schöling | l => $label,
|
||
s => $spacer,
|
||||
id => "$id_prefix\_$id",
|
||||
5d73281e | Sven Schöling | );
|
||
829f6742 | Sven Schöling | if (!$level) { # toplevel
|
||
5d73281e | Sven Schöling | push @items, { %common_args,
|
||
3c058d7f | Sven Schöling | i => "icon24 $icon_class", # make_image(size => 24, label => $item),
|
||
c => 'm',
|
||||
5d73281e | Sven Schöling | };
|
||
push @items, section_menu($menu, $item, "$id_prefix\_$id");
|
||||
829f6742 | Sven Schöling | } elsif ($menuitem->{submenu}) {
|
||
5d73281e | Sven Schöling | push @items, { %common_args,
|
||
3c058d7f | Sven Schöling | i => "icon16 submenu", #make_image(label => 'submenu'),
|
||
c => 'sm',
|
||||
5d73281e | Sven Schöling | };
|
||
push @items, section_menu($menu, $item, "$id_prefix\_$id");
|
||||
829f6742 | Sven Schöling | } elsif ($menuitem->{module}) {
|
||
5d73281e | Sven Schöling | push @items, { %common_args,
|
||
3c058d7f | Sven Schöling | i => "icon16 $icon_class", #make_image(size => 16, label => $item),
|
||
h => $anchor,
|
||||
c => 'i',
|
||||
5d73281e | Sven Schöling | };
|
||
829f6742 | Sven Schöling | }
|
||
5d73281e | Sven Schöling | } continue {
|
||
$id++;
|
||||
829f6742 | Sven Schöling | }
|
||
c6a27f90 | Sven Schöling | |||
3880d657 | Sven Schöling | $::lxdebug->leave_sub(2);
|
||
5d73281e | Sven Schöling | return @items;
|
||
829f6742 | Sven Schöling | }
|
||
3289bcb2 | Sven Schöling | 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;
|
||||
return $is_mobile_browser && $is_mobile_style ? 130
|
||||
: $is_lynx_browser ? 240
|
||||
da80eb32 | Sven Donath | : 200;
|
||
3289bcb2 | Sven Schöling | }
|
||
829f6742 | Sven Schöling | sub _show_images {
|
||
# don't show images in links
|
||||
_calc_framesize() != 240;
|
||||
}
|
||||
3289bcb2 | Sven Schöling | 1;
|