kivitendo/SL/Template.pm @ 79b7fc43
54e4131e | Moritz Bunkus | #====================================================================
|
||
# LX-Office ERP
|
||||
# Copyright (C) 2004
|
||||
# Based on SQL-Ledger Version 2.1.9
|
||||
# Web http://www.lx-office.org
|
||||
#
|
||||
#====================================================================
|
||||
0fba3edd | Moritz Bunkus | package SL::Template;
|
||
54e4131e | Moritz Bunkus | |||
c510d88b | Sven Schöling | use strict;
|
||
9ead220c | Moritz Bunkus | use IO::Dir;
|
||
0fba3edd | Moritz Bunkus | use SL::Template::Simple;
|
||
use SL::Template::Excel;
|
||||
use SL::Template::HTML;
|
||||
use SL::Template::LaTeX;
|
||||
use SL::Template::OpenDocument;
|
||||
use SL::Template::PlainText;
|
||||
72585c35 | Moritz Bunkus | use SL::Template::ShellCommand;
|
||
0fba3edd | Moritz Bunkus | use SL::Template::XML;
|
||
90815a31 | Joachim Zach | |||
0fba3edd | Moritz Bunkus | sub create {
|
||
my %params = @_;
|
||||
my $package = "SL::Template::" . $params{type};
|
||||
90815a31 | Joachim Zach | |||
7e0814bb | Moritz Bunkus | $package->new(
|
||
%params,
|
||||
source => $params{file_name},
|
||||
form => $params{form},
|
||||
myconfig => $params{myconfig} || \%::myconfig,
|
||||
userspath => $params{userspath} || $::lx_office_conf{paths}->{userspath},
|
||||
);
|
||||
90815a31 | Joachim Zach | }
|
||
9ead220c | Moritz Bunkus | 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|xml|txb)$/
|
||||
&& !m/^(?:webpages$|print$|mail$|\.)/
|
||||
} keys %dir_h;
|
||||
tie %dir_h, 'IO::Dir', "$::lx_office_conf{paths}->{templates}/print";
|
||||
my @allmaster = ('Standard', sort grep { -d ("$::lx_office_conf{paths}->{templates}/print" . "/$_") && !/^\.\.?$/ && !/^Standard$/ } keys %dir_h);
|
||||
return (
|
||||
print_templates => \@alldir,
|
||||
master_templates => \@allmaster,
|
||||
);
|
||||
}
|
||||
54e4131e | Moritz Bunkus | 1;
|