From de6227bd0a6465f842391888d8de9124f9d56e9e Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Fri, 6 Feb 2009 14:34:32 -0600 Subject: [PATCH] Add Syndetics Summaries and TOC Signed-off-by: Galen Charlton --- C4/External/Syndetics.pm | 123 ++++++++++++++++++ .../prog/en/modules/opac-detail.tmpl | 26 +++- opac/opac-detail.pl | 12 ++ 3 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 C4/External/Syndetics.pm diff --git a/C4/External/Syndetics.pm b/C4/External/Syndetics.pm new file mode 100644 index 0000000000..9344da655f --- /dev/null +++ b/C4/External/Syndetics.pm @@ -0,0 +1,123 @@ +package C4::External::Syndetics; +# Copyright (C) 2006 LibLime +# +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use XML::Simple; +use LWP::Simple; +use LWP::UserAgent; +use HTTP::Request::Common; + +use strict; +use warnings; + +use vars qw($VERSION @ISA @EXPORT); + +BEGIN { + require Exporter; + $VERSION = 0.03; + @ISA = qw(Exporter); + @EXPORT = qw( + &get_syndetics_summary + &get_syndetics_toc + ); +} + +=head1 NAME + +C4::External::Syndetics - Functions for retrieving Syndetics content in Koha + +=head1 FUNCTIONS + +This module provides facilities for retrieving Syndetics.com content in Koha + +=head2 get_syndetics_summary + +=over 4 + +my $syndetics_summary= &get_syndetics_summary( $xisbn ); + +=back + +Get Summary data from Syndetics + +=cut + +sub get_syndetics_summary { + my ( $isbn ) = @_; + + #normalize the ISBN + $isbn = _normalize_match_point ($isbn); + + # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2' + my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode'); + + my $url = "http://syndetics.com/index.aspx?isbn=$isbn/SUMMARY.XML&client=$syndetics_client_code&type=xw10"; + warn $url; + my $content = get($url); + warn "could not retrieve $url" unless $content; + my $xmlsimple = XML::Simple->new(); + my $response = $xmlsimple->XMLin( + $content, + forcearray => [ qw(Fld520) ], + ) unless !$content; + # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a + my $summary = \@{$response->{VarFlds}->{VarDFlds}->{Notes}->{Fld520}} if $response; + return $summary if $summary; +} + +sub get_syndetics_toc { + my ( $isbn ) = @_; + + #normalize the ISBN + $isbn = _normalize_match_point ($isbn); + + # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2' + my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode'); + + my $url = "http://syndetics.com/index.aspx?isbn=$isbn/TOC.XML&client=$syndetics_client_code&type=xw10"; + warn $url; + my $content = get($url); + warn "could not retrieve $url" unless $content; + my $xmlsimple = XML::Simple->new(); + my $response = $xmlsimple->XMLin( + $content, + forcearray => [ qw(Fld970) ], + ) unless !$content; + # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a + my $toc = \@{$response->{VarFlds}->{VarDFlds}->{SSIFlds}->{Fld970}} if $response; + return $toc if $toc; +} + +sub _normalize_match_point { + my $match_point = shift; + (my $normalized_match_point) = $match_point =~ /([\d-]*[X]*)/; + $normalized_match_point =~ s/-//g; + + return $normalized_match_point; +} + +1; +__END__ + +=head1 NOTES + +=head1 AUTHOR + +Joshua Ferraro + +=cut diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index f55bc899eb..15561863fb 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -228,6 +228,9 @@ ( )
  • #descriptions">Descriptions
  • + +
  • #toc">TOC
  • +
  • #subscriptions">Subscriptions
  • @@ -368,6 +371,15 @@ + + + +

    From Syndetics:

    +

    + + + +

    @@ -379,7 +391,19 @@ - +
    +
    + +
      + + +
    • ()
    • + + +
    + +
    +

    This is a serial subscription

    diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 01c272f893..c184982e10 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -33,6 +33,7 @@ use C4::Tags qw(get_tags); use C4::Dates qw/format_date/; use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn get_biblio_from_xisbn); use C4::External::Amazon; +use C4::External::Syndetics qw(get_syndetics_summary get_syndetics_toc); use C4::Review; use C4::Serials; use C4::Members; @@ -289,6 +290,17 @@ if ( C4::Context->preference("OPACAmazonContent") == 1 ) { $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products ); $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews ); } + +if ( C4::Context->preference("SyndeticsEnabled") && C4::Context->preference("SyndeticsSummary") ) { + my $syndetics_summary = &get_syndetics_summary($xisbn); + $template->param( SYNDETICS_SUMMARY => $syndetics_summary ); +} + +if ( C4::Context->preference("SyndeticsEnabled") && C4::Context->preference("SyndeticsTOC") ) { + my $syndetics_toc = &get_syndetics_toc($xisbn); + $template->param( SYNDETICS_TOC => $syndetics_toc ); +} + # Shelf Browser Stuff if (C4::Context->preference("OPACShelfBrowser")) { # pick the first itemnumber unless one was selected by the user -- 2.39.2