From f559ec45ea2fc09c361ef7e4a40a59b1f2133737 Mon Sep 17 00:00:00 2001 From: Holger Will Date: Wed, 31 Oct 2007 17:02:57 +0000 Subject: [PATCH] XML basiertes Menue, siehe Bug #771 --- SL/Menu.pm | 58 +++++ SL/User.pm | 3 +- bin/mozilla/login.pl | 3 + bin/mozilla/menuXML.pl | 140 ++++++++++++ locale/de/menuXML | 11 + menuXML.pl | 1 + templates/webpages/am/config_de.html | 7 + xslt/style1.css | 14 ++ xslt/xulmenu.xsl | 328 +++++++++++++++++++++++++++ 9 files changed, 564 insertions(+), 1 deletion(-) create mode 100644 bin/mozilla/menuXML.pl create mode 100755 locale/de/menuXML create mode 120000 menuXML.pl create mode 100644 xslt/style1.css create mode 100644 xslt/xulmenu.xsl diff --git a/SL/Menu.pm b/SL/Menu.pm index 89a6ffd15..7d07153bc 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -164,6 +164,64 @@ sub menuitem_v3 { return $str; } +sub menuitem_XML { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form, $item, $other) = @_; + + my $module = $form->{script}; + my $action = "section_menu"; + my $target = ""; + + if ($self->{$item}{module}) { + $module = $self->{$item}{module}; + } + if ($self->{$item}{action}) { + $action = $self->{$item}{action}; + } + if ($self->{$item}{target}) { + $target = $self->{$item}{target}; + } + + my $level = $form->escape($item); + + my $str = qq| link="$module?action=| . $form->escape($action) . + qq|&level=| . $form->escape($level); + map({ $str .= "&${_}=" . $form->escape($form->{$_}); } qw(login password)); + + my @vars = qw(module action target href); + + if ($self->{$item}{href}) { + $str = qq| link=$self->{$item}{href}|; + @vars = qw(module target href); + } + + map { delete $self->{$item}{$_} } @vars; + + # add other params + foreach my $key (keys %{ $self->{$item} }) { + $str .= "&" . $form->escape($key, 1) . "="; + ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); + $value = $myconfig->{$value} . "/$conf" if ($conf); + $str .= $form->escape($value, 1); + } + + $str .= '"'; + + + + if ($other) { + foreach my $key (keys(%{$other})) { + $str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|; + } + } + + + $main::lxdebug->leave_sub(); + + return $str; +} + sub menuitemNew { my ($self, $myconfig, $form, $item) = @_; diff --git a/SL/User.pm b/SL/User.pm index 99c531938..13bde36ec 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -224,6 +224,7 @@ sub login { my $menufile = $self->{"menustyle"} eq "v3" ? "menuv3.pl" : $self->{"menustyle"} eq "neu" ? "menunew.pl" : + $self->{"menustyle"} eq "xml" ? "menuXML.pl" : "menu.pl"; print($form->parse_html_template2("dbupgrade/footer", @@ -1106,7 +1107,7 @@ sub config_vars { printer role sid signature stylesheet tel templates vclimit angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen taxnumber co_ustid duns menustyle template_format default_media - default_printer_id copies show_form_details); + default_printer_id copies show_form_details favorites); $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index 72032f3df..7623bff3e 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -156,6 +156,9 @@ sub login { } elsif ($user->{menustyle} eq "neu") { $form->{callback} = "menunew.pl?login=$form->{login}&password=$form->{password}&action=display"; + } elsif ($user->{menustyle} eq "xml") { + $form->{callback} = + "menuXML.pl?login=$form->{login}&password=$form->{password}&action=display"; } else { $form->{callback} = "menu.pl?login=$form->{login}&password=$form->{password}&action=display"; diff --git a/bin/mozilla/menuXML.pl b/bin/mozilla/menuXML.pl new file mode 100644 index 000000000..84fabbb05 --- /dev/null +++ b/bin/mozilla/menuXML.pl @@ -0,0 +1,140 @@ +#===================================================================== +# 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. +####################################################################### +# +# three frame layout with refractured menu +# +# CHANGE LOG: +# DS. 2002-03-25 Created +# 2004-12-14 - New Optik - Marco Welter +# 2007-10-14 - XMLified - Holger Will +####################################################################### + +$menufile = "menu.ini"; +use SL::Menu; + +use CGI::Carp qw(fatalsToBrowser); +use Encode; +1; + +# end of main + +sub display { + print "Content-type: text/xml; charset=iso-8859-1\n\n"; + print qq|\n|; + print qq|\n|; + print qq| +]>|; + print qq||; + print qq||; + print $form->{login}; + print qq||; + print qq||; + print $form->{password}; + print qq||; + print qq||; + print %myconfig->{name}; + print qq||; + print qq||; + print %myconfig->{dbname}; + print qq||; + print qq||; + my $fav=%myconfig->{favorites}; + my @favorites = split(/;/, $fav); + foreach (@favorites) { + print qq||; + } + print qq||; + print qq||; +my $isoencodedmenu=&acc_menu($menu); + print encode("iso-8859-1",$isoencodedmenu ); + + print qq||; + print qq||; + +} + + +sub acc_menu { + $locale = Locale->new($language, "menu"); + + $mainlevel = $form->{level}; + $mainlevel =~ s/$mainlevel--//g; + my $menu = new Menu "$menufile"; + + $| = 1; + + return print_menu($menu); +} + +sub print_menu { + my ($menu, $parent, $depth) = @_; + my $html; + + die if ($depth * 1 > 5); + + my @menuorder; + + @menuorder = $menu->access_control(\%myconfig, $parent); + + $parent .= "--" if ($parent); + + foreach my $item (@menuorder) { + my $menu_item_id = $item; + substr($item, 0, length($parent)) = ""; + next if (($item eq "") || ($item =~ /--/)); + + my $menu_item = $menu->{"${parent}${item}"}; + my $menu_title = $locale->text($item); + my $menu_text = $menu_title; + + my $target = "main_window"; + $target = $menu_item->{"target"} if ($menu_item->{"target"}); + + if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) || + ($menu_item->{"module"} eq "menu.pl")) { + + my $h = print_menu($menu, "${parent}${item}", $depth * 1 + 1)."\n"; + if (!$parent) { + $html .= qq|${h}\n|; + } else { + $html .= qq|${h}\n|; + } + } else { + $html .= qq|menuitem_XML(\%myconfig, $form, "${parent}$item", + { "title" => $menu_title, + "target" => $target }); + $html .= qq| name="${menu_text}" id='${menu_item_id}'/>\n|; + } + } + + return $html; +} diff --git a/locale/de/menuXML b/locale/de/menuXML new file mode 100755 index 000000000..821b8ec59 --- /dev/null +++ b/locale/de/menuXML @@ -0,0 +1,11 @@ +$self->{texts} = { +}; + +$self->{subs} = { + 'acc_menu' => 'acc_menu', + 'clock_line' => 'clock_line', + 'display' => 'display', + 'print_menu' => 'print_menu', +}; + +1; diff --git a/menuXML.pl b/menuXML.pl new file mode 120000 index 000000000..385000d1b --- /dev/null +++ b/menuXML.pl @@ -0,0 +1 @@ +am.pl \ No newline at end of file diff --git a/templates/webpages/am/config_de.html b/templates/webpages/am/config_de.html index edfcccfa4..052204cda 100644 --- a/templates/webpages/am/config_de.html +++ b/templates/webpages/am/config_de.html @@ -106,9 +106,16 @@   +   + + + Favoriten + + + Formulardetails (zweite Positionszeile) diff --git a/xslt/style1.css b/xslt/style1.css new file mode 100644 index 000000000..81517d2c7 --- /dev/null +++ b/xslt/style1.css @@ -0,0 +1,14 @@ +treechildren::-moz-tree-row(hover){background-color:#eef !important;} +tree{-moz-appearance: none !important;border:0px solid black !important;padding-top:2px;background: white} +treechildren::-moz-tree-column{background: white} + +toolbar{-moz-appearance: none !important;background:lavender !important;border-bottom:1px solid black;border-top:1px solid black;} +menubar{-moz-appearance: none !important;background:darkblue !important;border:0px} +splitter{-moz-appearance: none !important;background:lavender !important;border:0px solid black !important} +iframe{border-left:1px solid black !important} +#sidebar{background:grey;max-width:450px;width:150px;font-family:arial;font-size:12px;margin:0px;border-right:1px solid black} +menubar menu{-moz-appearance: none !important;color:white !important;} +menubar menu:hover{-moz-appearance: none;background:lightblue !important} +menu menu{-moz-appearance: none !important;color:black !important;} +menu menu:hover{-moz-appearance: none;background:lightgrey !important} +toolbarbutton{padding:5px !important;margin:2px !important} \ No newline at end of file diff --git a/xslt/xulmenu.xsl b/xslt/xulmenu.xsl new file mode 100644 index 000000000..3a7df20b0 --- /dev/null +++ b/xslt/xulmenu.xsl @@ -0,0 +1,328 @@ + + + + + + + + + +href="xslt/style1.css" type="text/css" + + + LX-Office Version + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + function openLink(event) + { + var path=event.target.getAttribute("link") + if(event.target.getAttribute("target")=="_top") + { + window.location=path + } + else + { + var bf=document.getElementsByTagName("iframe").item(0) + bf.setAttribute("src",path) + } + } + + function openLinkNewTab(event) + { + if(event.button!=1) return + var path=event.target.getAttribute("link") + if(event.target.getAttribute("target")=="_top") + { + window.location=path + } + else + { +window.open(path,"_new","") + + } + } + + + function openLinkNewWindow(event) + { + var path=event.target.getAttribute("link") + window.open(path,"_new","") + } + + function openTreeLink(event) + { + var tree=event.target + var selIndex=tree.currentIndex + var item=tree.view.getItemAtIndex(selIndex) + var link=item.getAttribute("link") + if(link) document.getElementById("main_window").setAttribute("src",link) + } + + function updateClock() + { + var d= new Date() + var sec=d.getSeconds() + var min=d.getMinutes() + var std=(d.getHours() % 12 ) + min/60 + document.getElementById("std").setAttribute("transform","rotate("+std*30+",20,20)") + document.getElementById("min").setAttribute("transform","rotate("+min*6+",20,20)") + document.getElementById("sec").setAttribute("transform","rotate("+sec*6+",20,20)") + } + + function PrintW() + { + document.getElementById("main_window").contentWindow.print() + } + + function doSearch(){ + var t=document.getElementById("searchboxtext").value + document.getElementById("desc").value=t + document.getElementById("sb").click() + + } + function checkEnter(event){ + if(event.keyCode==13) doSearch() + } + //setInterval("updateClock()",1000) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.20.1