Bugzilla – Attachment 62904 Details for
Bug 18514
Allow library to search their Koha and Overdrive collections using ElasticSearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18514 Fix link on results page, and show overdrive data on detail page
Bug-18514-Fix-link-on-results-page-and-show-overdr.patch (text/plain), 5.07 KB, created by
Chris Cormack
on 2017-05-01 00:18:36 UTC
(
hide
)
Description:
Bug 18514 Fix link on results page, and show overdrive data on detail page
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2017-05-01 00:18:36 UTC
Size:
5.07 KB
patch
obsolete
>From b764796d7bb8cc495956b8a830d035403617da03 Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Mon, 1 May 2017 09:35:40 +1200 >Subject: [PATCH] Bug 18514 Fix link on results page, and show overdrive data > on detail page > >To test >1/ Apply the first 2 patches, and run the fetcher script (in patch one) >2/ Search, notice the overdrive results result in a 404 if you click on >them >3/ Apply this patch >4/ Search again >5/ Click on a result, you should now be at a 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(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 0284e49ea8..2a2d5d69cb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/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 = $( '<div id="overdrive-results">' + _( 'Searching OverDrive...' ) + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></div>' ); > $( '#numresults' ) .append( ' ' ) > .append( $overdrive_results ); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl >index 7349b816a6..5a52ee0694 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl >@@ -414,6 +414,7 @@ > </xsl:with-param> > </xsl:call-template> > <xsl:value-of select="$biblionumber"/> >+ <xsl:if test="marc:datafield[@tag=999]/marc:subfield[@code='a']='ExtOverdrive'">&externalsource=overdrive</xsl:if> > </xsl:attribute> > <xsl:attribute name="class">title</xsl:attribute> > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index f2c2f6fe6a..59acc9322e 100755 >--- a/opac/opac-detail.pl >+++ b/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; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18514
:
62902
|
62903
|
62904
|
65004
|
65858
|
65859
|
65860
|
65861