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

(-)a/C4/Search.pm (+10 lines)
Lines 1744-1749 sub searchResults { Link Here
1744
		$oldbiblio->{normalized_ean}  = GetNormalizedEAN(       $marcrecord,$marcflavour);
1744
		$oldbiblio->{normalized_ean}  = GetNormalizedEAN(       $marcrecord,$marcflavour);
1745
		$oldbiblio->{normalized_oclc} = GetNormalizedOCLCNumber($marcrecord,$marcflavour);
1745
		$oldbiblio->{normalized_oclc} = GetNormalizedOCLCNumber($marcrecord,$marcflavour);
1746
        $oldbiblio->{normalized_isbn} = GetNormalizedISBN($oldbiblio->{isbn},$marcrecord,$marcflavour); # Use existing ISBN from record if we got one
1746
        $oldbiblio->{normalized_isbn} = GetNormalizedISBN($oldbiblio->{isbn},$marcrecord,$marcflavour); # Use existing ISBN from record if we got one
1747
1748
        if ( C4::Context->preference('OpenLibraryCovers') ) {
1749
            for my $field ( $marcrecord->field('024') ) {
1750
                if ( $field->subfield('2') eq 'openlib' ) {
1751
                    $oldbiblio->{olid} = $field->subfield('a');
1752
                    last;
1753
                }
1754
            }
1755
        }
1756
1747
		$oldbiblio->{content_identifier_exists} = 1 if ($oldbiblio->{normalized_isbn} or $oldbiblio->{normalized_oclc} or $oldbiblio->{normalized_ean} or $oldbiblio->{normalized_upc});
1757
		$oldbiblio->{content_identifier_exists} = 1 if ($oldbiblio->{normalized_isbn} or $oldbiblio->{normalized_oclc} or $oldbiblio->{normalized_ean} or $oldbiblio->{normalized_upc});
1748
1758
1749
		# edition information, if any
1759
		# edition information, if any
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-4 / +4 lines)
Lines 114-120 Link Here
114
114
115
                            [% IF OpenLibraryCovers %]
115
                            [% IF OpenLibraryCovers %]
116
                                <div class="cover-image" id="openlibrary-coverimg">
116
                                <div class="cover-image" id="openlibrary-coverimg">
117
                                    <div title="[% img_title | html %]" class="[% normalized_isbn | html %]" id="openlibrary-thumbnail-preview" data-use-data-link="1"></div>
117
                                    <div title="[% img_title | html %]" data-isbn="[% normalized_isbn | html %]" data-olid="[% olid | html %]" id="openlibrary-thumbnail-preview" data-use-data-link="1"></div>
118
                                    <div class="hint">Image from OpenLibrary</div>
118
                                    <div class="hint">Image from OpenLibrary</div>
119
                                </div>
119
                                </div>
120
                            [% END %]
120
                            [% END %]
Lines 1834-1840 Link Here
1834
            [% END %]
1834
            [% END %]
1835
1835
1836
            [% IF OpenLibraryCovers %]
1836
            [% IF OpenLibraryCovers %]
1837
                KOHA.OpenLibrary.GetCoverFromIsbn();
1837
                KOHA.OpenLibrary.GetCover();
1838
            [% END %]
1838
            [% END %]
