Revision b251cc22
Von Sven Schöling vor mehr als 9 Jahren hinzugefügt
SL/Layout/Javascript.pm | ||
---|---|---|
21 | 21 |
$self->SUPER::use_javascript(@_); |
22 | 22 |
} |
23 | 23 |
|
24 |
sub javascripts_inline { |
|
25 |
$_[0]->SUPER::javascripts_inline, |
|
26 |
<<'EOJS' |
|
27 |
DHTMLSuite.createStandardObjects(); |
|
28 |
DHTMLSuite.configObj.setImagePath('image/dhtmlsuite/'); |
|
29 |
var menu_model = new DHTMLSuite.menuModel(); |
|
30 |
menu_model.addItemsFromMarkup('main_menu_model'); |
|
31 |
menu_model.init(); |
|
32 |
var menu_bar = new DHTMLSuite.menuBar(); |
|
33 |
menu_bar.addMenuItems(menu_model); |
|
34 |
menu_bar.setTarget('main_menu_div'); |
|
35 |
menu_bar.init(); |
|
36 |
EOJS |
|
37 |
} |
|
38 |
|
|
24 | 39 |
sub pre_content { |
25 | 40 |
$_[0]->SUPER::pre_content . |
26 |
&display |
|
41 |
$_[0]->presenter->render("menu/menunew", |
|
42 |
force_ul_width => 1, |
|
43 |
menu => $_[0]->menu, |
|
44 |
icon_path => sub { my $img = "image/icons/16x16/$_[0].png"; -f $img ? $img : () }, |
|
45 |
max_width => sub { 10 * max map { length $::locale->text($_->{name}) } @{ $_[0]{children} || [] } }, |
|
46 |
); |
|
27 | 47 |
} |
28 | 48 |
|
29 | 49 |
sub start_content { |
... | ... | |
45 | 65 |
$_[0]->SUPER::stylesheets; |
46 | 66 |
} |
47 | 67 |
|
48 |
sub display { |
|
49 |
my ($self) = @_; |
|
50 |
|
|
51 |
$self->presenter->render("menu/menunew", |
|
52 |
force_ul_width => 1, |
|
53 |
menu_items => $self->acc_menu, |
|
54 |
); |
|
55 |
} |
|
56 |
|
|
57 |
sub acc_menu { |
|
58 |
my ($self) = @_; |
|
59 |
|
|
60 |
my $menu = $self->menu; |
|
61 |
|
|
62 |
my $all_items = []; |
|
63 |
$self->create_menu($menu, $all_items); |
|
64 |
|
|
65 |
my $item = { 'subitems' => $all_items }; |
|
66 |
calculate_width($item); |
|
67 |
|
|
68 |
return $all_items; |
|
69 |
} |
|
70 |
|
|
71 |
sub calculate_width { |
|
72 |
my $item = shift; |
|
73 |
|
|
74 |
$item->{max_width} = max map { length $_->{title} } @{ $item->{subitems} }; |
|
75 |
|
|
76 |
foreach my $subitem (@{ $item->{subitems} }) { |
|
77 |
calculate_width($subitem) if ($subitem->{subitems}); |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
sub create_menu { |
|
82 |
my ($self, $menu, $all_items, $parent, $depth) = @_; |
|
83 |
my $html; |
|
84 |
|
|
85 |
my $form = $main::form; |
|
86 |
my %myconfig = %main::myconfig; |
|
87 |
|
|
88 |
$depth ||= 0; |
|
89 |
|
|
90 |
die if ($depth * 1 > 5); |
|
91 |
|
|
92 |
my @menuorder = $menu->access_control(\%myconfig, $parent); |
|
93 |
$parent .= "--" if ($parent); |
|
94 |
$parent ||= ''; |
|
95 |
|
|
96 |
foreach my $name (@menuorder) { |
|
97 |
substr($name, 0, length($parent), ""); |
|
98 |
next if (($name eq "") || ($name =~ /--/)); |
|
99 |
|
|
100 |
my $menu_item = $menu->{"${parent}${name}"}; |
|
101 |
my $item = { 'title' => $::locale->text($name) }; |
|
102 |
push @{ $all_items }, $item; |
|
103 |
|
|
104 |
if ($menu_item->{submenu} || (!defined($menu_item->{module}) && !defined($menu_item->{href}))) { |
|
105 |
$item->{subitems} = []; |
|
106 |
$item->{image} = _icon_path($menu_item->{ICON}); |
|
107 |
$self->create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1); |
|
108 |
|
|
109 |
} else { |
|
110 |
$item->{image} = _icon_path("${parent}${name}.png"); |
|
111 |
$menu->menuitem_new("${parent}${name}", $item); |
|
112 |
} |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
sub _icon_path { |
|
117 |
my ($label, $size) = @_; |
|
118 |
|
|
119 |
$size ||= 16; |
|
120 |
|
|
121 |
my $img = "image/icons/${size}x${size}/$label.png"; |
|
122 |
|
|
123 |
return unless -f $img; |
|
124 |
return $img; |
|
125 |
} |
|
126 |
|
|
127 | 68 |
1; |
Auch abrufbar als: Unified diff
Menüstruktur auf YAML geändert