Projekt

Allgemein

Profil

Herunterladen (4,58 KB) Statistiken
| Zweig: | Markierung: | Revision:
b6fd15a8 Sven Schöling
package SL::Layout::MenuLeft;
d319704a Moritz Bunkus
3289bcb2 Sven Schöling
use strict;
b6fd15a8 Sven Schöling
use parent qw(SL::Layout::Base);
3289bcb2 Sven Schöling
f2078516 Sven Schöling
use URI;
d319704a Moritz Bunkus
829f6742 Sven Schöling
use List::MoreUtils qw(apply);

a8814e0e Sven Schöling
sub stylesheets {
dc4b933b Sven Schöling
qw(icons16.css icons24.css menu.css)
a8814e0e Sven Schöling
}
7adc5519 Sven Schöling
a8814e0e Sven Schöling
sub javascripts_inline {
my $self = shift;
my $sections = [ section_menu($self->menu) ];
9ad27e65 Sven Schöling
$self->presenter->render('menu/menu',
7adc5519 Sven Schöling
sections => $sections,
a8814e0e Sven Schöling
)
}

dc4b933b Sven Schöling
sub javascripts {
9be43132 Sven Schöling
qw(
js/jquery.cookie.js
js/switchmenuframe.js
);
dc4b933b Sven Schöling
}

a8814e0e Sven Schöling
sub pre_content {
"<div id='html-menu'></div>\n";
}

sub start_content {
"<div id='content' class='html-menu'>\n";
}

sub end_content {
"</div>\n";
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;
4d1071ce Sven Schöling
my $icon_class = apply { $_ =lc $_; s/[^a-z0-9_-]/-/g } $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
6fd839ca Sven Schöling
my @common_args = ($label, $spacer, "$id_prefix\_$id");
5d73281e Sven Schöling
829f6742 Sven Schöling
if (!$level) { # toplevel
6fd839ca Sven Schöling
push @items, [ @common_args, "icon24 $icon_class", 'm' ];
# make_image(size => 24, label => $item),
5d73281e Sven Schöling
push @items, section_menu($menu, $item, "$id_prefix\_$id");
829f6742 Sven Schöling
} elsif ($menuitem->{submenu}) {
6fd839ca Sven Schöling
push @items, [ @common_args, "icon16 submenu", 'sm' ];
#make_image(label => 'submenu'),
5d73281e Sven Schöling
push @items, section_menu($menu, $item, "$id_prefix\_$id");
829f6742 Sven Schöling
} elsif ($menuitem->{module}) {
8660390c Moritz Bunkus
push @items, [ @common_args, "icon16 $icon_class", 'i', $menuitem->{href}, $menuitem->{target} ];
6fd839ca Sven Schöling
#make_image(size => 16, label => $item),
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;
91aa8ecb Sven Schöling
__END__

=encoding utf-8

=head1 NAME

SL::Layout::MenuLeft - ex html meanu, now only left menu

=head1 DOM MODEL

Data will be embedded into the page as a json array of entries.
Each entry is another array with the following fields:

0: title
1: indentation classes
2: unique id
3: icon classes
4: role classes
8660390c Moritz Bunkus
5: href
6: target
91aa8ecb Sven Schöling
From each entry the following dom will be generated, with [0] being entry 0 of
the data array:

<div id="mi[2]" class="mi [4] [1]">
<a class="ml">
<span class="mii ms">
<div class="[3]"></div>
</span>
<span class="mic">[0]</span>
</a>
</div>

The classes are minified to keep the json somewhat in check, their meaning is as follows:

=over 4

=item Indentation Classes

s0: No indentation
s1: One level of indentation
s2: Two levels of indentation

=item Icon Classes

Each icon consists of two classes, one for the icon, and one for the size.
The icon classes are taken from the file names, for example C<Master-Data> is
the icon for master data, and refers to Master-Icon.png.

icon16: 16x16 icon
icon24: 24x24 icon
icon32: 32x32 icon

=item Role Classes

Role classes may be used to style types of links differently. Currently used:

ml: menu link, any <a> tag will have this
mi: menu item, the enclosing div for each entry has this
mii: menu item icon, the enclosing div for the icons has this
ms: menu spacer, the first <span> in the link will have this
m: menu, only top level entries have this
i: item, only leaf entries have this
sm: sub menu, eveything that is not top nor leaf has this
mic: menu item content, the span with the human readable description has this

=back

=head1 BUGS

none yet

=head1 AUTHOR

Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>

=cut