1839
1839
1840
            [% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
1840
            [% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
Lines 1887-1893 Link Here
1887
                                    KOHA.coce.getURL('[% Koha.Preference('CoceHost') | html %]', '[% Koha.Preference('CoceProviders') | html %]', $("#bibliodescriptions"));
1887
                                    KOHA.coce.getURL('[% Koha.Preference('CoceHost') | html %]', '[% Koha.Preference('CoceProviders') | html %]', $("#bibliodescriptions"));
1888
                                [% END %]
1888
                                [% END %]
1889
                                [% IF OpenLibraryCovers %]
1889
                                [% IF OpenLibraryCovers %]
1890
                                    KOHA.OpenLibrary.GetCoverFromIsbn();
1890
                                    KOHA.OpenLibrary.GetCover();
1891
                                [% END %]
1891
                                [% END %]
1892
                                [% IF OPACLocalCoverImages %]
1892
                                [% IF OPACLocalCoverImages %]
1893
                                    KOHA.LocalCover.GetCoverFromBibnumber(true);
1893
                                    KOHA.LocalCover.GetCoverFromBibnumber(true);
Lines 1913-1919 Link Here
1913
                                    KOHA.coce.getURL('[% Koha.Preference('CoceHost') | html %]', '[% Koha.Preference('CoceProviders') | html %]', $("#bibliodescriptions"));
1913
                                    KOHA.coce.getURL('[% Koha.Preference('CoceHost') | html %]', '[% Koha.Preference('CoceProviders') | html %]', $("#bibliodescriptions"));
1914
                                [% END %]
1914
                                [% END %]
1915
                                [% IF OpenLibraryCovers %]
1915
                                [% IF OpenLibraryCovers %]
1916
                                    KOHA.OpenLibrary.GetCoverFromIsbn();
1916
                                    KOHA.OpenLibrary.GetCover();
1917
                                [% END %]
1917
                                [% END %]
1918
                                [% IF OPACLocalCoverImages %]
1918
                                [% IF OPACLocalCoverImages %]
1919
                                    KOHA.LocalCover.GetCoverFromBibnumber(true);
1919
                                    KOHA.LocalCover.GetCoverFromBibnumber(true);
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (-3 / +3 lines)
Lines 389-396 Link Here
389
                                                        [% END %]
389
                                                        [% END %]
390
390
391
                                                        [% IF OpenLibraryCovers %]
391
                                                        [% IF OpenLibraryCovers %]
392
                                                            [% IF SEARCH_RESULT.normalized_isbn %]
392
                                                            [% IF SEARCH_RESULT.normalized_isbn || SEARCH_RESULT.olid %]
393
                                                                <span title="[% img_title | html %]" class="[% SEARCH_RESULT.normalized_isbn | html %]" id="openlibrary-thumbnail[% loop.count | html %]"></span>
393
                                                                <span title="[% img_title | html %]" data-isbn="[% SEARCH_RESULT.normalized_isbn | html %]" data-olid="[% SEARCH_RESULT.olid %]" id="openlibrary-thumbnail[% loop.count | html %]"></span>
394
                                                            [% ELSE %]
394
                                                            [% ELSE %]
395
                                                                <span class="no-image">No cover image available</span>
395
                                                                <span class="no-image">No cover image available</span>
396
                                                            [% END %]
396
                                                            [% END %]
Lines 896-902 Link Here
896
                });
896
                });
