From 503655261b9f86498c36b634e387938ecd8359a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 28 Dec 2010 13:39:07 +0100 Subject: [PATCH] Form::header MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 1. Code aufgeräumt. Viele der alten Idiome einheitlich gemacht und sortiert. Alle prints finden jetzt am Ende statt, fall jemand das ganze mal auf return umbauen will. Alle Header werden vorher zusammengebaut. 2. jsscript flag entfernt. Javascripte werden jetzt immer mit ausgegeben. 3. Support für http redirect. Conflicts: SL/Form.pm --- SL/Form.pm | 164 ++++++++++++++++------------------------------------- 1 file changed, 50 insertions(+), 114 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index f02c25abe..4360c0740 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -616,120 +616,59 @@ sub create_http_response { sub header { - $main::lxdebug->enter_sub(); + $::lxdebug->enter_sub; - # extra code ist currently only used by menuv3 and menuv4 to set their css. + # extra code is currently only used by menuv3 and menuv4 to set their css. # it is strongly deprecated, and will be changed in a future version. my ($self, $extra_code) = @_; - - if ($self->{header}) { - $main::lxdebug->leave_sub(); - return; - } - - my ($stylesheet, $favicon, $pagelayout); - - if ($ENV{HTTP_USER_AGENT}) { - my $doctype; - - if ($ENV{'HTTP_USER_AGENT'} =~ m/MSIE\s+\d/) { - # Only set the DOCTYPE for Internet Explorer. Other browsers have problems displaying the menu otherwise. - $doctype = qq|\n|; - } - - my $stylesheets = "$self->{stylesheet} $self->{stylesheets}"; - - $stylesheets =~ s|^\s*||; - $stylesheets =~ s|\s*$||; - foreach my $file (split m/\s+/, $stylesheets) { - $file =~ s|.*/||; - next if (! -f "css/$file"); - - $stylesheet .= qq|\n|; - } - - $self->{favicon} = "favicon.ico" unless $self->{favicon}; - - if ($self->{favicon} && (-f "$self->{favicon}")) { - $favicon = - qq| - |; - } - - my $db_charset = $main::dbcharset ? $main::dbcharset : Common::DEFAULT_CHARSET; - - if ($self->{landscape}) { - $pagelayout = qq||; - } - - my $fokus = qq| - - | if $self->{"fokus"}; - - # if there is a title, we put some JavaScript in to the page, wich writes a - # meaningful title-tag for our frameset. - my $title_hack; - if ($self->{"title"}){ - $title_hack = qq| - - |; - } - - #Set Calendar - my $jsscript = ""; - if ($self->{jsscript} == 1) { - - $jsscript = qq| - - - - - - - $self->{javascript} - |; - } - - $self->{titlebar} = - ($self->{title}) - ? "$self->{title} - $self->{titlebar}" - : $self->{titlebar}; - my $ajax = ""; - for my $item (@ { $self->{AJAX} || [] }) { - $ajax .= $item->show_javascript(); - } - - print $self->create_http_response('content_type' => 'text/html', - 'charset' => $db_charset,); - print qq|${doctype} - - + my $db_charset = $::dbcharset || Common::DEFAULT_CHARSET; + my @header; + + $::lxdebug->leave_sub and return if !$ENV{HTTP_USER_AGENT} || $self->{header}++; + + $self->{favicon} ||= "favicon.ico"; + $self->{titlebar} = "$self->{title} - $self->{titlebar}" if $self->{title}; + + # build includes + if ($self->{refresh_url} || $self->{refresh_time}) { + my $refresh_time = $self->{refresh_time} || 3; + my $refresh_url = $self->{refresh_url} || $ENV{REFERER}; + push @header, ""; + } + + push @header, "" + for grep { -f "css/$_" } apply { s|.*/|| } $self->{stylesheet}, $self->{stylesheets}; + + push @header, "" if $self->{landscape}; + push @header, "" if -f $self->{favicon}; + push @header, '', + '', + '', + '', + '', + '', + ''; + push @header, $self->{javascript} if $self->{javascript}; + 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}; + + # output + print $self->create_http_response(content_type => 'text/html', charset => $db_charset); + print "\n" + if $ENV{'HTTP_USER_AGENT'} =~ m/MSIE\s+\d/; # Other browsers may choke on menu scripts with DOCTYPE. + print < + + $self->{titlebar} - $stylesheet - $pagelayout - $favicon - $jsscript - $ajax - $fokus - $title_hack - +EOT + print " $_\n" for @header; + print < - - + - $extra_code - + -|; - } - $self->{header} = 1; +EOT - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub ajax_response_header { -- 2.20.1