Revision 005b4d9b
Von Sven Schöling vor fast 14 Jahren hinzugefügt
bin/mozilla/menu.pl | ||
---|---|---|
43 | 43 |
use Data::Dumper; |
44 | 44 |
use URI; |
45 | 45 |
|
46 |
use List::MoreUtils qw(apply); |
|
47 |
|
|
48 | 46 |
my $menufile = "menu.ini"; |
49 |
my $nbsp = ' '; |
|
50 | 47 |
my $mainlevel; |
51 | 48 |
|
52 | 49 |
# end of main |
53 | 50 |
|
54 | 51 |
sub display { |
55 |
$::lxdebug->enter_sub; |
|
52 |
$main::lxdebug->enter_sub(); |
|
53 |
|
|
54 |
my $form = $main::form; |
|
56 | 55 |
|
57 |
my $callback = $::form->unescape($::form->{callback});
|
|
56 |
my $callback = $form->unescape($form->{callback});
|
|
58 | 57 |
$callback = URI->new($callback)->rel($callback) if $callback; |
59 | 58 |
$callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; |
60 | 59 |
my $framesize = _calc_framesize(); |
61 | 60 |
|
62 |
$::form->header;
|
|
61 |
$form->header; |
|
63 | 62 |
|
64 | 63 |
print qq| |
65 | 64 |
<frameset rows="28px,*" cols="*" framespacing="0" frameborder="0"> |
66 | 65 |
<frame src="kopf.pl" name="kopf" scrolling="NO"> |
67 | 66 |
<frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" id="menuframe" name="menuframe"> |
68 |
<frame src="$::form->{script}?action=acc_menu" name="acc_menu" scrolling="auto" noresize marginwidth="0">
|
|
67 |
<frame src="$form->{script}?action=acc_menu" name="acc_menu" scrolling="auto" noresize marginwidth="0"> |
|
69 | 68 |
<frame src="$callback" name="main_window" scrolling="auto"> |
70 | 69 |
</frameset> |
71 | 70 |
<noframes> |
... | ... | |
75 | 74 |
</HTML> |
76 | 75 |
|; |
77 | 76 |
|
78 |
$::lxdebug->leave_sub;
|
|
77 |
$main::lxdebug->leave_sub();
|
|
79 | 78 |
} |
80 | 79 |
|
81 | 80 |
sub acc_menu { |
82 |
$::lxdebug->enter_sub; |
|
81 |
$main::lxdebug->enter_sub(); |
|
82 |
|
|
83 |
my $form = $main::form; |
|
84 |
my $locale = $main::locale; |
|
85 |
my $framesize = _calc_framesize(); |
|
86 |
|
|
87 |
$mainlevel = $form->{level}; |
|
88 |
$mainlevel =~ s/\Q$mainlevel\E--//g; |
|
89 |
my $menu = Menu->new($::menufile); |
|
83 | 90 |
|
84 |
my $framesize = _calc_framesize() - 2; |
|
85 |
my $menu = Menu->new($::menufile); |
|
86 |
$mainlevel = $::form->{level}; |
|
87 |
$::form->{title} = $::locale->text('Lx-Office'); |
|
88 |
$::form->header; |
|
91 |
$form->{title} = $locale->text('Lx-Office'); |
|
92 |
|
|
93 |
$form->header; |
|
89 | 94 |
|
90 | 95 |
print qq| |
91 | 96 |
<body class="menu"> |
97 |
|
|
98 |
|; |
|
99 |
print qq|<div align="left">\n<table width="| |
|
100 |
. ($framesize-2) |
|
101 |
. qq|" border="0">\n|; |
|
92 | 102 |
|
93 |
<div align="left">\n<table width="$framesize" border="0">\n|; |
|
94 |
|
|
95 |
section_menu($menu); |
|
103 |
§ion_menu($menu); |
|
96 | 104 |
|
97 |
print qq|</table></div> |
|
105 |
print qq|</table></div>|; |
|
106 |
print qq| |
|
98 | 107 |
</body> |
99 | 108 |
</html> |
100 | 109 |
|; |
101 | 110 |
|
102 |
$::lxdebug->leave_sub;
|
|
111 |
$main::lxdebug->leave_sub();
|
|
103 | 112 |
} |
104 | 113 |
|
105 | 114 |
sub section_menu { |
106 |
$::lxdebug->enter_sub;
|
|
115 |
$main::lxdebug->enter_sub();
|
|
107 | 116 |
my ($menu, $level) = @_; |
108 | 117 |
|
109 |
# build tiered menus |
|
110 |
my @menuorder = $menu->access_control(\%::myconfig, $level); |
|
111 |
for my $item (@menuorder) { |
|
112 |
my $menuitem = $menu->{$item}; |
|
113 |
my $label = apply { s/.*--// } $item; |
|
114 |
my $ml = apply { s/--.*// } $item; |
|
115 |
my $show = $ml eq $mainlevel; |
|
116 |
my $spacer = $nbsp x (($item =~ s/--/--/g) * 2); |
|
117 |
my $label_icon = $level . "--" . $label . ".png"; |
|
118 |
my $form = $main::form; |
|
119 |
my %myconfig = %main::myconfig; |
|
120 |
my $locale = $main::locale; |
|
121 |
my $is_not_links_browser = $ENV{HTTP_USER_AGENT} =~ /links/i ? 0 : 1; |
|
118 | 122 |
|
119 |
$label = $::locale->text($label);
|
|
123 |
my $zeige;
|
|
120 | 124 |
|
121 |
$menuitem->{target} ||= "main_window"; |
|
122 |
|
|
123 |
my $anchor = $menu->menuitem(\%::myconfig, $::form, $item, $level); |
|
124 |
|
|
125 |
next if $menuitem->{HIDDEN}; |
|
125 |
# build tiered menus |
|
126 |
my @menuorder = $menu->access_control(\%myconfig, $level); |
|
127 |
while (@menuorder) { |
|
128 |
my $item = shift @menuorder; |
|
129 |
my $label = $item; |
|
130 |
my $ml = $item; |
|
131 |
$label =~ s/\Q$level\E--//g; |
|
132 |
$ml =~ s/--.*//; |
|
133 |
if ($ml eq $mainlevel) { $zeige = 1; } |
|
134 |
else { $zeige = 0; } |
|
135 |
my $spacer = " " x (($item =~ s/--/--/g) * 2); |
|
136 |
$label =~ s/.*--//g; |
|
137 |
my $label_icon = $level . "--" . $label . ".png"; |
|
138 |
my $mlab = $label; |
|
139 |
$label = $locale->text($label); |
|
126 | 140 |
|
127 | 141 |
# multi line hack, sschoeling jul06 |
128 | 142 |
# if a label is too long, try to split it at whitespaces, then join it to chunks of less |
129 | 143 |
# than 20 chars and store it in an array. |
130 | 144 |
# use this array later instead of the -ed label |
131 |
my @chunks; |
|
132 |
my $l = 20; |
|
133 |
for (split / /, $label) { |
|
134 |
$l += length $_; |
|
135 |
if ($l < 20) { |
|
136 |
$chunks[-1] .= " $_"; |
|
145 |
my @chunks = (); |
|
146 |
my ($i,$l) = (-1, 20); |
|
147 |
map { |
|
148 |
if (($l += length $_) < 20) { |
|
149 |
$chunks[$i] .= " $_"; |
|
137 | 150 |
} else { |
138 | 151 |
$l = length $_; |
139 |
push @chunks, $_; |
|
152 |
$chunks[++$i] = $_; |
|
153 |
|
|
140 | 154 |
} |
141 |
} |
|
155 |
} split / /, $label; |
|
156 |
map { s/ / / } @chunks; |
|
142 | 157 |
# end multi line |
143 | 158 |
|
144 |
if ($menuitem->{submenu}) { |
|
145 |
if ($::form->{level} && $item =~ /^\Q$::form->{level}\E/) { |
|
146 |
my $image = make_image(submenu => 1); |
|
147 |
print "<tr><td style='vertical-align:bottom'><b>$spacer$image$label</b></td></tr>\n" if $show; |
|
159 |
$label =~ s/ / /g; |
|
160 |
$menu->{$item}{target} = "main_window" unless $menu->{$item}{target}; |
|
148 | 161 |
|
149 |
# remove same level items |
|
150 |
$menu->{$_}{HIDDEN} = 1 for grep /^$item/, @menuorder; |
|
151 |
section_menu($menu, $item); |
|
152 |
} else { |
|
153 |
print "<tr><td>$anchor$label ...</a></td></tr>\n" if $show; |
|
162 |
if ($menu->{$item}{submenu}) { |
|
163 |
$menu->{$item}{$item} = !$form->{$item}; |
|
164 |
if ($form->{level} && $item =~ /^\Q$form->{level}\E/) { |
|
165 |
|
|
166 |
# expand menu |
|
167 |
if ($zeige) { |
|
168 |
|
|
169 |
qq|<tr><td style='vertical-align:bottom'><b>$spacer<img src="image/unterpunkt.png">$label</b></td></tr>\n|; |
|
170 |
} |
|
154 | 171 |
|
155 | 172 |
# remove same level items |
156 |
$menu->{$_}{HIDDEN} = 1 for grep /^$item/, @menuorder; |
|
157 |
} |
|
158 |
} elsif ($menuitem->{module}) { |
|
159 |
if ($::form->{$item} && $::form->{level} eq $item) { |
|
160 |
my $image = make_image(); |
|
161 |
print qq|<tr><td valign=bottom>$spacer$image$anchor$label</a></td></tr>\n| if $show; |
|
173 |
map { shift @menuorder } grep /^$item/, @menuorder; |
|
174 |
§ion_menu($menu, $item); |
|
175 |
} else { |
|
176 |
if ($zeige) { |
|
177 |
print qq|<tr><td>| |
|
178 |
. $menu->menuitem(\%myconfig, \%$form, $item, $level) |
|
179 |
. qq|$label ...</a></td></tr>\n|; |
|
180 |
} |
|
162 | 181 |
|
163 | 182 |
# remove same level items |
164 |
$menu->{$_}{HIDDEN} = 1 for grep /^$item/, @menuorder; |
|
165 |
section_menu($menu, $item); |
|
166 |
} elsif ($show) { |
|
167 |
my $image1 = make_image(label => $label, icon => $label_icon); |
|
168 |
my $image2 = make_image(hidden => 1); |
|
169 |
print "<tr><td class='hover' height='16'>$spacer$anchor$image1$chunks[0]</a></td></tr>\n"; |
|
170 |
print "<tr style='vertical-align:top'><td class='hover'>$spacer$image2$anchor$chunks[$_]</a></td></tr>\n" |
|
171 |
for 1..$#chunks; |
|
183 |
map { shift @menuorder } grep /^$item/, @menuorder; |
|
172 | 184 |
} |
173 | 185 |
} else { |
174 |
my $ml_ = $::form->escape($ml); |
|
175 |
my $image = make_image(icon => $item . '.png', size => 24, label => $label, valign => 'middle'); |
|
176 |
my $anchor = "<a href='menu.pl?action=acc_menu&level=$ml_' class='nohover' title='$label'>"; |
|
177 |
print qq|<tr><td class="bg" height="24" align="left" valign="middle">$anchor$image$label</a></td></tr>\n|; |
|
178 |
|
|
179 |
§ion_menu($menu, $item); |
|
186 |
if ($menu->{$item}{module}) { |
|
187 |
if ($form->{$item} && $form->{level} eq $item) { |
|
188 |
$menu->{$item}{$item} = !$form->{$item}; |
|
189 |
if ($zeige) { |
|
190 |
|
|
191 |
qq|<tr><td valign=bottom>$spacer<img src="image/unterpunkt.png">| |
|
192 |
. $menu->menuitem(\%myconfig, \%$form, $item, $level) |
|
193 |
. qq|$label</a></td></tr>\n|; |
|
194 |
} |
|
195 |
|
|
196 |
# remove same level items |
|
197 |
map { shift @menuorder } grep /^$item/, @menuorder; |
|
198 |
§ion_menu($menu, $item); |
|
199 |
} else { |
|
200 |
if ($zeige) { |
|
201 |
if (scalar @chunks <= 1) { |
|
202 |
|
|
203 |
qq|<tr><td class="hover" height="16" >$spacer| |
|
204 |
. $menu->menuitem(\%myconfig, \%$form, $item, $level) ; |
|
205 |
|
|
206 |
if (-f "image/icons/16x16/$label_icon" && ($is_not_links_browser)) |
|
207 |
|
|
208 |
qq|<img src="image/icons/16x16/$label_icon" border="0" style="vertical-align:text-top" title="| |
|
209 |
. $label |
|
210 |
. qq|"> | } |
|
211 |
else { |
|
212 |
if ($is_not_links_browser) { |
|
213 |
print qq|<img src="image/unterpunkt.png" border="0" style="vertical-align:text-top">|; |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
217 |
|
|
218 |
qq|$label</a></td></tr>\n|; |
|
219 |
} else { |
|
220 |
my $tmpitem = $menu->menuitem(\%myconfig, \%$form, $item, $level); |
|
221 |
|
|
222 |
qq|<tr><td class="hover" height="16" >$spacer<img src="image/unterpunkt.png" style="vertical-align:text-top">| |
|
223 |
. $tmpitem |
|
224 |
. qq|$chunks[0]</a></td></tr>\n|; |
|
225 |
map { |
|
226 |
|
|
227 |
qq|<tr style="vertical-align:top""><td class="hover">$spacer<img src="image/unterpunkt.png" style="visibility:hidden; width:24; height=2;">| |
|
228 |
. $tmpitem |
|
229 |
. qq|$chunks[$_]</a></td></tr>\n|; |
|
230 |
} 1..$#chunks; |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
} else { |
|
235 |
my $ml_ = $form->escape($ml); |
|
236 |
|
|
237 |
qq|<tr><td class="bg" height="24" align="left" valign="middle"> |
|
238 |
<a href="menu.pl?action=acc_menu&level=$ml_" class="nohover" title="$label">|; |
|
239 |
if ($is_not_links_browser) { |
|
240 |
print qq|<img src="image/icons/24x24/$item.png" border="0" style="vertical-align:middle" title="$label">|; |
|
241 |
} |
|
242 |
print qq| $label</a> </td></tr>\n|; |
|
243 |
§ion_menu($menu, $item); |
|
244 |
|
|
245 |
print qq|\n|; |
|
246 |
} |
|
180 | 247 |
} |
181 | 248 |
} |
182 |
$::lxdebug->leave_sub;
|
|
249 |
$main::lxdebug->leave_sub();
|
|
183 | 250 |
} |
184 | 251 |
|
185 | 252 |
sub _calc_framesize { |
... | ... | |
192 | 259 |
: 200; |
193 | 260 |
} |
194 | 261 |
|
195 |
sub _show_images { |
|
196 |
# don't show images in links |
|
197 |
_calc_framesize() != 240; |
|
198 |
} |
|
199 |
|
|
200 |
sub make_image { |
|
201 |
my (%params) = @_; |
|
202 |
|
|
203 |
my $label = $params{label}; |
|
204 |
my $icon = $params{icon}; |
|
205 |
my $hidden = $params{hidden}; |
|
206 |
my $size = $params{size} || 16; |
|
207 |
my $valign = $params{valign} || 'text-top'; |
|
208 |
|
|
209 |
return unless _show_images(); |
|
210 |
|
|
211 |
my $icon_found = $icon && -f _icon_path($icon, $size); |
|
212 |
|
|
213 |
my $image_url = $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png"; |
|
214 |
my $style = $hidden ? "visibility:hidden" : "vertical-align:$valign"; |
|
215 |
my $width = $hidden ? "width='$size'" : ''; |
|
216 |
|
|
217 |
my $padding = $size == 16 && $icon_found || $hidden ? $nbsp x 2 |
|
218 |
: $size == 24 ? $nbsp |
|
219 |
: ''; |
|
220 |
|
|
221 |
return "<img src='$image_url' border='0' style='$style' title='$label' $width>$padding"; |
|
222 |
} |
|
223 |
|
|
224 |
sub _icon_path { |
|
225 |
my ($label, $size) = @_; |
|
226 |
|
|
227 |
$size ||= 16; |
|
228 |
|
|
229 |
return "image/icons/${size}x${size}/$label"; |
|
230 |
} |
|
231 |
|
|
232 | 262 |
1; |
233 | 263 |
|
234 | 264 |
__END__ |
Auch abrufbar als: Unified diff
Revert "Menü refactored damit keine Icons verloren gehen."
This reverts commit 25b37b7f3ab68650c1d8898b534cac5bdd64c7e5.