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

(-)a/C4/Templates.pm (-3 / +3 lines)
Lines 256-273 sub themelanguage { Link Here
256
    my $where = $tmpl =~ /xsl$/ ? 'xslt' : 'modules';
256
    my $where = $tmpl =~ /xsl$/ ? 'xslt' : 'modules';
257
    for my $theme (@themes) {
257
    for my $theme (@themes) {
258
        if ( -e "$htdocs/$theme/$lang/$where/$tmpl" ) {
258
        if ( -e "$htdocs/$theme/$lang/$where/$tmpl" ) {
259
            return ( $theme, $lang, uniq( \@themes ) );
259
            return ( $theme, $lang, [ uniq(@themes) ] );
260
        }
260
        }
261
    }
261
    }
262
    # Otherwise return theme/'en', last resort fallback/'en'
262
    # Otherwise return theme/'en', last resort fallback/'en'
263
    for my $theme (@themes) {
263
    for my $theme (@themes) {
264
        if ( -e "$htdocs/$theme/en/$where/$tmpl" ) {
264
        if ( -e "$htdocs/$theme/en/$where/$tmpl" ) {
265
            return ( $theme, 'en', uniq( \@themes ) );
265
            return ( $theme, 'en', [ uniq(@themes) ] );
266
        }
266
        }
267
    }
267
    }
268
    # tmpl is a full path, so this is a template for a plugin
268
    # tmpl is a full path, so this is a template for a plugin
269
    if ( $tmpl =~ /^\// && -e $tmpl ) {
269
    if ( $tmpl =~ /^\// && -e $tmpl ) {
270
        return ( $themes[0], $lang, uniq( \@themes ) );
270
        return ( $themes[0], $lang, [ uniq(@themes) ] );
271
    }
271
    }
272
}
272
}
273
273
(-)a/t/db_dependent/Templates.t (-4 / +14 lines)
Lines 19-26 use Modern::Perl; Link Here
19
19
20
use CGI;
20
use CGI;
21
21
22
use Test::More tests => 5;
22
use Test::More tests => 7;
23
use List::MoreUtils qw/uniq/;
23
use Test::Deep;
24
use Test::Deep;
25
use Test::MockModule;
24
26
25
BEGIN {
27
BEGIN {
26
    use_ok( 'C4::Templates' );
28
    use_ok( 'C4::Templates' );
Lines 45-49 is( scalar @keys, 6, "GetColumnDefs correctly returns the 5 tables defined in co Link Here
45
my @tables = ( 'biblio', 'biblioitems', 'borrowers', 'items', 'statistics', 'subscription');
47
my @tables = ( 'biblio', 'biblioitems', 'borrowers', 'items', 'statistics', 'subscription');
46
cmp_deeply( \@keys, \@tables, "GetColumnDefs returns the expected tables");
48
cmp_deeply( \@keys, \@tables, "GetColumnDefs returns the expected tables");
47
49
48
50
# simple test for themelanguage
49
1;
51
my $mod = Test::MockModule->new( 'C4::Languages' );
52
$mod->mock( 'getlanguage', sub { 'en' } );
53
my @retval = C4::Templates::themelanguage( C4::Context->config('intrahtdocs'),
54
    'about.tt', 'intranet', 'fake_query',
55
);
56
my $themeref = $retval[2];
57
is( @$themeref > 0, 1, 'We still assume to get back at least one theme' );
58
cmp_deeply( $themeref, [ uniq(@$themeref) ], 'Should be unique themes' );
59
60
# End of tests
50
- 

Return to bug 17982