From: Sven Schöling Date: Fri, 13 May 2011 09:17:23 +0000 (+0200) Subject: Debug Menü im HTML Menü. FCGI Entwicklung leicht gemacht. X-Git-Tag: release-2.6.3~25^2~37^2~10 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3e8a8c572aa73c522df8c916d799cb30be276925;p=kivitendo-erp.git Debug Menü im HTML Menü. FCGI Entwicklung leicht gemacht. --- diff --git a/SL/Controller/DebugMenu.pm b/SL/Controller/DebugMenu.pm new file mode 100644 index 000000000..d612d3701 --- /dev/null +++ b/SL/Controller/DebugMenu.pm @@ -0,0 +1,24 @@ +package SL::Controller::DebugMenu; + +use strict; +use parent qw(SL::Controller::Base); + +# safety +__PACKAGE__->run_before(sub { die 'not allowed in config' unless $::lx_office_conf{debug}{show_debug_menu}; }); + +sub action_reload { + my ($self, %params) = @_; + + print $::cgi->redirect('kopf.pl'); + exit; +} + +sub action_toggle { + my ($self, %params) = @_; + + $::lxdebug->level_by_name($::form->{level}, !$::lxdebug->level_by_name($::form->{level})); + print $::cgi->redirect('kopf.pl'); + return; +} + +1; diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index 1f0110f39..4e7790791 100644 --- a/SL/LXDebug.pm +++ b/SL/LXDebug.pm @@ -296,4 +296,20 @@ sub file { @_ == 2 ? $_[0]->{file} = $_[1] : $_[0]->{file}; } +sub _by_name { + my ($self, $level) = @_; + my $meth = $self->can(uc $level); + die 'unknown level' unless $meth; + $meth->(); +} + +sub level_by_name { + my ($self, $level, $val) = @_; + if (@_ == 3) { + $global_level |= $self->_by_name($level) if $val; + $global_level &= ~$self->_by_name($level) if !$val; + } + return $global_level & $self->_by_name($level); +} + 1; diff --git a/bin/mozilla/kopf.pl b/bin/mozilla/kopf.pl index ed11e522b..0228566ae 100644 --- a/bin/mozilla/kopf.pl +++ b/bin/mozilla/kopf.pl @@ -1,136 +1,21 @@ #!/usr/bin/perl -# - -#$| = 1; - -#use CGI::Carp qw(fatalsToBrowser); use strict; +use DateTime; sub run { my $session_result = shift; - %::myconfig = $::auth->read_user($::form->{login}) if $::form->{login}; - $::locale = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode}; - -my $form = $main::form; -my $locale = $main::locale; - -$form->header; -my $paramstring = $ENV{"QUERY_STRING"}; -my @felder = split "&", $paramstring; -my ($name, $wert); -foreach (@felder) { - ($name, $wert) = split "=", $_; - $wert =~ tr/+/ /; - $name = $wert; -} -my $login = - "". $locale->text('User') . ": " . $form->{login} - . " [text('Logout now') . "\">" - . $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| - -|; + %::myconfig = $::auth->read_user($::form->{login}) if $::form->{login}; + $::locale = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode}; -print qq| - - - - |; - if ( !($ENV{HTTP_USER_AGENT} =~ /links/i) ) { # do not show the the links in case of "links" in HTTP_USER_AGENT - print qq| - |; - } - print qq| - - -
- [| . $locale->text('Menu') . qq|] -  [| . $locale->text('New Win/Tab') . qq|] -  [| . $locale->text('Print') . qq|] -  [| . $locale->text('Back') . qq|] -  [| . $locale->text('Fwd') . qq|] - | - . $login . $datum . qq|   -
- - -|; + $::form->header; + print $::form->parse_html_template('menu/header', { + now => DateTime->now, + show_debug => $::lx_office_conf{debug}{show_debug_menu}, + lxdebug => $::lxdebug, + is_links => ($ENV{HTTP_USER_AGENT} =~ /links/i), + }); } 1; diff --git a/config/lx_office.conf.default b/config/lx_office.conf.default index ef620c0e2..e4991fd0c 100644 --- a/config/lx_office.conf.default +++ b/config/lx_office.conf.default @@ -222,6 +222,9 @@ global_level = NONE # default. watch_form = 0 +# Im HTML Menü ein Hilfsmenü zur Debugsteuerung zeigen. +show_debug_menu = 0 + # If you want to debug the creation of LaTeX files then set this to 1. # That way the temporary LaTeX files created during PDF creation are # not removed and remain in the "users" directory. diff --git a/templates/webpages/menu/header.html b/templates/webpages/menu/header.html new file mode 100644 index 000000000..359c94094 --- /dev/null +++ b/templates/webpages/menu/header.html @@ -0,0 +1,41 @@ +[%- USE T8 %] + + + + + +[% UNLESS is_links %] + +[%- END %] +[% IF show_debug %] + +[%- END %] + + +
+ [[% 'Menu' | $T8 %]] + [[% 'New Win/Tab' | $T8 %]] + [[% 'Print' | $T8 %]] + [[% 'Back' | $T8 %]] + [[% 'Fwd' | $T8 %]] + + Debug: + [FCGI Reload] + [[% IF lxdebug.level_by_name('request_timer') %]Timing[% ELSE %]Timing[% END %]] + [[% IF lxdebug.level_by_name('trace') %]Trace[% ELSE %]Trace[% END %]] + [[% IF lxdebug.level_by_name('query') %]Query[% ELSE %]Query[% END %]] + + [% 'User' | $T8 %]: + [% login %] + [[% 'Logout' | $T8 %]] + [% now.to_lxoffice %] - + [% now.hms %] +
+ +