897
            [% END # /IF TagsInputEnabled && loggedinusername %]
897
            [% END # /IF TagsInputEnabled && loggedinusername %]
898
898
899
            [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %]
899
            [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCover();[% END %]
900
            [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %]
900
            [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %]
901
            [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
901
            [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
902
            [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
902
            [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (-1 / +1 lines)
Lines 1008-1014 $(function() { Link Here
1008
            return false;
1008
            return false;
1009
        });
1009
        });
1010
    [% END %]
1010
    [% END %]
1011
    [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %]
1011
    [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCover();[% END %]
1012
    [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %]
1012
    [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %]
1013
    [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
1013
    [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
1014
    [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
1014
    [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js (-30 / +39 lines)
Lines 9-25 KOHA.OpenLibrary = new function() { Link Here
9
9
10
    /**
10
    /**
11
     * Search all:
11
     * Search all:
12
     *    <div title="biblionumber" id="isbn" class="openlibrary-thumbnail"></div>
12
     *    <div title="biblionumber" class="openlibrary-thumbnail"></div>
13
     * or
13
     * and run a search with all collected isbns and olids to Open Library Book Search.
14
     *    <div title="biblionumber" id="isbn" class="openlibrary-thumbnail-preview"></div>
15
     * and run a search with all collected isbns to Open Library Book Search.
16
     * The result is asynchronously returned by OpenLibrary and catched by
14
     * The result is asynchronously returned by OpenLibrary and catched by
17
     * olCallBack().
15
     * olCallBack().
18
     */
16
     */
19
    this.GetCoverFromIsbn = function() {
17
    this.GetCover = function() {
20
        var bibkeys = [];
18
        var bibkeys = [];
21
        $("[id^=openlibrary-thumbnail]").each(function(i) {
19
        $("[id^=openlibrary-thumbnail]").each(function(i) {
22
            bibkeys.push("ISBN:" + $(this).attr("class")); // id=isbn
20
            let isbn = $(this).data("isbn");
21
            if ( isbn ) bibkeys.push("ISBN:" + isbn);
22
            let olid = $(this).data("olid");
23
            if ( olid ) bibkeys.push("OLID:" + olid);
23
        });
24
        });
24
        bibkeys = bibkeys.join(',');
25
        bibkeys = bibkeys.join(',');
25
        var scriptElement = document.createElement("script");
26
        var scriptElement = document.createElement("script");
Lines 38-69 KOHA.OpenLibrary = new function() { Link Here
38
    this.olCallBack = function(booksInfo) {
39
    this.olCallBack = function(booksInfo) {
39
        for (id in booksInfo) {
40
        for (id in booksInfo) {
40
            var book = booksInfo[id];
41
            var book = booksInfo[id];
41
            var isbn = id.substring(5);
42
            let isbn; let olid;
42
            $("[id^=openlibrary-thumbnail]."+isbn).each(function() {
43
            id.split(';').forEach((e) => {
43
                var a = document.createElement("a");
44
                let identifier = e.split(':')
44
                a.href = booksInfo.url;
45
                if ( identifier[0] == 'ISBN' ) {
45
                if (book.cover) {
46
                    isbn = identifier[1];
46
                    if ( $(this).data('use-data-link') ) {
47
                } else if ( identifier[0] == 'OLID' ) {
47
                         var a = document.createElement("a");
48
                    olid = identifier[1];
48
                         a.href = book.cover.large;
49
                         var img = document.createElement("img");
50
                         img.src = book.cover.medium;
51
                         img.setAttribute('data-link', book.cover.large);
52
                         a.append(img)
53
                         $(this).empty().append(a);
54
                    } else {
55
                        var img = document.createElement("img");
56
                        img.src = book.cover.medium;
57
                        img.height = '110';
58
                        $(this).append(img);
59
                    }
60
                } else {
61
                    var message =  document.createElement("span");
62
                    $(message).attr("class","no-image");
63
                    $(message).html(NO_OL_JACKET);
64
                    $(this).append(message);
65
                }
49
                }
66
            });
50
            });
51
52
            let elt = isbn ? $("[id^=openlibrary-thumbnail][data-isbn=%s]".format(isbn)) : $('*[data-olid="%s"]'.format(olid));
53
            var a = document.createElement("a");
54
            a.href = booksInfo.url;
55
            if (book.cover) {
56
                if ( $(elt).data('use-data-link') ) {
57
                     var a = document.createElement("a");
58
                     a.href = book.cover.large;
59
                     var img = document.createElement("img");
60
                     img.src = book.cover.medium;
61
                     img.setAttribute('data-link', book.cover.large);
62
                     a.append(img)
63
                     $(elt).empty().append(a);
64
                } else {
65
                    var img = document.createElement("img");
66
                    img.src = book.cover.medium;
67
                    img.height = '110';
68
                    $(elt).append(img);
69
                }
70
            } else {
71
                var message =  document.createElement("span");
72
                $(message).attr("class","no-image");
73
                $(message).html(NO_OL_JACKET);
74
                $(elt).append(message);
75
            }
67
        }
76
        }
68
        this.done = 1;
77
        this.done = 1;
69
    }
78
    }
(-)a/opac/opac-detail.pl (-1 / +9 lines)
Lines 1243-1246 if ( C4::Context->preference('OPACAuthorIdentifiers') ) { Link Here
1243
    $template->param( author_identifiers => \@author_identifiers );
1243
    $template->param( author_identifiers => \@author_identifiers );
1244
}
1244
}
1245
1245
1246
if ( C4::Context->preference('OpenLibraryCovers') && $record ) {
1247
    for my $field ( $record->field('024') ) {
1248
        if ( $field->subfield('2') eq 'openlib' ) {
1249
            $template->param( olid => $field->subfield('a') );
1250
            last;
1251
        }
1252
    }
1253
}
1254
1246
output_html_with_http_headers $query, $cookie, $template->output;
1255
output_html_with_http_headers $query, $cookie, $template->output;
1247
- 

Return to bug 34527