1 package C4::External::Syndetics;
2 # Copyright (C) 2006 LibLime
3 # <jmf at liblime dot com>
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
23 use HTTP::Request::Common;
28 use vars qw($VERSION @ISA @EXPORT);
35 &get_syndetics_summary
37 &get_syndetics_editions
38 &get_syndetics_excerpt
44 C4::External::Syndetics - Functions for retrieving Syndetics content in Koha
48 This module provides facilities for retrieving Syndetics.com content in Koha
50 =head2 get_syndetics_summary
54 my $syndetics_summary= &get_syndetics_summary( $xisbn );
58 Get Summary data from Syndetics
62 sub get_syndetics_summary {
66 $isbn = _normalize_match_point ($isbn);
68 # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2'
69 my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode');
71 my $url = "http://syndetics.com/index.aspx?isbn=$isbn/SUMMARY.XML&client=$syndetics_client_code&type=xw10";
73 my $content = get($url);
74 warn "could not retrieve $url" unless $content;
75 my $xmlsimple = XML::Simple->new();
76 my $response = $xmlsimple->XMLin(
78 forcearray => [ qw(Fld520) ],
80 # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a
82 $summary = \@{$response->{VarFlds}->{VarDFlds}->{Notes}->{Fld520}} if $response;
83 return $summary if $summary;
86 sub get_syndetics_toc {
90 $isbn = _normalize_match_point ($isbn);
92 # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2'
93 my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode');
95 my $url = "http://syndetics.com/index.aspx?isbn=$isbn/TOC.XML&client=$syndetics_client_code&type=xw10";
97 my $content = get($url);
98 warn "could not retrieve $url" unless $content;
99 my $xmlsimple = XML::Simple->new();
100 my $response = $xmlsimple->XMLin(
102 forcearray => [ qw(Fld970) ],
104 # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a
106 $toc = \@{$response->{VarFlds}->{VarDFlds}->{SSIFlds}->{Fld970}} if $response;
110 sub get_syndetics_excerpt {
114 $isbn = _normalize_match_point ($isbn);
116 # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2'
117 my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode');
119 my $url = "http://syndetics.com/index.aspx?isbn=$isbn/DBCHAPTER.XML&client=$syndetics_client_code&type=xw10";
121 my $content = get($url);
122 warn "could not retrieve $url" unless $content;
123 my $xmlsimple = XML::Simple->new();
124 my $response = $xmlsimple->XMLin(
126 forcearray => [ qw(Fld520) ],
128 # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a
130 $excerpt = \@{$response->{VarFlds}->{VarDFlds}->{Notes}->{Fld520}} if $response;
131 return XMLout($excerpt) if $excerpt;
135 sub get_syndetics_editions {
139 $isbn = _normalize_match_point ($isbn);
141 # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2'
142 my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode');
144 my $url = "http://syndetics.com/index.aspx?isbn=$isbn/FICTION.XML&client=$syndetics_client_code&type=xw10";
146 my $content = get($url);
147 warn "could not retrieve $url" unless $content;
148 my $xmlsimple = XML::Simple->new();
149 my $response = $xmlsimple->XMLin(
151 forcearray => [ qw(Fld020) ],
153 # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a
155 $similar_items = \@{$response->{VarFlds}->{VarDFlds}->{NumbCode}->{Fld020}} if $response;
156 return $similar_items if $similar_items;
159 sub _normalize_match_point {
160 my $match_point = shift;
161 (my $normalized_match_point) = $match_point =~ /([\d-]*[X]*)/;
162 $normalized_match_point =~ s/-//g;
164 return $normalized_match_point;
174 Joshua Ferraro <jmf@liblime.com>