Revision b251cc22
Von Sven Schöling vor mehr als 9 Jahren hinzugefügt
SL/Layout/CssMenu.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
use parent qw(SL::Layout::Base); |
5 | 5 |
|
6 |
use URI; |
|
7 |
|
|
8 |
sub print_menu { |
|
9 |
my ($self, $parent, $depth) = @_; |
|
10 |
|
|
11 |
my $html; |
|
12 |
|
|
13 |
die if ($depth * 1 > 5); |
|
14 |
|
|
15 |
my @menuorder; |
|
16 |
my $menu = $self->menu; |
|
17 |
|
|
18 |
@menuorder = $menu->access_control(\%::myconfig, $parent); |
|
19 |
|
|
20 |
$parent .= "--" if ($parent); |
|
21 |
|
|
22 |
foreach my $item (@menuorder) { |
|
23 |
substr($item, 0, length($parent)) = ""; |
|
24 |
next if (($item eq "") || ($item =~ /--/)); |
|
25 |
|
|
26 |
my $menu_item = $menu->{"${parent}${item}"}; |
|
27 |
my $menu_title = $::locale->text($item); |
|
28 |
my $menu_text = $menu_title; |
|
29 |
|
|
30 |
if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) && !defined($menu_item->{href})) { |
|
31 |
|
|
32 |
my $h = $self->print_menu("${parent}${item}", $depth * 1 + 1)."\n"; |
|
33 |
if (!$parent) { |
|
34 |
$html .= qq|<ul><li><h2>${menu_text}</h2><ul>${h}</ul></li></ul>\n|; |
|
35 |
} else { |
|
36 |
$html .= qq|<li><div class="x">${menu_text}</div><ul>${h}</ul></li>\n|; |
|
37 |
} |
|
38 |
} else { |
|
39 |
if ($self->{sub_class} && $depth > 1) { |
|
40 |
$html .= qq|<li class='sub'>|; |
|
41 |
} else { |
|
42 |
$html .= qq|<li>|; |
|
43 |
} |
|
44 |
$html .= $self->menuitem_v3("${parent}$item", { "title" => $menu_title }); |
|
45 |
$html .= qq|${menu_text}</a></li>\n|; |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
return $html; |
|
50 |
} |
|
51 |
|
|
52 |
sub menuitem_v3 { |
|
53 |
$main::lxdebug->enter_sub(); |
|
54 |
|
|
55 |
my ($self, $item, $other) = @_; |
|
56 |
my $menuitem = $self->menu->{$item}; |
|
57 |
|
|
58 |
my $action = "section_menu"; |
|
59 |
my $module; |
|
60 |
|
|
61 |
if ($menuitem->{module}) { |
|
62 |
$module = $menuitem->{module}; |
|
63 |
} |
|
64 |
if ($menuitem->{action}) { |
|
65 |
$action = $menuitem->{action}; |
|
66 |
} |
|
67 |
|
|
68 |
my $level = $::form->escape($item); |
|
69 |
|
|
70 |
my @vars; |
|
71 |
my $target = $menuitem->{target} ? qq| target="| . $::form->escape($menuitem->{target}) . '"' : ''; |
|
72 |
my $str = qq|<a${target} href="|; |
|
73 |
|
|
74 |
if ($menuitem->{href}) { |
|
75 |
$main::lxdebug->leave_sub(); |
|
76 |
return $str . $menuitem->{href} . '">'; |
|
77 |
} |
|
78 |
|
|
79 |
$str .= qq|$module?action=| . $::form->escape($action); |
|
80 |
|
|
81 |
map { delete $menuitem->{$_} } qw(module action target href); |
|
82 |
|
|
83 |
# add other params |
|
84 |
foreach my $key (keys %{ $menuitem }) { |
|
85 |
$str .= "&" . $::form->escape($key, 1) . "="; |
|
86 |
my ($value, $conf) = split(/=/, $menuitem->{$key}, 2); |
|
87 |
$value = $::myconfig{$value} . "/$conf" if ($conf); |
|
88 |
$str .= $::form->escape($value, 1); |
|
89 |
} |
|
90 |
|
|
91 |
$str .= '"'; |
|
92 |
|
|
93 |
if ($other) { |
|
94 |
foreach my $key (keys(%{$other})) { |
|
95 |
$str .= qq| ${key}="| . $::form->quote($other->{$key}) . qq|"|; |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
$str .= ">"; |
|
100 |
|
|
101 |
$main::lxdebug->leave_sub(); |
|
102 |
|
|
103 |
return $str; |
|
104 |
} |
|
105 |
|
|
106 | 6 |
sub use_stylesheet { |
107 | 7 |
qw(icons16.css frame_header/header.css), |
108 | 8 |
} |
109 | 9 |
|
110 | 10 |
sub pre_content { |
111 |
$_[0]->presenter->render('menu/menuv3', |
|
112 |
menu => $_[0]->print_menu, |
|
113 |
); |
|
11 |
$_[0]->presenter->render('menu/menuv3', menu => $_[0]->menu); |
|
114 | 12 |
} |
115 | 13 |
|
116 | 14 |
1; |
Auch abrufbar als: Unified diff
Menüstruktur auf YAML geändert