X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=lib%2FPackages%2FTemplate.pm;h=0fe24813ee9bad83afbf1999a4213f3c7ab9f451;hb=1bae1b743532d7d100015b751fe1f7be52198b8b;hp=9912cd704f2acbb023402e35e7dd7cdd07fc6e7a;hpb=2ec757bb58907b15c43548be5601d4f2b8c7caac;p=deb%2Fpackages.git diff --git a/lib/Packages/Template.pm b/lib/Packages/Template.pm index 9912cd7..0fe2481 100644 --- a/lib/Packages/Template.pm +++ b/lib/Packages/Template.pm @@ -38,6 +38,7 @@ sub new { %$options, } ) or fatal_error( sprintf( _g( "Initialization of Template Engine failed: %s" ), $Template::ERROR ) ); $self->{format} = $format; + $self->{vars} = $vars; return $self; } @@ -52,15 +53,23 @@ sub error { } sub page { - my ($self, $action, $page_content) = @_; + my ($self, $action, $page_content, $target) = @_; #use Data::Dumper; #die Dumper($self, $action, $page_content); + $page_content->{used_langs} ||= [ 'en' ]; + $page_content->{langs} = languages( $page_content->{lang} + || $self->{vars}{lang} || 'en', + @{$page_content->{used_langs}} ); my $txt; - $self->process("$self->{format}/$action.tmpl", $page_content, \$txt) - or die sprintf( "template error: %s", $self->error ); # too late for reporting on-line - + if ($target) { + $self->process("$self->{format}/$action.tmpl", $page_content, $target) + or die sprintf( "template error: %s", $self->error ); # too late for reporting on-line + } else { + $self->process("$self->{format}/$action.tmpl", $page_content, \$txt) + or die sprintf( "template error: %s", $self->error ); + } return $txt; } @@ -71,19 +80,7 @@ sub error_page { # warn Dumper($page_content); my $txt; - $self->process("$self->{format}/error.tmpl", $page_content, \$txt) - or die sprintf( "template error: %s", $self->error ); # too late for reporting on-line - - return $txt; -} - -sub trailer { - my ($self, $NAME, $LANG, $USED_LANGS, $timediff) = @_; - - my $langs = languages( $LANG, @$USED_LANGS ); - - my $txt; - $self->process("$self->{format}/foot.tmpl", { langs => $langs, name => $NAME, benchmark => $timediff ? timestr($timediff) : '' }, \$txt) + $self->process("html/error.tmpl", $page_content, \$txt) or die sprintf( "template error: %s", $self->error ); # too late for reporting on-line return $txt;