Fenster und Tabtitle im XUL Menü gefixt.
[kivitendo-erp.git] / bin / mozilla / menuXML.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 # three frame layout with refractured menu
32 #
33 # CHANGE LOG:
34 #   DS. 2002-03-25  Created
35 #  2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de>
36 #  2007-10-14 - XMLified  - Holger Will  <holger@treebuilder.de>
37 #######################################################################
38
39 $menufile = "menu.ini";
40 use SL::Menu;
41
42 use CGI::Carp qw(fatalsToBrowser);
43 use Encode;
44 1;
45
46 # end of main
47
48 sub display {
49   $locale     = Locale->new($language, "menu");
50   my $charset = $dbcharset || 'ISO-8859-1';
51   my $callback = $form->unescape($form->{callback}) || "login.pl?action=company_logo";
52
53   my $text    = $form->create_http_response('content_type' => 'text/xml',
54                                             'charset'      => $charset)
55     . qq|<?xml version="1.0" encoding="${charset}"?>
56 <?xml-stylesheet href="xslt/xulmenu.xsl" type="text/xsl"?>
57 <!DOCTYPE doc [
58 <!ENTITY szlig "| . $locale->{iconv_iso8859}->convert('ß') . qq|">
59 <!ENTITY auml "| . $locale->{iconv_iso8859}->convert('ä') . qq|">
60 <!ENTITY ouml "| . $locale->{iconv_iso8859}->convert('ö') . qq|">
61 <!ENTITY uuml "| . $locale->{iconv_iso8859}->convert('ü') . qq|">
62 ]>
63
64 <doc>
65 <name>$myconfig{name}</name>
66 <callback>$callback</callback>
67 <db>$myconfig{dbname}</db>
68
69 <favorites>|;
70
71   my $fav       = $myconfig{favorites};
72   my @favorites = split m/;/, $fav;
73   foreach (@favorites) {
74     $text .= qq|<link name="$_"/>|;
75   }
76
77   $text .= qq|</favorites>\n|
78     . qq|<menu>\n|
79     . acc_menu()
80     . qq|</menu>\n|
81     . qq|</doc>\n|;
82
83   print $text;
84 }
85
86
87 sub acc_menu {
88   $mainlevel = $form->{level};
89   $mainlevel =~ s/$mainlevel--//g;
90   my $menu = new Menu "$menufile";
91
92   $| = 1;
93
94   return print_menu($menu);
95 }
96
97 sub print_menu {
98   my ($menu, $parent, $depth) = @_;
99   my $html;
100
101   die if ($depth * 1 > 5);
102
103   my @menuorder;
104
105   @menuorder = $menu->access_control(\%myconfig, $parent);
106
107   $parent .= "--" if ($parent);
108
109   foreach my $item (@menuorder) {
110     my $menu_item_id = $item;
111     substr($item, 0, length($parent)) = "";
112     next if (($item eq "") || ($item =~ /--/));
113
114     my $menu_item = $menu->{"${parent}${item}"};
115     my $menu_title = $locale->text($item);
116     my $menu_text = $menu_title;
117
118     my $target = "main_window";
119     $target = $menu_item->{"target"} if ($menu_item->{"target"});
120
121     if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) ||
122         ($menu_item->{"module"} eq "menu.pl")) {
123
124       my $h = print_menu($menu, "${parent}${item}", $depth * 1 + 1)."\n";
125       if (!$parent) {
126         $html .= qq|<item name='${menu_text}' id='${menu_item_id}'>${h}</item>\n|;
127       } else {
128         $html .= qq|<item name='${menu_text}' id='${menu_item_id}'>${h}</item>\n|;
129       }
130     } else {
131       $html .= qq|<item |;
132       $html .= $menu->menuitem_XML(\%myconfig, $form, "${parent}$item",
133                                   { "title" => $menu_title,
134                                     "target" => $target });
135       $html .= qq| name="${menu_text}" id='${menu_item_id}'/>\n|;
136     }
137   }
138
139   return $html;
140 }