Manage template inclusion when file is not in configured portal theme (#1653)
This commit is contained in:
parent
413cc98fba
commit
ae3a728378
|
@ -17,7 +17,7 @@ has languages => ( is => 'rw', isa => 'Str', default => 'en' );
|
||||||
has logLevel => ( is => 'rw', isa => 'Str', default => 'info' );
|
has logLevel => ( is => 'rw', isa => 'Str', default => 'info' );
|
||||||
has portal => ( is => 'rw', isa => 'Str' );
|
has portal => ( is => 'rw', isa => 'Str' );
|
||||||
has staticPrefix => ( is => 'rw', isa => 'Str' );
|
has staticPrefix => ( is => 'rw', isa => 'Str' );
|
||||||
has templateDir => ( is => 'rw', isa => 'Str' );
|
has templateDir => ( is => 'rw', isa => 'Str|ArrayRef' );
|
||||||
has links => ( is => 'rw', isa => 'ArrayRef' );
|
has links => ( is => 'rw', isa => 'ArrayRef' );
|
||||||
has menuLinks => ( is => 'rw', isa => 'ArrayRef' );
|
has menuLinks => ( is => 'rw', isa => 'ArrayRef' );
|
||||||
has logger => ( is => 'rw' );
|
has logger => ( is => 'rw' );
|
||||||
|
@ -250,6 +250,7 @@ sub sendHtml {
|
||||||
$htpl = HTML::Template->new(
|
$htpl = HTML::Template->new(
|
||||||
filehandle => IO::File->new($template),
|
filehandle => IO::File->new($template),
|
||||||
path => $self->templateDir,
|
path => $self->templateDir,
|
||||||
|
search_path_on_include => 1,
|
||||||
die_on_bad_params => 0,
|
die_on_bad_params => 0,
|
||||||
die_on_missing_include => 1,
|
die_on_missing_include => 1,
|
||||||
cache => 0,
|
cache => 0,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use Email::Sender::Transport::SMTP qw();
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
use Encode;
|
use Encode;
|
||||||
|
|
||||||
our $VERSION = '2.0.2';
|
our $VERSION = '2.0.3';
|
||||||
|
|
||||||
our $transport;
|
our $transport;
|
||||||
|
|
||||||
|
@ -184,8 +184,10 @@ sub send_mail {
|
||||||
foreach ( keys %cid ) {
|
foreach ( keys %cid ) {
|
||||||
$message->attach(
|
$message->attach(
|
||||||
Type => "image/" . ( $cid{$_} =~ m/\.(\w+)/ )[0],
|
Type => "image/" . ( $cid{$_} =~ m/\.(\w+)/ )[0],
|
||||||
Id => $_,
|
Id => $_,
|
||||||
Path => $self->p->{templateDir} . "/" . $cid{$_},
|
Path => $self->conf->{templateDir} . "/"
|
||||||
|
. $self->conf->{portalSkin} . "/"
|
||||||
|
. $cid{$_},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,6 +194,8 @@ sub reloadConf {
|
||||||
$self->error("Template dir $self->{templateDir} doesn't exist");
|
$self->error("Template dir $self->{templateDir} doesn't exist");
|
||||||
return $self->fail;
|
return $self->fail;
|
||||||
}
|
}
|
||||||
|
$self->templateDir(
|
||||||
|
[ $self->{templateDir}, $self->conf->{templateDir} . '/bootstrap' ] );
|
||||||
|
|
||||||
$self->{staticPrefix} = $self->conf->{staticPrefix} || '/static';
|
$self->{staticPrefix} = $self->conf->{staticPrefix} || '/static';
|
||||||
$self->{languages} = $self->conf->{languages} || '/';
|
$self->{languages} = $self->conf->{languages} || '/';
|
||||||
|
|
|
@ -743,6 +743,7 @@ sub sendHtml {
|
||||||
my ( $self, $req, $template, %args ) = @_;
|
my ( $self, $req, $template, %args ) = @_;
|
||||||
|
|
||||||
my $templateDir = $self->conf->{templateDir} . '/' . $self->getSkin($req);
|
my $templateDir = $self->conf->{templateDir} . '/' . $self->getSkin($req);
|
||||||
|
$self->templateDir( [ $templateDir, @{ $self->templateDir } ] );
|
||||||
|
|
||||||
# Check template
|
# Check template
|
||||||
$args{templateDir} = $templateDir;
|
$args{templateDir} = $templateDir;
|
||||||
|
@ -1004,17 +1005,14 @@ sub _sumUpSession {
|
||||||
sub loadTemplate {
|
sub loadTemplate {
|
||||||
my ( $self, $name, %prm ) = @_;
|
my ( $self, $name, %prm ) = @_;
|
||||||
$name .= '.tpl';
|
$name .= '.tpl';
|
||||||
my $file =
|
|
||||||
$self->conf->{templateDir} . '/'
|
|
||||||
. $self->conf->{portalSkin} . '/'
|
|
||||||
. $name;
|
|
||||||
$file = $self->conf->{templateDir} . '/common/' . $name
|
|
||||||
unless ( -e $file );
|
|
||||||
unless ( -e $file ) {
|
|
||||||
die "Unable to find $name in $self->conf->{templateDir}";
|
|
||||||
}
|
|
||||||
my $tpl = HTML::Template->new(
|
my $tpl = HTML::Template->new(
|
||||||
filename => $file,
|
filename => $name,
|
||||||
|
path => [
|
||||||
|
$self->conf->{templateDir} . '/' . $self->conf->{portalSkin},
|
||||||
|
$self->conf->{templateDir} . '/bootstrap/',
|
||||||
|
$self->conf->{templateDir} . '/common/'
|
||||||
|
],
|
||||||
|
search_path_on_include => 1,
|
||||||
die_on_bad_params => 0,
|
die_on_bad_params => 0,
|
||||||
die_on_missing_include => 1,
|
die_on_missing_include => 1,
|
||||||
cache => 1,
|
cache => 1,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user