X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate.pm;h=b20a7b1a3b5a25c55713b0daa10a53f972162e11;hb=a27846ef2756ed0f59c29d256a5d43d6caaf0b58;hp=ab499e99d289e43ae600ff1701f2848d9adc26c1;hpb=72585c35d48589e072325ffc46c720df080e2ca1;p=kivitendo-erp.git diff --git a/SL/Template.pm b/SL/Template.pm index ab499e99d..b20a7b1a3 100644 --- a/SL/Template.pm +++ b/SL/Template.pm @@ -10,6 +10,8 @@ package SL::Template; use strict; +use IO::Dir; + use SL::Template::Simple; use SL::Template::Excel; use SL::Template::HTML; @@ -17,13 +19,44 @@ use SL::Template::LaTeX; use SL::Template::OpenDocument; use SL::Template::PlainText; use SL::Template::ShellCommand; -use SL::Template::XML; sub create { my %params = @_; my $package = "SL::Template::" . $params{type}; - $package->new($params{file_name}, $params{form}, $params{myconfig} || \%::myconfig, $params{userspath} || $::lx_office_conf{paths}->{userspath}); + $package->new( + %params, + source => $params{file_name}, + form => $params{form}, + myconfig => $params{myconfig} || \%::myconfig, + userspath => $params{userspath} || $::lx_office_conf{paths}->{userspath}, + ); +} + +sub available_templates { + my ($class) = @_; + + # is there a templates basedir + if (!-d $::lx_office_conf{paths}->{templates}) { + $::form->error(sprintf($::locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates})); + } + + tie my %dir_h, 'IO::Dir', $::lx_office_conf{paths}->{templates}; + + my @alldir = sort grep { + -d ($::lx_office_conf{paths}->{templates} . "/$_") + && !/^\.\.?$/ + && !m/\.(?:html|tex|sty|odt)$/ + && !m/^(?:webpages$|mobile_webpages$|pdf$|print$|mail$|\.)/ + } keys %dir_h; + + tie %dir_h, 'IO::Dir', "$::lx_office_conf{paths}->{templates}/print"; + my @allmaster = (sort grep { -d ("$::lx_office_conf{paths}->{templates}/print" . "/$_") && !/^\.\.?$/ && !/^Standard$/ } keys %dir_h); + + return ( + print_templates => \@alldir, + master_templates => \@allmaster, + ); } 1;