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

(-)a/C4/External/Amazon.pm (-80 lines)
Lines 1-80 Link Here
1
package C4::External::Amazon;
2
3
# Copyright (C) 2006 LibLime
4
# <jmf at liblime dot com>
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# Koha is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with Koha; if not, see <https://www.gnu.org/licenses>.
20
21
use strict;
22
use warnings;
23
24
use vars qw(@ISA @EXPORT);
25
26
BEGIN {
27
    require Exporter;
28
    @ISA    = qw(Exporter);
29
    @EXPORT = qw(
30
        get_amazon_tld
31
    );
32
}
33
34
sub get_amazon_tld {
35
    my %tld = (
36
        CA => '.ca',
37
        DE => '.de',
38
        FR => '.fr',
39
        IN => '.in',
40
        JP => '.jp',
41
        UK => '.co.uk',
42
        US => '.com',
43
    );
44
45
    my $locale = C4::Context->preference('AmazonLocale');
46
    my $tld    = $tld{$locale} || '.com';                   # default top level domain is .com
47
    return $tld;
48
}
49
50
=head1 NAME
51
52
C4::External::Amazon - Functions for retrieving Amazon.com content in Koha
53
54
=head2 FUNCTIONS
55
56
This module provides facilities for retrieving Amazon.com content in Koha
57
58
=over
59
60
=item get_amazon_tld()
61
62
Get Amazon Top Level Domain depending on Amazon local preference: AmazonLocal.
63
For example, if AmazonLocal is 'UK', returns '.co.uk'.
64
65
=back
66
67
=cut
68
69
1;
70
__END__
71
72
=head1 NOTES
73
74
=cut
75
76
=head1 AUTHOR
77
78
Joshua Ferraro <jmf@liblime.com>
79
80
=cut
(-)a/catalogue/detail.pl (-8 / +6 lines)
Lines 34-46 use C4::Output qw( output_html_with_http_headers ); Link Here
34
use C4::Biblio  qw( GetBiblioData GetFrameworkCode );
34
use C4::Biblio  qw( GetBiblioData GetFrameworkCode );
35
use C4::Items   qw( GetAnalyticsCount );
35
use C4::Items   qw( GetAnalyticsCount );
36
use C4::Reserves;
36
use C4::Reserves;
37
use C4::Serials          qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
37
use C4::Serials     qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
38
use C4::XISBN            qw( get_xisbns );
38
use C4::XISBN       qw( get_xisbns );
39
use C4::External::Amazon qw( get_amazon_tld );
39
use C4::Search      qw( z3950_search_args enabled_staff_search_views new_record_from_zebra );
40
use C4::Search           qw( z3950_search_args enabled_staff_search_views new_record_from_zebra );
40
use C4::Tags        qw( get_tags );
41
use C4::Tags             qw( get_tags );
41
use C4::XSLT        qw( XSLTParse4Display );
42
use C4::XSLT             qw( XSLTParse4Display );
42
use Koha::DateUtils qw( format_sqldatetime );
43
use Koha::DateUtils      qw( format_sqldatetime );
44
use C4::HTML5Media;
43
use C4::HTML5Media;
45
use C4::CourseReserves qw( GetItemCourseReservesInfo );
44
use C4::CourseReserves qw( GetItemCourseReservesInfo );
46
use Koha::AuthorisedValues;
45
use Koha::AuthorisedValues;
Lines 434-440 foreach ( keys %{$dat} ) { Link Here
434
433
435
# does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews');
434
# does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews');
436
# method query not found?!?!
435
# method query not found?!?!
437
$template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages") );
438
$template->param(
436
$template->param(
439
    biblionumber                            => $biblionumber,
437
    biblionumber                            => $biblionumber,
440
    ( $analyze ? 'analyze' : 'detailview' ) => 1,
438
    ( $analyze ? 'analyze' : 'detailview' ) => 1,
(-)a/installer/data/mysql/atomicupdate/bug_41318.pl (+34 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "41318",
6
    description => "Rename system preference AmazonLocale to AmazonLocaleTld",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        my $pref_exists =
12
            $dbh->selectrow_array(q{SELECT COUNT(*) FROM systempreferences WHERE variable = "AmazonLocale"});
13
        if ($pref_exists) {
14
            $dbh->do(
15
                q{
16
                UPDATE systempreferences
17
                SET `variable`="AmazonLocaleTld",
18
                    `explanation`="Use to set the locale top-level domain (tld) of your Amazon web services",
19
                    `type`="free",
20
                    `value` = CASE `value`
21
                            WHEN 'CA' THEN 'ca'
22
                            WHEN 'UK' THEN 'co.uk'
23
                            WHEN 'DE' THEN 'de'
24
                            WHEN 'FR' THEN 'fr'
25
                            WHEN 'IN' THEN 'in'
26
                            WHEN 'JP' THEN 'jp'
27
                            ELSE 'com'
28
                        END
29
                WHERE `variable`="AmazonLocale"
30
            }
31
            ) && say $out "Renamed system preference 'AmazonLocale' to 'AmazonLocaleTld";
32
        }
33
    },
34
};
(-)a/installer/data/mysql/localization/de-DE/custom.sql (-1 / +1 lines)
Lines 16-22 Link Here
16
-- You should have received a copy of the GNU General Public License
16
-- You should have received a copy of the GNU General Public License
17
-- along with Koha; if not, see <https://www.gnu.org/licenses>.
17
-- along with Koha; if not, see <https://www.gnu.org/licenses>.
18
18
19
UPDATE systempreferences SET value = 'DE' WHERE variable = 'AmazonLocale';
19
UPDATE systempreferences SET value = 'de' WHERE variable = 'AmazonLocaleTld';
20
UPDATE systempreferences SET value = 'Vater|Mutter' WHERE variable = 'borrowerRelationship';
20
UPDATE systempreferences SET value = 'Vater|Mutter' WHERE variable = 'borrowerRelationship';
21
UPDATE systempreferences SET value = 'Herr|Frau' WHERE variable = 'BorrowersTitles';
21
UPDATE systempreferences SET value = 'Herr|Frau' WHERE variable = 'BorrowersTitles';
22
UPDATE systempreferences SET value = 'FR' WHERE variable = 'CurencyFormat';
22
UPDATE systempreferences SET value = 'FR' WHERE variable = 'CurencyFormat';
(-)a/installer/data/mysql/localization/fr-CA/custom.sql (-1 / +1 lines)
Lines 17-23 Link Here
17
-- along with Koha; if not, see <https://www.gnu.org/licenses>.
17
-- along with Koha; if not, see <https://www.gnu.org/licenses>.
18
18
19
UPDATE systempreferences SET value = 'fre|eng' WHERE variable = 'AdvancedSearchLanguages';
19
UPDATE systempreferences SET value = 'fre|eng' WHERE variable = 'AdvancedSearchLanguages';
20
UPDATE systempreferences SET value = 'CA' WHERE variable = 'AmazonLocale';
20
UPDATE systempreferences SET value = 'ca' WHERE variable = 'AmazonLocaleTld';
21
UPDATE systempreferences SET value = 'père|mère|grand-parent|tuteur légal|autre' WHERE variable = 'borrowerRelationship';
21
UPDATE systempreferences SET value = 'père|mère|grand-parent|tuteur légal|autre' WHERE variable = 'borrowerRelationship';
22
UPDATE systempreferences SET value = 'M.|Mme|Mx' WHERE variable = 'BorrowersTitles';
22
UPDATE systempreferences SET value = 'M.|Mme|Mx' WHERE variable = 'BorrowersTitles';
23
UPDATE systempreferences SET value = 'FR' WHERE variable = 'CurencyFormat';
23
UPDATE systempreferences SET value = 'FR' WHERE variable = 'CurencyFormat';
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 60-66 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
60
('AlwaysShowHoldingsTableFilters','0','','Option to always show filters when loading the holdings table','YesNo'),
60
('AlwaysShowHoldingsTableFilters','0','','Option to always show filters when loading the holdings table','YesNo'),
61
('AmazonAssocTag','','','See:  http://aws.amazon.com','free'),
61
('AmazonAssocTag','','','See:  http://aws.amazon.com','free'),
62
('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'),
62
('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'),
63
('AmazonLocale','US','US|CA|DE|FR|IN|JP|UK','Use to set the Locale of your Amazon.com Web Services','Choice'),
63
('AmazonLocaleTld','com','','Use to set the locale top-level domain (tld) of your Amazon web services','free'),
64
('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'),
64
('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'),
65
('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''),
65
('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''),
66
('ApplyFrameworkDefaults', 'new', 'new|duplicate|changed|imported', 'Configure when to apply framework default values - when cataloguing a new record, or when editing a record as new (duplicating), or when changing framework, or when importing a record', 'multiple'),
66
('ApplyFrameworkDefaults', 'new', 'new|duplicate|changed|imported', 'Configure when to apply framework default values - when cataloguing a new record, or when editing a record as new (duplicating), or when changing framework, or when importing a record', 'multiple'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref (-11 / +13 lines)
Lines 18-34 Enhanced content: Link Here
18
            - other editions of an item on the OPAC.
18
            - other editions of an item on the OPAC.
19
    Amazon:
19
    Amazon:
20
        -
20
        -
21
            - Use Amazon data from its
21
            - Use Amazon data using the following top-level domain
22
            - pref: AmazonLocale
22
            - pref: AmazonLocaleTld
23
              choices:
23
            - .
24
                  US: American
24
            - '<br />Options:<ul>'
25
                  CA: Canadian
25
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="com">com</a>" for American</li>'
26
                  DE: German
26
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="com.br">com.br</a>" for Brazilian</li>'
27
                  FR: French
27
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="co.uk">co.uk</a>" for British</li>'
28
                  IN: Indian
28
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="ca">ca</a>" for Canadian</li>'
29
                  JP: Japanese
29
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="fr">fr</a>" for French</li>'
30
                  UK: British
30
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="de">de</a>" for German</li>'
31
            - website.
31
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="in">in</a>" for Indian</li>'
32
            - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="jp">jp</a>" for Japanese</li>'
33
            - '</ul>'
32
        -
34
        -
33
            - Put the associate tag
35
            - Put the associate tag
34
            - pref: AmazonAssocTag
36
            - pref: AmazonAssocTag
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +1 lines)
Lines 262-268 Link Here
262
                                <img
262
                                <img
263
                                    src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.MZZZZZZZ.jpg"
263
                                    src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.MZZZZZZZ.jpg"
264
                                    alt="Amazon cover image"
264
                                    alt="Amazon cover image"
265
                                    data-link="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"
265
                                    data-link="http://www.amazon.[% Koha.Preference('AmazonLocaleTld') | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"
266
                                />
266
                                />
267
                            </a>
267
                            </a>
268
                            <div class="hint">Image from Amazon.com</div>
268
                            <div class="hint">Image from Amazon.com</div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/cover-images.inc (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE ItemTypes %]
3
[% USE ItemTypes %]
3
<div
4
<div
4
    class="bookcover"
5
    class="bookcover"
Lines 33-39 Link Here
33
                        src="https://images-na.ssl-images-amazon.com/images/P/[% SEARCH_RESULT.normalized_isbn | uri %].01.MZZZZZZZ.jpg"
34
                        src="https://images-na.ssl-images-amazon.com/images/P/[% SEARCH_RESULT.normalized_isbn | uri %].01.MZZZZZZZ.jpg"
34
                        alt="Amazon cover image"
35
                        alt="Amazon cover image"
35
                        id="amazon-thumbnail-[% SEARCH_RESULT.biblionumber | html %]"
36
                        id="amazon-thumbnail-[% SEARCH_RESULT.biblionumber | html %]"
36
                        data-link="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% SEARCH_RESULT.normalized_isbn | html %][% AmazonAssocTag | html %]#reader-link"
37
                        data-link="http://www.amazon.[% Koha.Preference('AmazonLocaleTld') | uri %]/gp/reader/[% SEARCH_RESULT.normalized_isbn | html %][% AmazonAssocTag | html %]#reader-link"
37
                    />
38
                    />
38
                </a>
39
                </a>
39
                <div class="hint">Image from Amazon.com</div>
40
                <div class="hint">Image from Amazon.com</div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-1 / +1 lines)
Lines 100-106 Link Here
100
                                        <img
100
                                        <img
101
                                            src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.MZZZZZZZ.jpg"
101
                                            src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.MZZZZZZZ.jpg"
102
                                            alt="Amazon cover image"
102
                                            alt="Amazon cover image"
103
                                            data-link="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"
103
                                            data-link="http://www.amazon.[% Koha.Preference('AmazonLocaleTld') | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"
104
                                        />
104
                                        />
105
                                    </a>
105
                                    </a>
106
                                    <div class="hint">Image from Amazon.com</div>
106
                                    <div class="hint">Image from Amazon.com</div>
(-)a/opac/opac-detail.pl (-3 lines)
Lines 46-52 use C4::Biblio qw( Link Here
46
use C4::Record                qw( marc2cites );
46
use C4::Record                qw( marc2cites );
47
use C4::Tags                  qw( get_tags );
47
use C4::Tags                  qw( get_tags );
48
use C4::XISBN                 qw( get_xisbns );
48
use C4::XISBN                 qw( get_xisbns );
49
use C4::External::Amazon      qw( get_amazon_tld );
50
use C4::External::BakerTaylor qw( image_url link_url );
49
use C4::External::BakerTaylor qw( image_url link_url );
51
use C4::External::Syndetics   qw(
50
use C4::External::Syndetics   qw(
52
    get_syndetics_anotes
51
    get_syndetics_anotes
Lines 1140-1147 if ( C4::Context->preference("OPACShelfBrowser") ) { Link Here
1140
    }
1139
    }
1141
}
1140
}
1142
1141
1143
$template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages") );
1144
1145
if ( C4::Context->preference("BakerTaylorEnabled") ) {
1142
if ( C4::Context->preference("BakerTaylorEnabled") ) {
1146
    $template->param(
1143
    $template->param(
1147
        BakerTaylorEnabled      => 1,
1144
        BakerTaylorEnabled      => 1,
(-)a/t/db_dependent/Amazon.t (-51 lines)
Lines 1-51 Link Here
1
#!/usr/bin/perl
2
#
3
# This Koha test module is a stub!
4
# Add more tests here!!!
5
6
use strict;
7
use warnings;
8
9
use Test::NoWarnings;
10
use Test::More tests => 9;
11
use t::lib::Mocks;
12
use C4::Context;
13
14
BEGIN {
15
    use_ok( 'C4::External::Amazon', qw( get_amazon_tld ) );
16
}
17
18
my $context = C4::Context->new();
19
20
my $locale = $context->preference('AmazonLocale');
21
22
t::lib::Mocks::mock_preference( 'AmazonLocale', 'CA' );
23
$context->clear_syspref_cache();
24
is( get_amazon_tld, '.ca', 'Changes locale to CA and tests get_amazon_tld' );
25
26
t::lib::Mocks::mock_preference( 'AmazonLocale', 'DE' );
27
$context->clear_syspref_cache();
28
is( get_amazon_tld, '.de', 'Changes locale to DE and tests get_amazon_tld' );
29
30
t::lib::Mocks::mock_preference( 'AmazonLocale', 'FR' );
31
$context->clear_syspref_cache();
32
is( get_amazon_tld, '.fr', 'Changes locale to FR and tests get_amazon_tld' );
33
34
t::lib::Mocks::mock_preference( 'AmazonLocale', 'JP' );
35
$context->clear_syspref_cache();
36
is( get_amazon_tld, '.jp', 'Changes locale to JP and tests get_amazon_tld' );
37
38
t::lib::Mocks::mock_preference( 'AmazonLocale', 'UK' );
39
$context->clear_syspref_cache();
40
is( get_amazon_tld, '.co.uk', 'Changes locale to UK and tests get_amazon_tld' );
41
42
t::lib::Mocks::mock_preference( 'AmazonLocale', 'US' );
43
$context->clear_syspref_cache();
44
is( get_amazon_tld, '.com', 'Changes locale to US and tests get_amazon_tld' );
45
46
t::lib::Mocks::mock_preference( 'AmazonLocale', 'NZ' );
47
$context->clear_syspref_cache();
48
is( get_amazon_tld, '.com', 'Changes locale to one not in the array and tests get_amazon_tld' );
49
50
t::lib::Mocks::mock_preference( 'AmazonLocale', $locale );
51
$context->clear_syspref_cache();
(-)a/t/db_dependent/check_sysprefs.t (-3 / +2 lines)
Lines 86-93 subtest 'Compare sysprefs.sql with YAML files' => sub { Link Here
86
#
86
#
87
# Example:
87
# Example:
88
# INSERT INTO `systempreferences` (variable,value,explanation,options,type)
88
# INSERT INTO `systempreferences` (variable,value,explanation,options,type)
89
# VALUES('AmazonLocale','US','Use to set the Locale of your Amazon.com Web Services',
89
# VALUES('AmazonLocaleTld','com','Use to set the Locale of your Amazon.com Web Services',
90
# 'US|CA|DE|FR|JP|UK','Choice')
90
# '','Free')
91
#
91
#
92
sub get_syspref_from_file {
92
sub get_syspref_from_file {
93
    my $fh = shift;
93
    my $fh = shift;
94
- 

Return to bug 41318