Revision 20993efb
Von Sven Schöling vor fast 13 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
41 | 41 |
use SL::Mailer; |
42 | 42 |
use SL::MoreCommon; |
43 | 43 |
use SL::Template; |
44 |
use SL::DB::Printer; |
|
45 |
use SL::DB::Language; |
|
44 | 46 |
|
45 | 47 |
use strict; |
46 | 48 |
|
... | ... | |
403 | 405 |
$form->{printer_code} = "_" . $form->{printer_code}; |
404 | 406 |
} |
405 | 407 |
|
406 |
$form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html"; |
|
407 |
$form->{pdf} = 1; |
|
408 |
my $extension = 'html'; |
|
409 |
if ($form->{format} eq 'postscript') { |
|
410 |
$form->{postscript} = 1; |
|
411 |
$extension = 'tex'; |
|
408 | 412 |
|
409 |
if ($form->{"format"} =~ /opendocument/) { |
|
410 |
$form->{IN} =~ s/html$/odt/; |
|
411 |
} else { |
|
412 |
$form->{IN} =~ s/html$/tex/; |
|
413 |
} elsif ($form->{"format"} =~ /pdf/) { |
|
414 |
$form->{pdf} = 1; |
|
415 |
$extension = $form->{'format'} =~ m/opendocument/i ? 'odt' : 'tex'; |
|
416 |
|
|
417 |
} elsif ($form->{"format"} =~ /opendocument/) { |
|
418 |
$form->{opendocument} = 1; |
|
419 |
$extension = 'odt'; |
|
420 |
} elsif ($form->{"format"} =~ /excel/) { |
|
421 |
$form->{excel} = 1; |
|
422 |
$extension = 'xls'; |
|
423 |
} |
|
424 |
|
|
425 |
|
|
426 |
# search for the template |
|
427 |
my @template_files; |
|
428 |
push @template_files, "$form->{formname}_email$form->{language}$form->{printer_code}.$extension" if $form->{media} eq 'email'; |
|
429 |
push @template_files, "$form->{formname}$form->{language}$form->{printer_code}.$extension"; |
|
430 |
push @template_files, "$form->{formname}.$extension"; |
|
431 |
push @template_files, "default.$extension"; |
|
432 |
|
|
433 |
$form->{IN} = undef; |
|
434 |
for my $filename (@template_files) { |
|
435 |
if (-f "$form->{templates}/$filename") { |
|
436 |
$form->{IN} = $filename; |
|
437 |
last; |
|
438 |
} |
|
413 | 439 |
} |
414 | 440 |
|
441 |
if (!defined $form->{IN}) { |
|
442 |
$::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)); |
|
443 |
} |
|
444 |
|
|
445 |
# prepare meta information for template introspection |
|
446 |
$form->{template_meta} = { |
|
447 |
formname => $form->{formname}, |
|
448 |
language => SL::DB::Manager::Language->find_by_or_create(id => $form->{language_id}), |
|
449 |
format => $form->{format}, |
|
450 |
media => $form->{media}, |
|
451 |
extension => $extension, |
|
452 |
printer => SL::DB::Manager::Printer->find_by_or_create(id => $form->{printer_id}), |
|
453 |
today => DateTime->today, |
|
454 |
}; |
|
455 |
|
|
415 | 456 |
$main::lxdebug->leave_sub(); |
416 | 457 |
} |
417 | 458 |
|
Auch abrufbar als: Unified diff
Template Metadaten und default.tex Weiterleitung auch für Mahnungen.