X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher.pm;h=da7ffef641b405dbfa2d1f35c7d98f5474027959;hb=47a963f4da66588e72124424e0e5e58577894eb5;hp=c412f64224ab168b1dea603a4f275eeeb2c339cd;hpb=41400107ec8929d6ea107de7f5238006e9de029c;p=kivitendo-erp.git diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index c412f6422..da7ffef64 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -9,11 +9,13 @@ BEGIN { } use CGI qw( -no_xhtml); +use DateTime; use English qw(-no_match_vars); use SL::Auth; use SL::LXDebug; use SL::Locale; use SL::Common; +use SL::Helper::DateTime; use Form; use List::Util qw(first); use File::Basename; @@ -22,6 +24,15 @@ use File::Basename; # number 'die' was called in. use constant END_OF_REQUEST => "END-OF-REQUEST\n"; +sub new { + my ($class, $interface) = @_; + + my $self = bless {}, $class; + $self->{interface} = lc($interface || 'cgi'); + + return $self; +} + sub pre_request_checks { if (!$::auth->session_tables_present) { if ($::form->{script} eq 'admin.pl') { @@ -138,15 +149,17 @@ sub _run_controller { } sub handle_request { + my $self = shift; + $self->{request} = shift; + $::lxdebug->enter_sub; $::lxdebug->begin_request; - my $interface = lc(shift || 'cgi'); my ($script, $path, $suffix, $script_name, $action, $routing_type); $script_name = $ENV{SCRIPT_NAME}; - unrequire_bin_mozilla($interface); + $self->unrequire_bin_mozilla; $::cgi = CGI->new(''); $::locale = Locale->new($::language); @@ -230,7 +243,8 @@ sub handle_request { } sub unrequire_bin_mozilla { - return unless $_[0] =~ m/^(?:fastcgi|fcgid|fcgi)$/; + my $self = shift; + return unless $self->{interface} =~ m/^(?:fastcgi|fcgid|fcgi)$/; for (keys %INC) { next unless m#^bin/mozilla/#; @@ -282,7 +296,7 @@ sub _route_controller_request { my ($controller, $action); eval { - $::form->{action} =~ m|^ ( [A-Z] [A-Za-z0-9_]* ) :: ( [a-z] [a-z0-9_]* ) $|x || die "Unroutable request -- inavlid controller/action.\n"; + $::form->{action} =~ m|^ ( [A-Z] [A-Za-z0-9_]* ) / ( [a-z] [a-z0-9_]* ) $|x || die "Unroutable request -- inavlid controller/action.\n"; ($controller, $action) = ($1, $2); delete $::form->{action}; @@ -295,6 +309,12 @@ sub _route_controller_request { return ($controller, $action); } +sub get_standard_filehandles { + my $self = shift; + + return $self->{interface} =~ m/f(?:ast)cgi/i ? $self->{request}->GetHandles() : (\*STDIN, \*STDOUT, \*STDERR); +} + package main; use strict;