kivitendo/bin/mozilla/menunew.pl @ ebceac3e
e848dbf1 | Stephan Köhler | #=====================================================================
|
||
# 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.
|
||||
#######################################################################
|
||||
#
|
||||
# thre frame layout with refractured menu
|
||||
#
|
||||
#######################################################################
|
||||
32fa785e | Moritz Bunkus | use English qw(-no_match_vars);
|
||
use List::Util qw(max);
|
||||
e848dbf1 | Stephan Köhler | use SL::Menu;
|
||
1;
|
||||
# end of main
|
||||
sub display {
|
||||
32fa785e | Moritz Bunkus | $form->header();
|
||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | # $form->{force_ul_width} = $ENV{HTTP_USER_AGENT} =~ m/MSIE\s+6\./;
|
||
0f7124b3 | Moritz Bunkus | # $form->{force_ul_width} = $ENV{HTTP_USER_AGENT} !~ m/Opera/;
|
||
$form->{force_ul_width} = 1;
|
||||
32fa785e | Moritz Bunkus | $form->{date} = clock_line();
|
||
$form->{menu_items} = acc_menu();
|
||||
40255f36 | Sven Schöling | $form->{callback} = $form->unescape($form->{callback}) || "login.pl?action=company_logo";
|
||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | print $form->parse_html_template("menu/menunew");
|
||
e848dbf1 | Stephan Köhler | }
|
||
sub clock_line {
|
||||
my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat,
|
||||
$Jahr, $Wochentag, $Jahrestag, $Sommerzeit)
|
||||
= localtime(time);
|
||||
$Monat += 1;
|
||||
$Jahrestag += 1;
|
||||
$Monat = $Monat < 10 ? $Monat = "0" . $Monat : $Monat;
|
||||
$Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag;
|
||||
$Jahr += 1900;
|
||||
my @Wochentage = ("Sonntag", "Montag", "Dienstag", "Mittwoch",
|
||||
"Donnerstag", "Freitag", "Samstag");
|
||||
my @Monatsnamen = ("", "Januar", "Februar", "März",
|
||||
"April", "Mai", "Juni", "Juli",
|
||||
"August", "September", "Oktober", "November",
|
||||
"Dezember");
|
||||
32fa785e | Moritz Bunkus | return
|
||
e848dbf1 | Stephan Köhler | $Wochentage[$Wochentag] . ", der "
|
||
. $Monatstag . "."
|
||||
. $Monat . "."
|
||||
. $Jahr . " - ";
|
||||
}
|
||||
sub acc_menu {
|
||||
32fa785e | Moritz Bunkus | $locale = Locale->new($language, "menu");
|
||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | my $mainlevel = $form->{level};
|
||
$mainlevel =~ s/\Q$mainlevel\E--//g;
|
||||
my $menu = Menu->new('menu.ini');
|
||||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | $AUTOFLUSH = 1;
|
||
836399e0 | Moritz Bunkus | |||
32fa785e | Moritz Bunkus | my $all_items = [];
|
||
create_menu($menu, $all_items);
|
||||
836399e0 | Moritz Bunkus | |||
32fa785e | Moritz Bunkus | my $item = { 'subitems' => $all_items };
|
||
calculate_width($item);
|
||||
d9e39600 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | return $all_items;
|
||
e848dbf1 | Stephan Köhler | }
|
||
32fa785e | Moritz Bunkus | sub calculate_width {
|
||
my $item = shift;
|
||||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | $item->{max_width} = max map { length $_->{title} } @{ $item->{subitems} };
|
||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | foreach my $subitem (@{ $item->{subitems} }) {
|
||
calculate_width($subitem) if ($subitem->{subitems});
|
||||
}
|
||||
e848dbf1 | Stephan Köhler | }
|
||
32fa785e | Moritz Bunkus | sub create_menu {
|
||
my ($menu, $all_items, $parent, $depth) = @_;
|
||||
my $html;
|
||||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | die if ($depth * 1 > 5);
|
||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | my @menuorder = $menu->access_control(\%myconfig, $parent);
|
||
$parent .= "--" if ($parent);
|
||||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | foreach my $name (@menuorder) {
|
||
substr($name, 0, length($parent), "");
|
||||
next if (($name eq "") || ($name =~ /--/));
|
||||
836399e0 | Moritz Bunkus | |||
32fa785e | Moritz Bunkus | my $menu_item = $menu->{"${parent}${name}"};
|
||
my $item = { 'title' => $locale->text($name) };
|
||||
push @{ $all_items }, $item;
|
||||
e848dbf1 | Stephan Köhler | |||
32fa785e | Moritz Bunkus | if ($menu_item->{submenu} || !defined($menu_item->{module}) || ($menu_item->{module} eq "menu.pl")) {
|
||
$item->{subitems} = [];
|
||||
create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1);
|
||||
e848dbf1 | Stephan Köhler | |||
} else {
|
||||
32fa785e | Moritz Bunkus | $menu->menuitem_new("${parent}${name}", $item);
|
||
e848dbf1 | Stephan Köhler | }
|
||
}
|
||||
}
|