[Koha-patches] [PATCH] Add Syndetics Summaries and TOC
Daniel Sweeney
daniel.sweeney at liblime.com
Fri Mar 6 17:28:13 CET 2009
From: Joshua Ferraro <jmf at liblime.com>
Signed-off-by: Daniel Sweeney <daniel.sweeney at liblime.com>
---
C4/External/Syndetics.pm | 123 ++++++++++++++++++++
.../opac-tmpl/prog/en/modules/opac-detail.tmpl | 26 ++++-
opac/opac-detail.pl | 12 ++
3 files changed, 160 insertions(+), 1 deletions(-)
create mode 100644 C4/External/Syndetics.pm
diff --git a/C4/External/Syndetics.pm b/C4/External/Syndetics.pm
new file mode 100644
index 0000000..9344da6
--- /dev/null
+++ b/C4/External/Syndetics.pm
@@ -0,0 +1,123 @@
+package C4::External::Syndetics;
+# Copyright (C) 2006 LibLime
+# <jmf at liblime dot com>
+#
+# 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 <jmf at liblime.com>
+
+=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 f55bc89..1556186 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 @@
( <!-- TMPL_VAR NAME="count" --> )</a>
</li>
<li> <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#descriptions">Descriptions</a></li>
+<!-- TMPL_IF NAME="SYNDETICS_TOC" -->
+ <li> <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#toc">TOC</a></li>
+<!-- /TMPL_IF -->
<!-- TMPL_IF name="subscriptionsnumber" --><li>
<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#subscriptions">Subscriptions</a>
</li><!-- /TMPL_IF -->
@@ -368,6 +371,15 @@
<!-- /TMPL_LOOP -->
<!-- /TMPL_IF-->
+<!-- TMPL_IF NAME="SyndeticsSummary" -->
+<!-- TMPL_LOOP NAME="SYNDETICS_SUMMARY" -->
+ <!-- TMPL_IF NAME="a" -->
+ <h4>From Syndetics:</h4>
+ <p><!-- TMPL_VAR NAME="a" --></p>
+ <!-- /TMPL_IF -->
+<!-- /TMPL_LOOP -->
+<!-- /TMPL_IF -->
+
<!-- TMPL_IF name="MARCNOTES" -->
<!-- TMPL_LOOP NAME="MARCNOTES" -->
<p><!-- TMPL_VAR NAME="marcnote" --></p>
@@ -379,7 +391,19 @@
<!-- /TMPL_IF -->
</div>
</div>
-
+<div id="toc">
+<div class="content_set">
+<!-- TMPL_IF NAME="SyndeticsTOC" --><!-- TMPL_IF NAME="SYNDETICS_TOC" -->
+<ul>
+<!-- TMPL_LOOP NAME="SYNDETICS_TOC" -->
+ <!-- TMPL_IF NAME="p" -->
+ <li><b><!-- TMPL_VAR NAME="l" --> <!-- TMPL_VAR NAME="t" --></b><!-- TMPL_IF NAME="p" --> (<!-- TMPL_VAR NAME="p" -->)<!-- /TMPL_IF --></li>
+ <!-- /TMPL_IF -->
+<!-- /TMPL_LOOP -->
+</ul>
+<!-- /TMPL_IF --><!-- /TMPL_IF -->
+</div>
+</div>
<!-- TMPL_IF name="subscriptionsnumber" -->
<div id="subscriptions">
<h2>This is a serial subscription</h2>
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 01c272f..c184982 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
--
1.5.6.5
More information about the Koha-patches
mailing list