Adds Fully Preferences-based Amazon.com feature. See mail to koha-devel

for details.
This commit is contained in:
kados 2006-02-04 01:56:42 +00:00
parent eab65edb5c
commit a063c11170
3 changed files with 35 additions and 4 deletions

View File

@ -50,7 +50,7 @@ sub get_amazon_details {
my ( $isbn ) = @_;
#get rid of MARC cataloger's nonsense
$isbn ~= /(p|-)//g;
$isbn =~ s/(p|-)//g;
# grab the developer's key: mine is 'ektostoukadou-20'
my $dev_key=C4::Context->preference('AmazonDevKey');

View File

@ -9,6 +9,7 @@ use C4::Interface::CGI::Output;
use HTML::Template;
use C4::Biblio;
use C4::SearchMarc;
use C4::Amazon;
my $query=new CGI;
my ($template, $borrowernumber, $cookie)
@ -63,7 +64,6 @@ my $marc = C4::Context->preference("marc");
#preformat isbn for amazon content
$dat->{'isbn'} =~ s|-||g;
my @results = ($dat,);
if (C4::Boolean::true_p($marc)) {
my $dbh = C4::Context->dbh;
@ -87,11 +87,41 @@ $template->param(BIBLIO_RESULTS => $resultsarray,
SITE_RESULTS => $sitearray,
subscriptions => \@subs,
subscriptionsnumber => $subscriptionsnumber,
LibraryName => C4::Context->preference("LibraryName"),
LibraryName => C4::Context->preference("LibraryName"),
suggestion => C4::Context->preference("suggestion"),
virtualshelves => C4::Context->preference("virtualshelves"),
OpacNav => C4::Context->preference("OpacNav"),
AmazonContent => C4::Context->preference("AmazonContent"),
);
output_html_with_http_headers $query, $cookie, $template->output;
## Amazon.com stuff
if (C4::Context->preference("AmazonContent")==1) {
my $isbn=$dat->{'isbn'};
my $amazon_details = &get_amazon_details($isbn);
foreach my $result (@{$amazon_details->{Details}}){
$template->param(item_description => $result->{ProductDescription});
$template->param(image => $result->{ImageUrlMedium});
$template->param(list_price => $result->{ListPrice});
$template->param(amazon_url => $result->{url});
}
my @products;
my @reviews;
for my $details( @{ $amazon_details->{ Details } } ) {
next unless $details->{ SimilarProducts };
for my $product ( @{ $details->{ SimilarProducts }->{ Product } } ) {
push @products, +{ Product => $product };
}
next unless $details->{ Reviews };
for my $product ( @{ $details->{ Reviews }->{ AvgCustomerRating } } ) {
$template->param(rating => $product * 20);
}
for my $reviews ( @{ $details->{ Reviews }->{ CustomerReview } } ) {
push @reviews, +{ Summary => $reviews->{ Summary }, Comment => $reviews->{ Comment }, };
}
}
$template->param( SIMILAR_PRODUCTS => \@products );
$template->param( REVIEWS => \@reviews );
}
output_html_with_http_headers $query, $cookie, $template->output;

View File

@ -214,6 +214,7 @@ if ($op eq "do_search") {
virtualshelves => C4::Context->preference("virtualshelves"),
LibraryName => C4::Context->preference("LibraryName"),
OpacNav => C4::Context->preference("OpacNav"),
AmazonContent => C4::Context->preference("AmazonContent"),
);
}