View | Details | Raw Unified | Return to bug 31373
Collapse All | Expand All

(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 1578-1584 sub _process_tt { Link Here
1578
    my $content    = $params->{content};
1578
    my $content    = $params->{content};
1579
    my $tables     = $params->{tables};
1579
    my $tables     = $params->{tables};
1580
    my $loops      = $params->{loops};
1580
    my $loops      = $params->{loops};
1581
    my $objects    = $params->{objects};
1581
    my $objects    = $params->{objects} || {};
1582
    my $substitute = $params->{substitute} || {};
1582
    my $substitute = $params->{substitute} || {};
1583
    my $lang = defined($params->{lang}) && $params->{lang} ne 'default' ? $params->{lang} : 'en';
1583
    my $lang = defined($params->{lang}) && $params->{lang} ne 'default' ? $params->{lang} : 'en';
1584
    my ($theme, $availablethemes);
1584
    my ($theme, $availablethemes);
(-)a/tools/letter.pl (-29 / +10 lines)
Lines 42-48 Link Here
42
42
43
use Modern::Perl;
43
use Modern::Perl;
44
use CGI qw ( -utf8 );
44
use CGI qw ( -utf8 );
45
use Template;
45
use Try::Tiny;
46
46
47
use C4::Auth qw( get_template_and_user );
47
use C4::Auth qw( get_template_and_user );
48
use C4::Context;
48
use C4::Context;
Lines 197-225 sub add_form { Link Here
197
        my $first_flag_name = 1;
197
        my $first_flag_name = 1;
198
        my $lang;
198
        my $lang;
199
199
200
        # Get available includes
201
        my $htdocs = C4::Context->config('intrahtdocs');
202
        my ($theme, $availablethemes);
203
        ($theme, $lang, $availablethemes)= C4::Templates::availablethemes( $htdocs, 'about.tt', 'intranet', $lang);
204
        my @includes;
205
        foreach (@$availablethemes) {
206
            push @includes, "$htdocs/$_/$lang/includes";
207
            push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en';
208
        }
209
210
        # The letter name is contained into each mtt row.
200
        # The letter name is contained into each mtt row.
211
        # So we can only sent the first one to the template.
201
        # So we can only sent the first one to the template.
212
        my $tt = Template->new(
213
            {
214
                EVAL_PERL   => 1,
215
                ABSOLUTE    => 1,
216
                PLUGIN_BASE => 'Koha::Template::Plugin',
217
                INCLUDE_PATH => \@includes,
218
                FILTERS     => {},
219
                ENCODING    => 'UTF-8',
220
            }
221
        );
222
223
        for my $letter ( @$letters ) {
202
        for my $letter ( @$letters ) {
224
            # The letter_name
203
            # The letter_name
225
            if ( $first_flag_name and $letter->{name} ) {
204
            if ( $first_flag_name and $letter->{name} ) {
Lines 229-240 sub add_form { Link Here
229
                $first_flag_name = 0;
208
                $first_flag_name = 0;
230
            }
209
            }
231
210
232
            my $output;
211
            # Catch template issues
233
            my $template = $letter->{content};
212
            try {
234
            $template = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %][% PROCESS 'html_helpers.inc' %]$template|;
213
                C4::Letters::_process_tt($letter);
235
            unless ( $tt->process( \$template, {}, \$output ) ) {
214
            } catch {
236
                $letter->{tt_error} = $tt->error();
215
                my $error = $_;
237
            }
216
                $error =~ s/^ERROR PROCESSING TEMPLATE: //;
217
                $error =~ s/at .*\/tools\/letter\.pl line 213\.$//;
218
                $letter->{tt_error} = $error;
219
            };
238
220
239
            my $lang = $letter->{lang};
221
            my $lang = $letter->{lang};
240
            my $mtt = $letter->{message_transport_type};
222
            my $mtt = $letter->{message_transport_type};
241
- 

Return to bug 31373