Revision 20993efb
Von Sven Schöling vor etwa 13 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
use SL::Mailer;
|
||
use SL::MoreCommon;
|
||
use SL::Template;
|
||
use SL::DB::Printer;
|
||
use SL::DB::Language;
|
||
|
||
use strict;
|
||
|
||
... | ... | |
$form->{printer_code} = "_" . $form->{printer_code};
|
||
}
|
||
|
||
$form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
|
||
$form->{pdf} = 1;
|
||
my $extension = 'html';
|
||
if ($form->{format} eq 'postscript') {
|
||
$form->{postscript} = 1;
|
||
$extension = 'tex';
|
||
|
||
if ($form->{"format"} =~ /opendocument/) {
|
||
$form->{IN} =~ s/html$/odt/;
|
||
} else {
|
||
$form->{IN} =~ s/html$/tex/;
|
||
} elsif ($form->{"format"} =~ /pdf/) {
|
||
$form->{pdf} = 1;
|
||
$extension = $form->{'format'} =~ m/opendocument/i ? 'odt' : 'tex';
|
||
|
||
} elsif ($form->{"format"} =~ /opendocument/) {
|
||
$form->{opendocument} = 1;
|
||
$extension = 'odt';
|
||
} elsif ($form->{"format"} =~ /excel/) {
|
||
$form->{excel} = 1;
|
||
$extension = 'xls';
|
||
}
|
||
|
||
|
||
# search for the template
|
||
my @template_files;
|
||
push @template_files, "$form->{formname}_email$form->{language}$form->{printer_code}.$extension" if $form->{media} eq 'email';
|
||
push @template_files, "$form->{formname}$form->{language}$form->{printer_code}.$extension";
|
||
push @template_files, "$form->{formname}.$extension";
|
||
push @template_files, "default.$extension";
|
||
|
||
$form->{IN} = undef;
|
||
for my $filename (@template_files) {
|
||
if (-f "$form->{templates}/$filename") {
|
||
$form->{IN} = $filename;
|
||
last;
|
||
}
|
||
}
|
||
|
||
if (!defined $form->{IN}) {
|
||
$::form->error($::locale->text('Cannot find matching template for this print request. Please contact your template maintainer. I tried these: #1.', join ', ', map { "'$_'"} @template_files));
|
||
}
|
||
|
||
# prepare meta information for template introspection
|
||
$form->{template_meta} = {
|
||
formname => $form->{formname},
|
||
language => SL::DB::Manager::Language->find_by_or_create(id => $form->{language_id}),
|
||
format => $form->{format},
|
||
media => $form->{media},
|
||
extension => $extension,
|
||
printer => SL::DB::Manager::Printer->find_by_or_create(id => $form->{printer_id}),
|
||
today => DateTime->today,
|
||
};
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
Auch abrufbar als: Unified diff
Template Metadaten und default.tex Weiterleitung auch für Mahnungen.