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

(-)a/C4/Templates.pm (+5 lines)
Lines 61-66 sub new { Link Here
61
        push @includes, "$htdocs/$_/$lang/includes";
61
        push @includes, "$htdocs/$_/$lang/includes";
62
        push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en';
62
        push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en';
63
    }
63
    }
64
65
    my @plugins_include_paths = Koha::Plugins->call( 'template_include_paths',
66
        { interface => $interface, lang => $lang } );
67
    push @includes, map { $_ ? @$_ : () } @plugins_include_paths;
68
64
    # Do not use template cache if script is called from commandline
69
    # Do not use template cache if script is called from commandline
65
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
70
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
66
    my $template = Template->new(
71
    my $template = Template->new(
(-)a/t/db_dependent/Koha/Plugins/TemplateIncludePathHook.t (+57 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
17
use Modern::Perl;
18
19
use Test::More tests => 4;
20
use Test::MockModule;
21
use Test::Warn;
22
23
use File::Basename;
24
25
26
BEGIN {
27
    # Mock pluginsdir before loading Plugins module
28
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
29
    require t::lib::Mocks;
30
    t::lib::Mocks::mock_config( 'enable_plugins', 1 );
31
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
32
33
    use_ok('Koha::Plugins');
34
    use_ok('Koha::Plugins::Handler');
35
    use_ok('Koha::Plugin::Test');
36
}
37
38
my $schema  = Koha::Database->new->schema;
39
40
subtest 'template_include_paths' => sub {
41
    plan tests => 1;
42
43
    $schema->storage->txn_begin;
44
45
    Koha::Plugins->new->InstallPlugins();
46
    Koha::Plugin::Test->new->enable;
47
48
    require C4::Templates;
49
    my $c4_template = C4::Templates::gettemplate('intranet-main.tt', 'intranet');
50
    my $template = $c4_template->{TEMPLATE};
51
    my $output = '';
52
    $template->process(\"[% INCLUDE test.inc %]", {}, \$output) || die $template->error();
53
    is($output, 'included content');
54
55
    $schema->storage->txn_commit;
56
    #Koha::Plugins::Methods->delete;
57
};
(-)a/t/lib/plugins/Koha/Plugin/Test.pm (+8 lines)
Lines 369-374 sub after_recall_action { Link Here
369
        "after_recall_action called with action: $action, ref: " . ref($recall) );
369
        "after_recall_action called with action: $action, ref: " . ref($recall) );
370
}
370
}
371
371
372
sub template_include_paths {
373
    my ($self) = @_;
374
375
    return [
376
        $self->mbf_path('inc'),
377
    ];
378
}
379
372
sub _private_sub {
380
sub _private_sub {
373
    return "";
381
    return "";
374
}
382
}
(-)a/t/lib/plugins/Koha/Plugin/Test/inc/test.inc (-1 / +1 lines)
Line 0 Link Here
0
- 
1
[% 'included content' ~%]

Return to bug 35070