@@ -, +, @@
on detail page
---
.../opac-tmpl/bootstrap/en/modules/opac-results.tt | 2 +-
.../bootstrap/en/xslt/MARC21slim2OPACResults.xsl | 1 +
opac/opac-detail.pl | 62 ++++++++++++++++++----
3 files changed, 55 insertions(+), 10 deletions(-)
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
@@ -885,7 +885,7 @@ $(document).ready(function(){
$("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;});
$("#highlight_toggle_off").show().click(function() {highlightOff();});
[% END %]
- [% IF ( OverDriveEnabled ) %]
+ [% IF ( OverDriveEnabled ) && Koha.Preference('SearchEngine') != 'Elasticsearch' %]
var $overdrive_results = $( '
' + _( 'Searching OverDrive...' ) + '
' );
$( '#numresults' ) .append( ' ' )
.append( $overdrive_results );
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
@@ -414,6 +414,7 @@
+ &externalsource=overdrive
title
--- a/opac/opac-detail.pl
+++ a/opac/opac-detail.pl
@@ -74,20 +74,64 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
);
my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
-$biblionumber = int($biblionumber);
-my @all_items = GetItemsInfo($biblionumber);
+my $external = $query->param('externalsource'); #is this record present in the db, or has come from external
+
+my $record;
+my @all_items;
my @hiddenitems;
-if (scalar @all_items >= 1) {
- push @hiddenitems, GetHiddenItemnumbers(@all_items);
- if (scalar @hiddenitems == scalar @all_items ) {
- print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
- exit;
- }
+# Move this to a module
+sub convert_od_marc {
+ # neeeds to work for other than marc21 too
+ my $data = shift;
+ my $marc = MARC::Record->new();
+ $marc->add_fields(
+ [ 245, "1", " ", a => $data->{title}, b => $data->{subtitle} ],
+ [ 100, "", "", a => $data->{'author'} ],
+ [ 260, "", "", a => $data->{'publisher'} ],
+ [ 999, "", "", c => $data->{'id'} ],
+ [ 999, "", "", d => $data->{'id'} ],
+ );
+ return $marc;
+}
+
+if ( $external && $external eq 'overdrive' ) {
+# We are looking at a record from overdrive, not a marc record in Koha
+ require Koha::ExternalContent::OverDrive;
+ import Koha::ExternalContent::OverDrive;
+ require WebService::ILS::OverDrive::Library;
+ import WebService::ILS::OverDrive::Library;
+ my $client_id = C4::Context->preference('OverDriveClientKey');
+ my $client_secret = C4::Context->preference('OverDriveClientSecret');
+ my $library_id = C4::Context->preference('OverDriveLibraryID');
+ my $od_client = WebService::ILS::OverDrive::Library->new(
+ {
+ test => 1,
+ client_id => $client_id,
+ client_secret => $client_secret,
+ library_id => $library_id
+ }
+ );
+ my $data = $od_client->item_metadata($biblionumber);
+ $record = convert_od_marc($data);
}
+else {
+# Normal record in Koha
+ $biblionumber = int($biblionumber);
+ @all_items = GetItemsInfo($biblionumber);
+ @hiddenitems;
+ if (scalar @all_items >= 1) {
+ push @hiddenitems, GetHiddenItemnumbers(@all_items);
+
+ if (scalar @hiddenitems == scalar @all_items ) {
+ print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
+ exit;
+ }
+ }
-my $record = GetMarcBiblio($biblionumber);
+ my $record = GetMarcBiblio($biblionumber);
+}
if ( ! $record ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
exit;
--