From 4a12c839937370488b8b8a40bef376e7cb0a2ce6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 17 Oct 2012 15:57:45 +0200 Subject: [PATCH] =?utf8?q?Layouts=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit bin/mozilla/menu* -> SL/Controller/Layout/* --- SL/Controller/Layout.pm | 24 + SL/Controller/Layout/Base.pm | 45 ++ SL/Controller/Layout/Classic.pm | 43 ++ SL/Controller/Layout/Css.pm | 127 +++++ .../Controller/Layout/Javascript.pm | 87 ++-- .../Controller/Layout/MenuLeft.pm | 62 +-- SL/Controller/Layout/None.pm | 6 + SL/Controller/Layout/Top.pm | 19 + SL/Controller/Layout/V3.pm | 36 ++ SL/Controller/Layout/V4.pm | 52 ++ SL/Controller/LoginScreen.pm | 1 + SL/Dispatcher.pm | 6 +- SL/Dispatcher/AuthHandler.pm | 3 +- SL/Dispatcher/AuthHandler/Admin.pm | 5 +- SL/Dispatcher/AuthHandler/User.pm | 4 +- SL/Form.pm | 43 +- SL/Menu.pm | 153 ------ bin/mozilla/menujs.pl | 446 ------------------ bin/mozilla/menuv3.pl | 141 ------ bin/mozilla/menuv4.pl | 147 ------ css/lx-office-erp/frame_header/header.css | 1 - css/lx-office-erp/menu.css | 5 +- templates/webpages/menu/menunew.html | 41 +- templates/webpages/menu/menuv3.html | 11 +- templates/webpages/menu/menuv4.html | 18 - 25 files changed, 455 insertions(+), 1071 deletions(-) create mode 100644 SL/Controller/Layout.pm create mode 100644 SL/Controller/Layout/Base.pm create mode 100644 SL/Controller/Layout/Classic.pm create mode 100644 SL/Controller/Layout/Css.pm rename bin/mozilla/menunew.pl => SL/Controller/Layout/Javascript.pm (54%) rename bin/mozilla/menu.pl => SL/Controller/Layout/MenuLeft.pm (57%) create mode 100644 SL/Controller/Layout/None.pm create mode 100644 SL/Controller/Layout/Top.pm create mode 100644 SL/Controller/Layout/V3.pm create mode 100644 SL/Controller/Layout/V4.pm delete mode 100644 bin/mozilla/menujs.pl delete mode 100644 bin/mozilla/menuv3.pl delete mode 100644 bin/mozilla/menuv4.pl diff --git a/SL/Controller/Layout.pm b/SL/Controller/Layout.pm new file mode 100644 index 000000000..5c33b1743 --- /dev/null +++ b/SL/Controller/Layout.pm @@ -0,0 +1,24 @@ +package SL::Controller::Layout; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::Menu; +use SL::Controller::Layout::Classic; +use SL::Controller::Layout::V3; +use SL::Controller::Layout::V4; +use SL::Controller::Layout::Javascript; + +my %menu_cache; + +sub new { + my ($class, %params) = @_; + + return SL::Controller::Layout::Classic->new if $params{style} eq 'old'; + return SL::Controller::Layout::V3->new if $params{style} eq 'v3'; + return SL::Controller::Layout::V4->new if $params{style} eq 'v4'; + return SL::Controller::Layout::Javascript->new if $params{style} eq 'neu'; + return SL::Controller::Layout::None->new; +} + +1; diff --git a/SL/Controller/Layout/Base.pm b/SL/Controller/Layout/Base.pm new file mode 100644 index 000000000..cbd5088d3 --- /dev/null +++ b/SL/Controller/Layout/Base.pm @@ -0,0 +1,45 @@ +package SL::Controller::Layout::Base; + +use strict; +use parent qw(SL::Controller::Base); + +use Rose::Object::MakeMethods::Generic ( + 'scalar --get_set_init' => qw(menu), +); + +use SL::Menu; + +my %menu_cache; + +sub new { + my ($class, @slurp) = @_; + + my $self = $class->SUPER::new(@slurp); +} + +sub init_menu { + Menu->new('menu.ini'); +} + +sub pre_content { +} + +sub start_content { +} + +sub end_content { +} + +sub post_content { +} + +sub stylesheets { +} + +sub stylesheets_inline { +} + +sub javascript_inline { +} + +1; diff --git a/SL/Controller/Layout/Classic.pm b/SL/Controller/Layout/Classic.pm new file mode 100644 index 000000000..514db7947 --- /dev/null +++ b/SL/Controller/Layout/Classic.pm @@ -0,0 +1,43 @@ +package SL::Controller::Layout::Classic; + +use strict; +use parent qw(SL::Controller::Layout::Base); + +use SL::Controller::Layout::Top; +use SL::Controller::Layout::MenuLeft; + +sub new { + my ($class, @slurp) = @_; + + my $self = $class->SUPER::new(@slurp); + + $self->{top} = SL::Controller::Layout::Top->new; + $self->{left} = SL::Controller::Layout::MenuLeft->new; + + $self; +} + +sub pre_content { + $_[0]{top}->render . + $_[0]{left}->render; +} + +sub start_content { + "
\n"; +} + +sub end_content { + "
\n"; +} + +sub stylesheets { + $_[0]{top}->stylesheets, + $_[0]{left}->stylesheets; +} + +sub javascripts { + $_[0]{top}->javascripts, + $_[0]{left}->javascripts; +} + +1; diff --git a/SL/Controller/Layout/Css.pm b/SL/Controller/Layout/Css.pm new file mode 100644 index 000000000..a50f56407 --- /dev/null +++ b/SL/Controller/Layout/Css.pm @@ -0,0 +1,127 @@ +package SL::Controller::Layout::Css; + +use List::Util qw(max); +use Exporter qw(import); + +our @EXPORT = qw(clock_line print_menu menuitem_v3); + +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"); + return + $Wochentage[$Wochentag] . ", der " + . $Monatstag . "." + . $Monat . "." + . $Jahr . " - "; +} + +sub print_menu { + my ($self, $parent, $depth) = @_; + + my $html; + + die if ($depth * 1 > 5); + + my @menuorder; + my $menu = $self->menu; + + @menuorder = $menu->access_control(\%::myconfig, $parent); + + $parent .= "--" if ($parent); + + foreach my $item (@menuorder) { + 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; + + if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) || + ($menu_item->{"module"} eq "menu.pl")) { + + my $h = $self->print_menu("${parent}${item}", $depth * 1 + 1)."\n"; + if (!$parent) { + $html .= qq|\n|; + } else { + $html .= qq|
  • ${menu_text}
  • \n|; + } + } else { + if ($self->{sub_class} && $depth > 1) { + $html .= qq|
  • |; + } else { + $html .= qq|
  • |; + } + $html .= $self->menuitem_v3("${parent}$item", { "title" => $menu_title }); + $html .= qq|${menu_text}
  • \n|; + } + } + + return $html; +} + +sub menuitem_v3 { + $main::lxdebug->enter_sub(); + + my ($self, $item, $other) = @_; + my $menuitem = $self->menu->{$item}; + + my $action = "section_menu"; + my $module; + + if ($menuitem->{module}) { + $module = $menuitem->{module}; + } + if ($menuitem->{action}) { + $action = $menuitem->{action}; + } + + my $level = $::form->escape($item); + + my $str = qq|escape($key, 1) . "="; + my ($value, $conf) = split(/=/, $menuitem->{$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|"|; + } + } + + $str .= ">"; + + $main::lxdebug->leave_sub(); + + return $str; +} + +1; diff --git a/bin/mozilla/menunew.pl b/SL/Controller/Layout/Javascript.pm similarity index 54% rename from bin/mozilla/menunew.pl rename to SL/Controller/Layout/Javascript.pm index a1f9a8f2d..590c53e22 100644 --- a/bin/mozilla/menunew.pl +++ b/SL/Controller/Layout/Javascript.pm @@ -1,65 +1,38 @@ -#===================================================================== -# 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 -# -####################################################################### - -use English qw(-no_match_vars); +package SL::Controller::Layout::Javascript; + +use strict; +use parent qw(SL::Controller::Layout::Base); + use List::Util qw(max); use URI; -use SL::Menu; - -use strict; +sub pre_content { + &display +} -1; +sub start_content { + "
    \n"; +} -# end of main +sub end_content { + "
    \n"; +} sub display { + my ($self) = @_; my $form = $main::form; - $form->header(); - -# $form->{force_ul_width} = $ENV{HTTP_USER_AGENT} =~ m/MSIE\s+6\./; -# $form->{force_ul_width} = $ENV{HTTP_USER_AGENT} !~ m/Opera/; - $form->{force_ul_width} = 1; - $form->{date} = clock_line(); - $form->{menu_items} = acc_menu(); my $callback = $form->unescape($form->{callback}); $callback = URI->new($callback)->rel($callback) if $callback; $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; - $form->{callback} = $callback; - print $form->parse_html_template("menu/menunew"); + $form->parse_html_template("menu/menunew", { +# $self->render("menu/menunew", { no_menu => 1, no_output => 1 }, # buggy, no idea why + force_ul_width => 1, + date => $self->clock_line, + menu_items => $self->acc_menu, + callback => $callback, + }); } sub clock_line { @@ -87,17 +60,12 @@ sub clock_line { } sub acc_menu { - my $form = $main::form; - my %myconfig = %main::myconfig; - - my $mainlevel = $form->{level}; - $mainlevel =~ s/\Q$mainlevel\E--//g; - my $menu = Menu->new('menu.ini'); + my ($self) = @_; - $English::AUTOFLUSH = 1; + my $menu = $self->menu; my $all_items = []; - create_menu($menu, $all_items); + $self->create_menu($menu, $all_items); my $item = { 'subitems' => $all_items }; calculate_width($item); @@ -116,7 +84,7 @@ sub calculate_width { } sub create_menu { - my ($menu, $all_items, $parent, $depth) = @_; + my ($self, $menu, $all_items, $parent, $depth) = @_; my $html; my $form = $main::form; @@ -138,7 +106,7 @@ sub create_menu { if ($menu_item->{submenu} || !defined($menu_item->{module}) || ($menu_item->{module} eq "menu.pl")) { $item->{subitems} = []; $item->{image} = _icon_path("$name.png"); - create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1); + $self->create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1); } else { $item->{image} = _icon_path("${parent}${name}.png"); @@ -158,3 +126,4 @@ sub _icon_path { return $img; } +1; diff --git a/bin/mozilla/menu.pl b/SL/Controller/Layout/MenuLeft.pm similarity index 57% rename from bin/mozilla/menu.pl rename to SL/Controller/Layout/MenuLeft.pm index 7e280ffd5..c79905269 100644 --- a/bin/mozilla/menu.pl +++ b/SL/Controller/Layout/MenuLeft.pm @@ -1,63 +1,23 @@ -#===================================================================== -# 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. -####################################################################### -# -# the frame layout with refractured menu -# -# CHANGE LOG: -# DS. 2002-03-25 Created -# 2004-12-14 - New Optik - Marco Welter -# 2010-08-19 - Icons for sub entries and single click behavior, unlike XUL-Menu -# JS switchable HTML-menu - Sven Donath -####################################################################### +package SL::Controller::Layout::MenuLeft; use strict; +use parent qw(SL::Controller::Layout::Base); -use SL::Menu; use URI; use List::MoreUtils qw(apply); -sub render { - $::lxdebug->enter_sub; - - $::form->use_stylesheet(qw(css/icons16.css css/icons24.css)); - - my $menu = Menu->new("menu.ini"); +sub stylesheets { + qw(css/icons16.css css/icons24.css); +} - my $sections = [ section_menu($menu) ]; +sub render { + my ($self) = @_; + my $sections = [ section_menu($self->menu) ]; - $::lxdebug->leave_sub; - $::form->parse_html_template('menu/menu', { + $self->SUPER::render('menu/menu', { no_menu => 1, no_output => 1 }, sections => $sections, - inline => 1, - }); + ); } sub section_menu { @@ -143,5 +103,3 @@ sub _show_images { } 1; - -__END__ diff --git a/SL/Controller/Layout/None.pm b/SL/Controller/Layout/None.pm new file mode 100644 index 000000000..f3fc79ffa --- /dev/null +++ b/SL/Controller/Layout/None.pm @@ -0,0 +1,6 @@ +package SL::Controller::Layout::None; + +use strict; +use parent qw(SL::Controller::Layout::Base); + +1; diff --git a/SL/Controller/Layout/Top.pm b/SL/Controller/Layout/Top.pm new file mode 100644 index 000000000..f4305d6e0 --- /dev/null +++ b/SL/Controller/Layout/Top.pm @@ -0,0 +1,19 @@ +package SL::Controller::Layout::Top; + +use strict; +use parent qw(SL::Controller::Layout::Base); + +sub render { + my ($self) = @_; + + $self->SUPER::render('menu/header', { partial => 1, no_output => 1 }, + now => DateTime->now_local, + is_fastcgi => scalar($::dispatcher->interface_type =~ /fastcgi/i), + is_links => scalar($ENV{HTTP_USER_AGENT} =~ /links/i)); +} + +sub stylesheets { +# 'frame_header/header.css'; +} + +1; diff --git a/SL/Controller/Layout/V3.pm b/SL/Controller/Layout/V3.pm new file mode 100644 index 000000000..e545b72c6 --- /dev/null +++ b/SL/Controller/Layout/V3.pm @@ -0,0 +1,36 @@ +package SL::Controller::Layout::V3; + +use strict; +use parent qw(SL::Controller::Layout::Base); +use SL::Controller::Layout::Css; + +use URI; + +sub pre_content { + &render; +} + +sub start_content { + "
    \n"; +} + +sub end_content { + "
    \n"; +} + +sub render { + my ($self) = @_; + + my $callback = $::form->unescape($::form->{callback}); + $callback = URI->new($callback)->rel($callback) if $callback; + $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; + + $self->SUPER::render('menu/menuv3', { no_menu => 1, no_output => 1 }, + force_ul_width => 1, + date => $self->clock_line, + menu => $self->print_menu, + callback => $callback, + ); +} + +1; diff --git a/SL/Controller/Layout/V4.pm b/SL/Controller/Layout/V4.pm new file mode 100644 index 000000000..6be1b551a --- /dev/null +++ b/SL/Controller/Layout/V4.pm @@ -0,0 +1,52 @@ +package SL::Controller::Layout::V4; + +use strict; +use parent qw(SL::Controller::Layout::Base); +use SL::Controller::Layout::Css; +use SL::Controller::Layout::Top; + +use URI; + +sub new { + my ($class, @slurp) = @_; + + my $self = $class->SUPER::new(@slurp); + $self->{top} = SL::Controller::Layout::Top->new; + $self; +} + +sub pre_content { + $_[0]{top}->render . + &render; +} + +sub stylesheets { + $_[0]{top}->stylesheets +} + +sub start_content { + "
    \n"; +} + +sub end_content { + "
    \n"; +} + +sub render { + my ($self) = @_; + + $self->{sub_class} = 1; + + my $callback = $::form->unescape($::form->{callback}); + $callback = URI->new($callback)->rel($callback) if $callback; + $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; + + $self->SUPER::render('menu/menuv4', { no_menu => 1, no_output => 1 }, + force_ul_width => 1, + date => $self->clock_line, + menu => $self->print_menu, + callback => $callback, + ); +} + +1; diff --git a/SL/Controller/LoginScreen.pm b/SL/Controller/LoginScreen.pm index c15cf3ea8..9d0e94bc3 100644 --- a/SL/Controller/LoginScreen.pm +++ b/SL/Controller/LoginScreen.pm @@ -38,6 +38,7 @@ sub action_login { $::form->{login} = $::myconfig{login}; $::locale = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode}; my $user = User->new(login => $::myconfig{login}); + $::request->{layout} = SL::Controller::Layout->new(style => $user->{menustyle}); # if we get an error back, bale out my $result = $user->login($::form); diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index c67efa79a..37ee29da0 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -35,6 +35,7 @@ use SL::Form; use SL::Helper::DateTime; use SL::InstanceConfiguration; use SL::Template::Plugin::HTMLFixes; +use SL::Controller::Layout::None; # Trailing new line is added so that Perl will not add the line # number 'die' was called in. @@ -181,7 +182,10 @@ sub handle_request { $::locale = Locale->new($::lx_office_conf{system}->{language}); $::form = Form->new; $::instance_conf = SL::InstanceConfiguration->new; - $::request = { cgi => CGI->new({}) }; + $::request = { + cgi => CGI->new({}), + layout => SL::Controller::Layout::None->new, + }; my $session_result = $::auth->restore_session; $::auth->create_or_refresh_session; diff --git a/SL/Dispatcher/AuthHandler.pm b/SL/Dispatcher/AuthHandler.pm index 22b2be44d..c24443151 100644 --- a/SL/Dispatcher/AuthHandler.pm +++ b/SL/Dispatcher/AuthHandler.pm @@ -1,4 +1,4 @@ -package SL::Dispatcher::AuthHandler; + package SL::Dispatcher::AuthHandler; use strict; @@ -14,6 +14,7 @@ sub handle { my ($self, %param) = @_; my $auth_level = $self->get_auth_level(%param); + my $handler_name = "SL::Dispatcher::AuthHandler::" . ucfirst($auth_level); $self->{handlers} ||= {}; $self->{handlers}->{$handler_name} ||= $handler_name->new; diff --git a/SL/Dispatcher/AuthHandler/Admin.pm b/SL/Dispatcher/AuthHandler/Admin.pm index 77202e8e4..86efbb2dc 100644 --- a/SL/Dispatcher/AuthHandler/Admin.pm +++ b/SL/Dispatcher/AuthHandler/Admin.pm @@ -1,15 +1,18 @@ package SL::Dispatcher::AuthHandler::Admin; use strict; - use parent qw(Rose::Object); +use SL::Controller::Layout; + sub handle { %::myconfig = (); return if $::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::form->{'{AUTH}admin_password'}) == $::auth->OK()); return if !$::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::auth->get_session_value('admin_password')) == $::auth->OK()); + $::request->{layout} = SL::Controller::Layout->new(style => 'admin'); + $::auth->punish_wrong_login; $::auth->delete_session_value('admin_password'); SL::Dispatcher::show_error('admin/adminlogin', 'password'); diff --git a/SL/Dispatcher/AuthHandler/User.pm b/SL/Dispatcher/AuthHandler/User.pm index a1b64860a..6dc200bae 100644 --- a/SL/Dispatcher/AuthHandler/User.pm +++ b/SL/Dispatcher/AuthHandler/User.pm @@ -1,9 +1,10 @@ package SL::Dispatcher::AuthHandler::User; use strict; - use parent qw(Rose::Object); +use SL::Controller::Layout; + sub handle { my ($self, %param) = @_; @@ -15,6 +16,7 @@ sub handle { $self->_error(%param) unless $::myconfig{login}; $::locale = Locale->new($::myconfig{countrycode}); + $::request->{layout} = SL::Controller::Layout->new(style => $::myconfig{menustyle}); my $ok = $::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, $::form->{'{AUTH}password'})); $ok ||= !$::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, undef)); diff --git a/SL/Form.pm b/SL/Form.pm index 521d899bd..b25fe6a2d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -451,11 +451,15 @@ sub use_stylesheet { my $self = shift; $self->{stylesheet} = [ $self->{stylesheet} ] unless ref $self->{stylesheet} eq 'ARRAY'; - $self->{stylesheet} = [ grep { -f } - map { m:^css/: ? $_ : "css/$_" } - grep { $_ } - (@{ $self->{stylesheet} }, @_) - ]; + + if (@_) { + $self->{stylesheet} = + [ grep { -f } + map { m:^css/: ? $_ : "css/$_" } + grep { $_ } + (@{ $self->{stylesheet} }, @_) + ]; + } return @{ $self->{stylesheet} }; } @@ -489,13 +493,10 @@ sub header { $::lxdebug->leave_sub and return if !$ENV{HTTP_USER_AGENT} || $self->{header}++; - my $layout; - $layout = $self->layout unless $params{no_menu}; - my $css_path = $self->get_stylesheet_for_user; $self->{favicon} ||= "favicon.ico"; - $self->{titlebar} = "$self->{title} - $self->{titlebar}" if $self->{title}; + $self->{titlebar} = join ' - ', grep $_, $self->{title}, $self->{login}, $::myconfig{dbname}, $self->{version} if $self->{title}; # build includes if ($self->{refresh_url} || $self->{refresh_time}) { @@ -504,7 +505,7 @@ sub header { push @header, ""; } - push @header, map { qq|| } $self->use_stylesheet; + push @header, map { qq|| } $self->use_stylesheet, $::request->{layout}->stylesheets; push @header, "" if $self->{landscape}; push @header, "" if -f $self->{favicon}; @@ -516,8 +517,6 @@ sub header { push @header, map { qq|| } push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] }; push @header, "" if $self->{fokus}; - push @header, sprintf "", - join ' - ', grep $_, $self->{title}, $self->{login}, $::myconfig{dbname}, $self->{version} if $self->{title}; my %doctypes = ( strict => qq||, @@ -551,13 +550,27 @@ EOT EOT - print $layout; - - print "
    \n"; + print $::request->{layout}->pre_content; + print $::request->{layout}->start_content; $::lxdebug->leave_sub; } +sub footer { + # TODO: fix abort conditions + + print $::request->{layout}->post_content; + print "\n" for $::request->{layout}->javascripts; + if (my @inline_scripts = $::request->{layout}->javascript_inline) { + print "\n" for @inline_scripts; + } + + print < + +EOL +} + sub ajax_response_header { $main::lxdebug->enter_sub(); diff --git a/SL/Menu.pm b/SL/Menu.pm index 3b994f2fb..48ac6229d 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -58,43 +58,6 @@ sub new { return $self; } -sub menuitem_js { - my ($self, $myconfig, $form, $item) = @_; - - my $module = $form->{script}; - my $action = "section_menu"; - - #if ($self->{$item}{module}) { - $module = $self->{$item}{module}; - - #} - if ($self->{$item}{action}) { - $action = $self->{$item}{action}; - } - - my $level = $form->escape($item); - my $str = qq|$module?action=$action&level=$level|; - my @vars = qw(module action target href); - - if ($self->{$item}{href}) { - $str = qq|$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) . "="; - my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); - $value = $myconfig->{$value} . "/$conf" if ($conf); - $str .= $form->escape($value, 1); - } - - $str .= " "; - -} - sub menuitem_new { $main::lxdebug->enter_sub(); @@ -124,122 +87,6 @@ sub menuitem_new { $main::lxdebug->leave_sub(); } -sub menuitem_v3 { - $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|escape($key, 1) . "="; - my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); - $value = $myconfig->{$value} . "/$conf" if ($conf); - $str .= $form->escape($value, 1); - } - - $str .= '"'; - - if ($target) { - $str .= qq| target="| . $form->quote($target) . qq|"|; - } - - if ($other) { - foreach my $key (keys(%{$other})) { - $str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|; - } - } - - $str .= ">"; - - $main::lxdebug->leave_sub(); - - 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); - - 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) . "="; - my ($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 access_control { $main::lxdebug->enter_sub(2); diff --git a/bin/mozilla/menujs.pl b/bin/mozilla/menujs.pl deleted file mode 100644 index 202f75c26..000000000 --- a/bin/mozilla/menujs.pl +++ /dev/null @@ -1,446 +0,0 @@ -#===================================================================== -# 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 -# -# CHANGE LOG: -# DS. 2002-03-25 Created -# 2004-12-14 - Holger Lindemann -####################################################################### - -use utf8; -use strict; - -use SL::Menu; -use CGI::Carp qw(fatalsToBrowser); - -1; - -# end of main - -sub display { - - my $form = $main::form; - - $form->{callback} = $form->unescape($form->{callback}); - $form->{callback} ||= "login.pl?action=company_logo"; - - $form->header; - - &clock_line; - - &acc_menu; - - print qq| - - - - -|; - -} - -sub clock_line { - - my $form = $main::form; - - my $fensterlink="menujs.pl?action=display"; - my $fenster = "["."neues Fenster]"; - - my $login = "[Nutzer " - . $form->{login} - . " - " - . $::locale->text('Logout') - . "] "; - my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat, - $Jahr, $Wochentag, $Jahrestag, $Sommerzeit) - = localtime(time); - my $CTIME_String = 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"); - my $datum = - $Wochentage[$Wochentag] . ", der " - . $Monatstag . "." - . $Monat . "." - . $Jahr . " - "; - - #$zeit="
    ".$Stunden.":".$Minuten.":".$Sekunden."
    "; - my $zeit = "
    " . $Stunden . ":" . $Minuten . "
    "; - print qq| - - - - - - -
      $fenster   [drucken] - $login $datum   -
    -|; -} - -sub acc_menu { - - my $form = $main::form; - my %myconfig = %main::myconfig; - - my $mainlevel = $form->{level}; - $mainlevel =~ s/$mainlevel--//g; - my $menu = Menu->new("menu.ini"); - - $| = 1; - - print qq| - - - - - - - - - - - -|; - - print qq| - -|; - -} - -sub section_menu { - my ($menu, $level) = @_; - - my $form = $main::form; - my %myconfig = %main::myconfig; - - # build tiered menus - my @menuorder = $menu->access_control(\%myconfig, $level); - my $main = 0; - - #$pm=0; - my $shlp=0; - my (%mlz, $sm, $z, $pm, $mm); - while (@menuorder) { - my $item = shift @menuorder; - my $label = $item; - my $ml = $item; - $label =~ s/$level--//g; - $ml =~ s/--.*//; - $label = $::locale->text($label); - $label =~ s/ / /g; - $menu->{$item}{target} = "main_window" unless $menu->{$item}{target}; - - if ($menu->{$item}{submenu}) { - $menu->{$item}{$item} = !$form->{$item}; - - # Untermen - if ($mlz{"s$ml"} > 1) { - $z++; - $sm = 1; - } else { - $z = $sm; - $mlz{"s$ml"}++; - } - print - qq|menu[$mlz{$ml}][$z] = new Item('$label', '#', '', defLength, 0, | - . ++$pm - . qq|);\n|; - $sm = 1; - print qq|menu[$pm] = new Array();\n|; - print - qq|menu[$pm][0] = new Menu(true, '', 85, 0, 180, defOver, defBack, 'itemBorder', 'itemText');\n|; - map { shift @menuorder } grep /^$item/, @menuorder; - §ion_menu($menu, $item); - map { shift @menuorder } grep /^$item/, @menuorder; - } else { - if ($menu->{$item}{module}) { - - #Untermenüpunkte - my $target = $menu->{$item}{target}; - my $uri = $menu->menuitem_js(\%myconfig, \%$form, $item, $level); - - print - qq|menu[$pm][$sm] = new Item('$label', '$uri', '$target', defLength, 0, 0);\n|; - $sm++; - } else { # Hauptmenu - my $ml_ = $form->escape($ml); - $mm++; - $pm++; - %mlz = ($ml, $pm, "s$ml", 1); - $shlp = $sm; - $sm = 1; - my $breit = 15 + length($label) * 6; - print - qq|menu[0][$mm] = new Item(' $label', '#', '', $breit, 10, $pm); \n|; - print qq|menu[$pm] = new Array();\n|; - print - qq|menu[$pm][0] = new Menu(true, '>', 0, 20, 180, defOver, defBack, 'itemBorder', 'itemText');\n|; - - §ion_menu($menu, $item); - - #print qq|
    \n|; - } - } - } -} diff --git a/bin/mozilla/menuv3.pl b/bin/mozilla/menuv3.pl deleted file mode 100644 index 121d76df0..000000000 --- a/bin/mozilla/menuv3.pl +++ /dev/null @@ -1,141 +0,0 @@ -#===================================================================== -# 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 -# -####################################################################### - -use SL::Menu; -use URI; - -use strict; - -1; - -# end of main - -sub display { - my $form = $main::form; - - $form->header(extra_code => qq||); - - $form->{date} = clock_line(); - $form->{menu} = acc_menu(); - my $callback = $form->unescape($form->{callback}); - $callback = URI->new($callback)->rel($callback) if $callback; - $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; - $form->{callback} = $callback; - - print $form->parse_html_template("menu/menuv3"); - -} - -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"); - return - $Wochentage[$Wochentag] . ", der " - . $Monatstag . "." - . $Monat . "." - . $Jahr . " - "; -} - -sub acc_menu { - my $form = $main::form; - my %myconfig = %main::myconfig; - - my $mainlevel = $form->{level}; - $mainlevel =~ s/\Q$mainlevel\E--//g; - my $menu = Menu->new("menu.ini"); - - $| = 1; - - return print_menu($menu); -} - -sub print_menu { - my ($menu, $parent, $depth) = @_; - - my $form = $main::form; - my %myconfig = %main::myconfig; - - my $html; - - die if ($depth * 1 > 5); - - my @menuorder; - - @menuorder = $menu->access_control(\%myconfig, $parent); - - $parent .= "--" if ($parent); - - foreach my $item (@menuorder) { - 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|\n|; - } else { - $html .= qq|
  • ${menu_text}
      ${h}
  • \n|; - } - } else { - $html .= qq|
  • |; - $html .= $menu->menuitem_v3(\%myconfig, $form, "${parent}$item", - { "title" => $menu_title, - "target" => $target }); - $html .= qq|${menu_text}
  • \n|; - } - } - - return $html; -} diff --git a/bin/mozilla/menuv4.pl b/bin/mozilla/menuv4.pl deleted file mode 100644 index 25d7d792c..000000000 --- a/bin/mozilla/menuv4.pl +++ /dev/null @@ -1,147 +0,0 @@ -#===================================================================== -# 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 -# -####################################################################### - -use SL::Menu; -use URI; - -use strict; - -1; - -# end of main - -sub display { - my $form = $main::form; - - $form->header(extra_code => qq||); - - $form->{date} = clock_line(); - $form->{menu} = acc_menu(); - my $callback = $form->unescape($form->{callback}); - $callback = URI->new($callback)->rel($callback) if $callback; - $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; - $form->{callback} = $callback; - - print $form->parse_html_template("menu/menuv4"); - -} - -sub clock_line { - my $form = $main::form; - - 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"); - return - $Wochentage[$Wochentag] . ", der " - . $Monatstag . "." - . $Monat . "." - . $Jahr . " - "; -} - -sub acc_menu { - my $form = $main::form; - my %myconfig = %main::myconfig; - - my $mainlevel = $form->{level}; - $mainlevel =~ s/\Q$mainlevel\E--//g; - my $menu = Menu->new("menu.ini"); - - $| = 1; - - return print_menu($menu); -} - -sub print_menu { - my ($menu, $parent, $depth) = @_; - - my $form = $main::form; - my %myconfig = %main::myconfig; - - my $html; - - die if ($depth * 1 > 5); - - my @menuorder; - - @menuorder = $menu->access_control(\%myconfig, $parent); - - $parent .= "--" if ($parent); - - foreach my $item (@menuorder) { - 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|\n|; - } else { - $html .= qq|
  • ${menu_text}
      ${h}
  • \n|; - } - } else { - if ($depth>1) { - $html .= qq|
  • |; - } else { - $html .= qq|
  • |; - } - $html .= $menu->menuitem_v3(\%myconfig, $form, "${parent}$item", - { "title" => $menu_title, - "target" => $target }); - $html .= qq|${menu_text}
  • \n|; - } - } - - return $html; -} diff --git a/css/lx-office-erp/frame_header/header.css b/css/lx-office-erp/frame_header/header.css index 470a89a25..852a76c98 100644 --- a/css/lx-office-erp/frame_header/header.css +++ b/css/lx-office-erp/frame_header/header.css @@ -18,7 +18,6 @@ width: 100%; border-spacing: 0; font-size: 12px; - margin-bottom:10px; } #frame-header .frame-header-left { diff --git a/css/lx-office-erp/menu.css b/css/lx-office-erp/menu.css index 812999ae1..eb19ad205 100644 --- a/css/lx-office-erp/menu.css +++ b/css/lx-office-erp/menu.css @@ -295,7 +295,7 @@ div#menuv4 li li li li:hover ul each line is a mi (menuitem) and has one mii (menu-item-icon) whcih is ms (menu-spacer) and one mic (menu-item-chunk) indenting is done with the levels s0, s1, s2 */ -#html-menu { float:left; width: 183px; font-size: 8pt } +#html-menu { float:left; width: 183px; font-size: 8pt; margin-top: 10px; } #html-menu div.mi { margin-top: 4px; margin-bottom: 3px; white-space: nowrap; clear:both; position:relative; } #html-menu div.sm { font-weight: bold } #html-menu img { vertical-align: top; border: 0; } @@ -312,7 +312,6 @@ div#menuv4 li li li li:hover ul #html-menu div.s0 { padding-left: 2px } #html-menu div.s1 { padding-left: 8px } #html-menu div.s2 { padding-left: 16px } - -#content { margin-left: 190px } +#content.html-menu { margin-left: 190px } body { margin: 0 } diff --git a/templates/webpages/menu/menunew.html b/templates/webpages/menu/menunew.html index d55267541..89bad2b37 100644 --- a/templates/webpages/menu/menunew.html +++ b/templates/webpages/menu/menunew.html @@ -1,6 +1,5 @@ [%- USE T8 %] -[% USE HTML %] - +[% USE HTML %] - - - diff --git a/templates/webpages/menu/menuv3.html b/templates/webpages/menu/menuv3.html index cfe50a3e5..2bd0f87e7 100644 --- a/templates/webpages/menu/menuv3.html +++ b/templates/webpages/menu/menuv3.html @@ -1,6 +1,5 @@ [%- USE T8 %] -[% USE HTML %] - +[% USE HTML %] - -- 2.20.1