From dd05dd3dbb2f5aca4aa2a1df77f916cdb7b89694 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Sun, 18 Nov 2007 11:18:40 -0600 Subject: [PATCH] adding xisbn, amazon similar items to OPAC Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- .../data/mysql/en/mandatory/sysprefs.sql | 6 +++ opac/opac-detail.pl | 47 +++++++++++++------ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index b7d807c90d..8eecab897e 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -2,6 +2,10 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('advancedMARCeditor','0','If ON, the MARC editor won\'t display field/subfield descriptions','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonContent','0','Turn ON Amazon Content - You MUST set AmazonDevKey and AmazonAssocTag if enabled','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonSimilarItems','0','Turn ON Amazon Similar Items feature - You MUST set AmazonDevKey and AmazonAssocTag if enabled','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACAmazonContent','0','Turn ON Amazon Content in the OPAC - You MUST set AmazonDevKey and AmazonAssocTag if enabled','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACAmazonSimilarItems','0','Turn ON Amazon Similar Items feature - You MUST set AmazonDevKey and AmazonAssocTag if enabled','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('XISBNAmazonSimilarItems','0','If ON, Amazon Similar Items will be passed through XISBN to find all associated works','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACXISBNAmazonSimilarItems','0','If ON, Amazon Similar Items in the OPAC will be passed through XISBN to find all associated works','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonDevKey','','See: aws-portal.amazon.com/gp/aws/developer/registration/index.html','','free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonAssocTag','','See: associates.amazon.com/gp/flex/associates/apply-login.html','','free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonSuggestions','0','Set to anonymous borrowernumber to enable Anonymous suggestions',NULL,'free'); @@ -117,8 +121,10 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries',NULL,'free'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('FRBRizeEditions',0,'','If ON, Koha will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACFRBRizeEditions',0,'','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('XISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the OCLC xISBN web service in the Editions tab on the detail pages. See: http://www.worldcat.org/affiliate/webservices/xisbn/app.jsp','YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OCLCAffiliateID','','','Use with FRBRizeEditions and XISBN. You can sign up for an AffiliateID here: http://www.worldcat.org/wcpa/do/AffiliateUserServices?method=initSelfRegister','free'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('XISBNDailyLimit',499,'','The xISBN Web service is free for non-commercial use when usage does not exceed 500 requests per day','free'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('PINESISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use PINES OISBN web service in the Editions tab on the detail pages.','YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('ThingISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the ThingISBN web service in the Editions tab on the detail pages.','YesNo'); + diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index e84af07390..7aa80f3423 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -25,6 +25,7 @@ use C4::Auth; use C4::Serials; #uses getsubscriptionfrom biblionumber use C4::Output; use C4::Biblio; +use C4::XISBN qw(get_xisbns get_biblio_from_xisbn); use C4::Amazon; use C4::Review; use C4::Serials; @@ -132,17 +133,21 @@ $template->param( reviews => $reviews ); -## Amazon.com stuff -#not used unless preference set -if ( C4::Context->preference("AmazonContent") == 1 ) { - use C4::Amazon; - $dat->{'amazonisbn'} = $dat->{'isbn'}; - $dat->{'amazonisbn'} =~ s|-||g; - - $template->param( amazonisbn => $dat->{amazonisbn} ); - - my $amazon_details = &get_amazon_details( $dat->{amazonisbn} ); - +# XISBN Stuff +my $xisbn=$dat->{'isbn'}; +$xisbn =~ s/(p|-| |:)//g; +$template->param(amazonisbn => $xisbn); +if (C4::Context->preference("OPACFRBRizeEditions")==1) { + eval { + $template->param( + xisbn => $xisbn, + XISBNS => get_xisbns($xisbn) + ); + }; + if ($@) { warn "XISBN Failed $@"; } +} +if ( C4::Context->preference("OPACAmazonContent") == 1 ) { + my $amazon_details = &get_amazon_details( $xisbn ); foreach my $result ( @{ $amazon_details->{Details} } ) { $template->param( item_description => $result->{ProductDescription} ); $template->param( image => $result->{ImageUrlMedium} ); @@ -155,7 +160,20 @@ if ( C4::Context->preference("AmazonContent") == 1 ) { for my $details ( @{ $amazon_details->{Details} } ) { next unless $details->{SimilarProducts}; for my $product ( @{ $details->{SimilarProducts}->{Product} } ) { - push @products, +{ Product => $product }; + if (C4::Context->preference("OPACAmazonSimilarItems") ) { + my $xbiblios; + my @xisbns; + + if (C4::Context->preference("OPACXISBNAmazonSimilarItems") ) { + my $xbiblio = get_biblio_from_xisbn($product); + push @xisbns, $xbiblio; + $xbiblios = \@xisbns; + } + else { + $xbiblios = get_xisbns($product); + } + push @products, +{ product => $xbiblios }; + } } next unless $details->{Reviews}; for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) { @@ -164,12 +182,13 @@ if ( C4::Context->preference("AmazonContent") == 1 ) { for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) { push @reviews, +{ - Summary => $reviews->{Summary}, - Comment => $reviews->{Comment}, + summary => $reviews->{Summary}, + comment => $reviews->{Comment}, }; } } $template->param( SIMILAR_PRODUCTS => \@products ); $template->param( AMAZONREVIEWS => \@reviews ); } + output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5