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

(-)a/koha-tmpl/opac-tmpl/lib/pz2.js (-2 / +16 lines)
Lines 1-6 Link Here
1
/*
1
/*
2
 * $Id: 3a9980787bb5d0fe966140b243a4a5eb6768913e $
2
 * pz2.js - pazpar2's javascript client library.
3
** pz2.js - pazpar2's javascript client library.
3
 * Copyright (C) 2006-2013 Index Data.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
4
*/
18
*/
5
19
6
//since explorer is flawed
20
//since explorer is flawed
(-)a/opac/opac-external-search.pl (-11 / +11 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2009 BibLibre SARL
3
# Copyright 2013 ByWater Solutions
4
#
4
#
5
# This file is part of Koha.
5
# This file is part of Koha.
6
#
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
7
# Koha is free software; you can redistribute it and/or modify it
8
# terms of the GNU General Public License as published by the Free Software
8
# under the terms of the GNU General Public License as published by
9
# Foundation; either version 2 of the License, or (at your option) any later
9
# the Free Software Foundation; either version 3 of the License, or
10
# version.
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
(-)a/opac/svc/pazpar2_init (-13 / +14 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2013 ByWater
3
# Copyright 2013 ByWater Solutions
4
#
4
#
5
# This file is part of Koha.
5
# This file is part of Koha.
6
#
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
7
# Koha is free software; you can redistribute it and/or modify it
8
# terms of the GNU General Public License as published by the Free Software
8
# under the terms of the GNU General Public License as published by
9
# Foundation; either version 2 of the License, or (at your option) any later
9
# the Free Software Foundation; either version 3 of the License, or
10
# version.
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
=head1 NAME
20
=head1 NAME
21
21
Lines 23-34 svc/pazpar2_init: Initialize a Pazpar2 session Link Here
23
23
24
=head1 SYNOPSIS
24
=head1 SYNOPSIS
25
25
26
svc/pazpar2_init?targets=3,5,9 -> ../pazpar2/search.pz2?command=init&...
26
svc/pazpar2_init -> ../pazpar2/search.pz2?command=init&...
27
27
28
=head1 DESCRIPTION
28
=head1 DESCRIPTION
29
29
30
This services connects to pazpar2 and authenticates connections on behalf of
30
This services connects to pazpar2 and authenticates connections on behalf of
31
client-side search code.
31
client-side search code. The proxy is necessary to prevent exposing
32
authentication information.
32
33
33
=cut
34
=cut
34
35
(-)a/t/XSLT.t (-16 / +79 lines)
Lines 6-12 Link Here
6
use strict;
6
use strict;
7
use warnings;
7
use warnings;
8
8
9
use Test::More tests => 8;
9
use C4::Context;
10
use C4::Templates;
11
use Test::More tests => 13;
12
use Test::MockModule;
13
use File::Basename qw/dirname/;
10
use File::Temp;
14
use File::Temp;
11
use File::Path qw/make_path/;
15
use File::Path qw/make_path/;
12
16
Lines 14-49 BEGIN { Link Here
14
        use_ok('C4::XSLT');
18
        use_ok('C4::XSLT');
15
}
19
}
16
20
17
my $dir = File::Temp->newdir();
21
my $opacdir = File::Temp->newdir();
22
my $staffdir = File::Temp->newdir();
18
my @themes = ('prog', 'test');
23
my @themes = ('prog', 'test');
19
my @langs = ('en', 'es-ES');
24
my @langs = ('en', 'es-ES');
20
25
26
sub make_test_file {
27
    my ( $filename, $contents ) = @_;
28
29
    make_path(dirname($filename));
30
    open my $fh, '>', $filename or die "Could not create test file: $filename";
31
    print $fh $contents;
32
    close $fh;
33
}
34
21
# create temporary files to be tested later
35
# create temporary files to be tested later
22
foreach my $theme (@themes) {
36
foreach my $theme (@themes) {
23
    foreach my $lang (@langs) {
37
    foreach my $lang (@langs) {
24
        make_path("$dir/$theme/$lang/xslt");
38
        foreach my $dir ($opacdir, $staffdir) {
25
        open my $fh, '>', "$dir/$theme/$lang/xslt/my_file.xslt";
39
            make_test_file( "$dir/$theme/$lang/xslt/my_file.xslt", "Theme $theme, language $lang" );
26
        print $fh "Theme $theme, language $lang";
40
            make_test_file( "$dir/$theme/$lang/xslt/MARC21slim2intranetDetail.xsl", "Theme $theme, language $lang, MARC21slim2intranetDetail" );
27
        close $fh;
41
            make_test_file( "$dir/$theme/$lang/xslt/test_en.xsl", "Theme $theme, language $lang, test_en" );
42
            make_test_file( "$dir/$theme/$lang/xslt/UNIMARCslim2OPACDetail.xsl", "Theme $theme, language $lang, UNIMARCslim2OPACDetail" );
43
            make_test_file( "$dir/$theme/$lang/xslt/nondefault_test.xsl", "Theme $theme, language $lang, nondefault_test" );
44
            make_test_file( "$dir/$theme/$lang/xslt/MARC21slim2OPACResults.xsl", "Theme $theme, language $lang, MARC21slim2OPACResults" );
45
        }
28
    }
46
    }
29
}
47
}
30
48
31
sub find_and_slurp {
49
sub find_and_slurp_default {
32
    my ($dir, $theme, $lang) = @_;
50
    my ($dir, $theme, $lang) = @_;
33
51
34
    my $filename = C4::XSLT::_get_best_default_xslt_filename($dir, $theme, $lang, 'my_file.xslt');
52
    my $filename = C4::XSLT::_get_best_default_xslt_filename($dir, $theme, $lang, 'my_file.xslt');
35
    open my $fh, '<', $filename;
53
    open my $fh, '<', $filename or return "Could not open: $filename";
36
    my $str = <$fh>;
54
    my $str = <$fh>;
37
    close $fh;
55
    close $fh;
38
    return $str;
56
    return $str;
39
}
57
}
40
58
59
sub find_and_slurp {
60
    my ($marcflavour, $xslsyspref) = @_;
61
62
    my $filename = C4::XSLT::XSLTGetFilename( $marcflavour, $xslsyspref );
63
    open my $fh, '<', $filename or return "Could not open: $filename";
64
    my $str = <$fh>;
65
    close $fh;
66
    return $str;
67
}
68
69
my $module_context = new Test::MockModule('C4::Context');
70
$module_context->mock(
71
    'config',
72
    sub {
73
        my ( $self, $var ) = @_;
74
        my %predefs = (
75
            opachtdocs => $opacdir,
76
            intrahtdocs => $staffdir,
77
        );
78
79
        return $predefs{$var} || $module_context->original('config')->(@_);
80
    }
81
);
82
$module_context->mock(
83
    'preference',
84
    sub {
85
        my ( $self, $var ) = @_;
86
        my %predefs = (
87
            template => 'prog',
88
            marcflavour => 'MARC21',
89
            opacthemes => 'test',
90
            XSLTDetailsDisplay => 'default',
91
            XSLTResultsDisplay => "$staffdir/prog/en/xslt/test_en.xsl",
92
            OPACXSLTDetailsDisplay => "$opacdir/test/en/xslt/nondefault_test.xsl",
93
            OPACXSLTResultsDisplay => '"default"',
94
        );
95
96
        return $predefs{$var} || $module_context->original('preference')->(@_);
97
    }
98
);
99
41
# These tests verify that we're finding the right XSLT file when present,
100
# These tests verify that we're finding the right XSLT file when present,
42
# and falling back to the right XSLT file when an exact match is not present.
101
# and falling back to the right XSLT file when an exact match is not present.
43
is(find_and_slurp($dir, 'test', 'en'   ), 'Theme test, language en',    'Found test/en');
102
is(find_and_slurp_default($opacdir, 'test', 'en'   ), 'Theme test, language en',    'Found test/en');
44
is(find_and_slurp($dir, 'test', 'es-ES'), 'Theme test, language es-ES', 'Found test/es-ES');
103
is(find_and_slurp_default($opacdir, 'test', 'es-ES'), 'Theme test, language es-ES', 'Found test/es-ES');
45
is(find_and_slurp($dir, 'prog', 'en',  ), 'Theme prog, language en',    'Found test/en');
104
is(find_and_slurp_default($opacdir, 'prog', 'en',  ), 'Theme prog, language en',    'Found test/en');
46
is(find_and_slurp($dir, 'prog', 'es-ES'), 'Theme prog, language es-ES', 'Found test/es-ES');
105
is(find_and_slurp_default($opacdir, 'prog', 'es-ES'), 'Theme prog, language es-ES', 'Found test/es-ES');
47
is(find_and_slurp($dir, 'test', 'fr-FR'), 'Theme test, language en',    'Fell back to test/en for test/fr-FR');
106
is(find_and_slurp_default($opacdir, 'test', 'fr-FR'), 'Theme test, language en',    'Fell back to test/en for test/fr-FR');
48
is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
107
is(find_and_slurp_default($opacdir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
49
is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
108
is(find_and_slurp_default($opacdir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
109
is(find_and_slurp('MARC21', 'XSLTDetailsDisplay'), 'Theme prog, language en, MARC21slim2intranetDetail', 'Used default for staff/details');
110
is(find_and_slurp('MARC21', 'XSLTResultsDisplay'), 'Theme prog, language en, test_en', 'Used non-default with langcode for staff/results');
111
is(find_and_slurp('MARC21', 'OPACXSLTDetailsDisplay'), 'Theme test, language en, nondefault_test', 'not-prog: Used non-default for local marcflavour and opac/details');
112
is(find_and_slurp('UNIMARC', 'OPACXSLTDetailsDisplay'), 'Theme test, language en, UNIMARCslim2OPACDetail', 'not-prog: Used default for non-local marcflavour and opac/details');
113
is(find_and_slurp('MARC21', 'OPACXSLTResultsDisplay'), 'Theme test, language en, MARC21slim2OPACResults', 'not-prog: Used "default" for opac/results');
50
- 

Return to bug 10486