kivitendo/bin/mozilla/menu.pl @ 48c946bd
d319704a | Moritz Bunkus | #=====================================================================
|
||
# LX-Office ERP
|
||||
# Copyright (C) 2004
|
||||
# Based on SQL-Ledger Version 2.1.9
|
||||
# Web http://www.lx-office.org
|
||||
#
|
||||
######################################################################
|
||||
# SQL-Ledger Accounting
|
||||
# Copyright (c) 1998-2002
|
||||
#
|
||||
# Author: Dieter Simader
|
||||
# Email: dsimader@sql-ledger.org
|
||||
# Web: http://www.sql-ledger.org
|
||||
#
|
||||
# Contributors: Christopher Browne
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#######################################################################
|
||||
#
|
||||
08b6539d | Sven Donath | # the frame layout with refractured menu
|
||
d319704a | Moritz Bunkus | #
|
||
# CHANGE LOG:
|
||||
# DS. 2002-03-25 Created
|
||||
# 2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de>
|
||||
da80eb32 | Sven Donath | # 2010-08-19 - Icons for sub entries and single click behavior, unlike XUL-Menu
|
||
08b6539d | Sven Donath | # JS switchable HTML-menu - Sven Donath <lxo@dexo.de>
|
||
d319704a | Moritz Bunkus | #######################################################################
|
||
3289bcb2 | Sven Schöling | use strict;
|
||
d319704a | Moritz Bunkus | use SL::Menu;
|
||
54e4131e | Moritz Bunkus | use Data::Dumper;
|
||
f2078516 | Sven Schöling | use URI;
|
||
d319704a | Moritz Bunkus | |||
3289bcb2 | Sven Schöling | my $menufile = "menu.ini";
|
||
9f4b866c | Sven Schöling | my $mainlevel;
|
||
d319704a | Moritz Bunkus | # end of main
|
||
sub display {
|
||||
9f4b866c | Sven Schöling | $main::lxdebug->enter_sub();
|
||
da80eb32 | Sven Donath | my $form = $main::form;
|
||
d319704a | Moritz Bunkus | |||
da80eb32 | Sven Donath | my $callback = $form->unescape($form->{callback});
|
||
$callback = URI->new($callback)->rel($callback) if $callback;
|
||||
$callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/;
|
||||
my $framesize = _calc_framesize();
|
||||
40255f36 | Sven Schöling | |||
d319704a | Moritz Bunkus | $form->header;
|
||
print qq|
|
||||
54e4131e | Moritz Bunkus | <frameset rows="28px,*" cols="*" framespacing="0" frameborder="0">
|
||
8c7e4493 | Moritz Bunkus | <frame src="kopf.pl" name="kopf" scrolling="NO">
|
||
08b6539d | Sven Donath | <frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" id="menuframe" name="menuframe">
|
||
8c7e4493 | Moritz Bunkus | <frame src="$form->{script}?action=acc_menu" name="acc_menu" scrolling="auto" noresize marginwidth="0">
|
||
f2078516 | Sven Schöling | <frame src="$callback" name="main_window" scrolling="auto">
|
||
d319704a | Moritz Bunkus | </frameset>
|
||
<noframes>
|
||||
You need a browser that can read frames to see this page.
|
||||
</noframes>
|
||||
</frameset>
|
||||
</HTML>
|
||||
|;
|
||||
9f4b866c | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|
||
sub acc_menu {
|
||||
9f4b866c | Sven Schöling | $main::lxdebug->enter_sub();
|
||
3289bcb2 | Sven Schöling | my $form = $main::form;
|
||
my $locale = $main::locale;
|
||||
da80eb32 | Sven Donath | my $framesize = _calc_framesize();
|
||
9f4b866c | Sven Schöling | |||
d319704a | Moritz Bunkus | $mainlevel = $form->{level};
|
||
5cf977e5 | Moritz Bunkus | $mainlevel =~ s/\Q$mainlevel\E--//g;
|
||
1bb4746a | Sven Schöling | my $menu = Menu->new($::menufile);
|
||
d319704a | Moritz Bunkus | |||
ad27efa6 | Sven Donath | $form->{title} = $locale->text('Lx-Office');
|
||
d319704a | Moritz Bunkus | |||
$form->header;
|
||||
print qq|
|
||||
<body class="menu">
|
||||
da80eb32 | Sven Donath | |||
|;
|
||||
d319704a | Moritz Bunkus | print qq|<div align="left">\n<table width="|
|
||
da80eb32 | Sven Donath | . ($framesize-2)
|
||
ad27efa6 | Sven Donath | . qq|" border="0">\n|;
|
||
d319704a | Moritz Bunkus | |||
§ion_menu($menu);
|
||||
print qq|</table></div>|;
|
||||
print qq|
|
||||
</body>
|
||||
</html>
|
||||
|;
|
||||
9f4b866c | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|
||
sub section_menu {
|
||||
9f4b866c | Sven Schöling | $main::lxdebug->enter_sub();
|
||
d319704a | Moritz Bunkus | my ($menu, $level) = @_;
|
||
da80eb32 | Sven Donath | my $form = $main::form;
|
||
my %myconfig = %main::myconfig;
|
||||
my $locale = $main::locale;
|
||||
my $is_links_browser = 1;
|
||||
if ( _calc_framesize() eq 240) { $is_links_browser = 0; }
|
||||
9f4b866c | Sven Schöling | |||
my $zeige;
|
||||
d319704a | Moritz Bunkus | # build tiered menus
|
||
my @menuorder = $menu->access_control(\%myconfig, $level);
|
||||
while (@menuorder) {
|
||||
9f4b866c | Sven Schöling | my $item = shift @menuorder;
|
||
my $label = $item;
|
||||
my $ml = $item;
|
||||
5cf977e5 | Moritz Bunkus | $label =~ s/\Q$level\E--//g;
|
||
d319704a | Moritz Bunkus | $ml =~ s/--.*//;
|
||
if ($ml eq $mainlevel) { $zeige = 1; }
|
||||
else { $zeige = 0; }
|
||||
ad27efa6 | Sven Donath | my $spacer = " " x (($item =~ s/--/--/g) * 2);
|
||
d319704a | Moritz Bunkus | $label =~ s/.*--//g;
|
||
ad27efa6 | Sven Donath | my $label_icon = $level . "--" . $label . ".png";
|
||
9f4b866c | Sven Schöling | my $mlab = $label;
|
||
d319704a | Moritz Bunkus | $label = $locale->text($label);
|
||
40255f36 | Sven Schöling | |||
54e4131e | Moritz Bunkus | # multi line hack, sschoeling jul06
|
||
40255f36 | Sven Schöling | # if a label is too long, try to split it at whitespaces, then join it to chunks of less
|
||
54e4131e | Moritz Bunkus | # than 20 chars and store it in an array.
|
||
# use this array later instead of the -ed label
|
||||
9f4b866c | Sven Schöling | my @chunks = ();
|
||
d0810c42 | Sven Schöling | my ($i,$l) = (-1, 20);
|
||
54e4131e | Moritz Bunkus | map {
|
||
d0810c42 | Sven Schöling | if (($l += length $_) < 20) {
|
||
$chunks[$i] .= " $_";
|
||||
40255f36 | Sven Schöling | } else {
|
||
$l = length $_;
|
||||
$chunks[++$i] = $_;
|
||||
d0810c42 | Sven Schöling | }
|
||
54e4131e | Moritz Bunkus | } split / /, $label;
|
||
d0810c42 | Sven Schöling | map { s/ / / } @chunks;
|
||
54e4131e | Moritz Bunkus | # end multi line
|
||
d319704a | Moritz Bunkus | $label =~ s/ / /g;
|
||
$menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
|
||||
if ($menu->{$item}{submenu}) {
|
||||
$menu->{$item}{$item} = !$form->{$item};
|
||||
5cf977e5 | Moritz Bunkus | if ($form->{level} && $item =~ /^\Q$form->{level}\E/) {
|
||
d319704a | Moritz Bunkus | |||
# expand menu
|
||||
if ($zeige) {
|
||||
print
|
||||
20310b7f | Sven Schöling | qq|<tr><td style='vertical-align:bottom'><b>$spacer<img src="image/unterpunkt.png">$label</b></td></tr>\n|;
|
||
d319704a | Moritz Bunkus | }
|
||
# remove same level items
|
||||
map { shift @menuorder } grep /^$item/, @menuorder;
|
||||
§ion_menu($menu, $item);
|
||||
} else {
|
||||
if ($zeige) {
|
||||
print qq|<tr><td>|
|
||||
. $menu->menuitem(\%myconfig, \%$form, $item, $level)
|
||||
. qq|$label ...</a></td></tr>\n|;
|
||||
}
|
||||
# remove same level items
|
||||
map { shift @menuorder } grep /^$item/, @menuorder;
|
||||
}
|
||||
} else {
|
||||
if ($menu->{$item}{module}) {
|
||||
if ($form->{$item} && $form->{level} eq $item) {
|
||||
$menu->{$item}{$item} = !$form->{$item};
|
||||
if ($zeige) {
|
||||
print
|
||||
qq|<tr><td valign=bottom>$spacer<img src="image/unterpunkt.png">|
|
||||
. $menu->menuitem(\%myconfig, \%$form, $item, $level)
|
||||
. qq|$label</a></td></tr>\n|;
|
||||
}
|
||||
# remove same level items
|
||||
map { shift @menuorder } grep /^$item/, @menuorder;
|
||||
§ion_menu($menu, $item);
|
||||
} else {
|
||||
if ($zeige) {
|
||||
54e4131e | Moritz Bunkus | if (scalar @chunks <= 1) {
|
||
print
|
||||
da80eb32 | Sven Donath | qq|<tr><td class="hover" height="16" >$spacer|
|
||
ad27efa6 | Sven Donath | . $menu->menuitem(\%myconfig, \%$form, $item, $level) ;
|
||
da80eb32 | Sven Donath | |||
if (-f "image/icons/16x16/$label_icon" && ($is_links_browser))
|
||||
{ print
|
||||
qq|<img src="image/icons/16x16/$label_icon" border="0" style="vertical-align:text-top" title="|
|
||||
. $label
|
||||
. qq|"> | }
|
||||
ad27efa6 | Sven Donath | else {
|
||
da80eb32 | Sven Donath | if ($is_links_browser) {
|
||
print qq|<img src="image/unterpunkt.png" border="0" style="vertical-align:text-top">|;
|
||||
}
|
||||
ab8a26e3 | Sven Donath | }
|
||
da80eb32 | Sven Donath | |||
ad27efa6 | Sven Donath | print
|
||
qq|$label</a></td></tr>\n|;
|
||||
54e4131e | Moritz Bunkus | } else {
|
||
my $tmpitem = $menu->menuitem(\%myconfig, \%$form, $item, $level);
|
||||
print
|
||||
ad27efa6 | Sven Donath | qq|<tr><td class="hover" height="16" >$spacer<img src="image/unterpunkt.png" style="vertical-align:text-top">|
|
||
54e4131e | Moritz Bunkus | . $tmpitem
|
||
. qq|$chunks[0]</a></td></tr>\n|;
|
||||
map {
|
||||
print
|
||||
ad27efa6 | Sven Donath | qq|<tr style="vertical-align:top""><td class="hover">$spacer<img src="image/unterpunkt.png" style="visibility:hidden; width:24; height=2;">|
|
||
54e4131e | Moritz Bunkus | . $tmpitem
|
||
. qq|$chunks[$_]</a></td></tr>\n|;
|
||||
} 1..$#chunks;
|
||||
}
|
||||
d319704a | Moritz Bunkus | }
|
||
}
|
||||
} else {
|
||||
my $ml_ = $form->escape($ml);
|
||||
print
|
||||
da80eb32 | Sven Donath | qq|<tr><td class="bg" height="24" align="left" valign="middle">
|
||
<a href="menu.pl?action=acc_menu&level=$ml_" class="nohover" title="$label">|;
|
||||
if ($is_links_browser) {
|
||||
print qq|<img src="image/icons/24x24/$item.png" border="0" style="vertical-align:middle" title="$label">|;
|
||||
}
|
||||
print qq| $label</a> </td></tr>\n|;
|
||||
d319704a | Moritz Bunkus | §ion_menu($menu, $item);
|
||
ad27efa6 | Sven Donath | print qq|\n|;
|
||
d319704a | Moritz Bunkus | }
|
||
}
|
||||
}
|
||||
9f4b866c | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|
||
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 | }
|
||
1;
|
||||
__END__
|