Fenster und Tabtitle im XUL MenĂ¼ gefixt.
[kivitendo-erp.git] / bin / mozilla / menuv4.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 ######################################################################
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #  Contributors: Christopher Browne
16 #
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #######################################################################
30 #
31 # thre frame layout with refractured menu
32 #
33 #######################################################################
34
35 $menufile = "menu.ini";
36 use SL::Menu;
37
38 1;
39
40 # end of main
41
42 sub display {
43   $form->header(qq|<link rel="stylesheet" href="css/menuv4.css?id=" type="text/css">|);
44
45   $form->{date}     = clock_line();
46   $form->{menu}     = acc_menu();
47   $form->{callback} = $form->unescape($form->{callback}) || "login.pl?action=company_logo";
48
49   print $form->parse_html_template("menu/menuv4");
50
51 }
52
53 sub clock_line {
54   my ($Sekunden, $Minuten,   $Stunden,   $Monatstag, $Monat,
55       $Jahr,     $Wochentag, $Jahrestag, $Sommerzeit)
56     = localtime(time);
57   $Monat     += 1;
58   $Jahrestag += 1;
59   $Monat     = $Monat < 10     ? $Monat     = "0" . $Monat     : $Monat;
60   $Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag;
61   $Jahr += 1900;
62   my @Wochentage = ("Sonntag",    "Montag",  "Dienstag", "Mittwoch",
63                     "Donnerstag", "Freitag", "Samstag");
64   my @Monatsnamen = ("",       "Januar",    "Februar", "M&auml;rz",
65                      "April",  "Mai",       "Juni",    "Juli",
66                      "August", "September", "Oktober", "November",
67                      "Dezember");
68   return
69       $Wochentage[$Wochentag] . ", der "
70     . $Monatstag . "."
71     . $Monat . "."
72     . $Jahr . " - ";
73 }
74
75 sub acc_menu {
76   $locale = Locale->new($language, "menu");
77
78   $mainlevel = $form->{level};
79   $mainlevel =~ s/\Q$mainlevel\E--//g;
80   my $menu = new Menu "$menufile";
81
82   $| = 1;
83
84   return print_menu($menu);
85 }
86
87 sub print_menu {
88   my ($menu, $parent, $depth) = @_;
89   my $html;
90
91   die if ($depth * 1 > 5);
92
93   my @menuorder;
94
95   @menuorder = $menu->access_control(\%myconfig, $parent);
96
97   $parent .= "--" if ($parent);
98
99   foreach my $item (@menuorder) {
100     substr($item, 0, length($parent)) = "";
101     next if (($item eq "") || ($item =~ /--/));
102
103     my $menu_item = $menu->{"${parent}${item}"};
104     my $menu_title = $locale->text($item);
105     my $menu_text = $menu_title;
106
107     my $target = "main_window";
108     $target = $menu_item->{"target"} if ($menu_item->{"target"});
109
110     if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) ||
111         ($menu_item->{"module"} eq "menu.pl")) {
112
113       my $h = print_menu($menu, "${parent}${item}", $depth * 1 + 1)."\n";
114       if (!$parent) {
115         $html .= qq|<ul><li><h2>${menu_text}</h2><ul>${h}</ul></li></ul>\n|;
116       } else {
117         $html .= qq|<li><div class="x">${menu_text}</div><ul>${h}</ul></li>\n|;
118       }
119     } else {
120       if ($depth>1) {
121       $html .= qq|<li class='sub'>|;
122       } else {
123       $html .= qq|<li>|;
124       }
125       $html .= $menu->menuitem_v3(\%myconfig, $form, "${parent}$item",
126                                   { "title" => $menu_title,
127                                     "target" => $target });
128       $html .= qq|${menu_text}</a></li>\n|;
129     }
130   }
131
132   return $html;
133 }