From 53ace844015eed16c66ea851b59632fbb71cefca Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 30 Apr 2009 15:09:42 -0500 Subject: [PATCH] Syndetics: add support for AVSUMMARY and AVPROFILE Added support for the Syndetics AV summary and AV profile data elements. The AV summary is displayed in the description tab if present, while the AV profile is displayed as a link off of the OPAC bib details page. Signed-off-by: Galen Charlton --- C4/External/Syndetics.pm | 21 ++++++++++--------- .../prog/en/modules/opac-detail.tmpl | 15 +++++++------ opac/opac-detail.pl | 5 +++-- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/C4/External/Syndetics.pm b/C4/External/Syndetics.pm index f61a31c7aa..c6d7ecffd7 100644 --- a/C4/External/Syndetics.pm +++ b/C4/External/Syndetics.pm @@ -90,7 +90,7 @@ sub get_syndetics_index { ) unless !$content; my $syndetics_elements; - for my $available_type ('SUMMARY','TOC','FICTION','AWARDS1','SERIES1','SPSUMMARY','SPREVIEW','AVSUMMARY','DBCHAPTER','LJREVIEW','PWREVIEW','SLJREVIEW','CHREVIEW','BLREVIEW','HBREVIEW','KIREVIEW','CRITICASREVIEW','ANOTES') { + for my $available_type ('SUMMARY','TOC','FICTION','AWARDS1','SERIES1','SPSUMMARY','SPREVIEW', 'AVPROFILE', 'AVSUMMARY','DBCHAPTER','LJREVIEW','PWREVIEW','SLJREVIEW','CHREVIEW','BLREVIEW','HBREVIEW','KIREVIEW','CRITICASREVIEW','ANOTES') { if (exists $response->{$available_type} && $response->{$available_type} =~ /$available_type/) { $syndetics_elements->{$available_type} = $available_type; #warn "RESPONSE: $available_type : $response->{$available_type}"; @@ -100,12 +100,13 @@ sub get_syndetics_index { } sub get_syndetics_summary { - my ( $isbn,$upc,$oclc ) = @_; + my ( $isbn, $upc, $oclc, $syndetics_elements ) = @_; # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2' my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode'); - my $url = "http://www.syndetics.com/index.aspx?isbn=$isbn/SUMMARY.XML&client=$syndetics_client_code&type=xw10&upc=$upc&oclc=$oclc"; + my $summary_type = exists($syndetics_elements->{'AVSUMMARY'}) ? 'AVSUMMARY' : 'SUMMARY'; + my $url = "http://www.syndetics.com/index.aspx?isbn=$isbn/$summary_type.XML&client=$syndetics_client_code&type=xw10&upc=$upc&oclc=$oclc"; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; @@ -117,14 +118,14 @@ sub get_syndetics_summary { my $content = $response->content; warn "could not retrieve $url" unless $content; - my $xmlsimple = XML::Simple->new(); - $response = $xmlsimple->XMLin( - $content, - forcearray => [ qw(Fld520) ], - ) unless !$content; - # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a my $summary; - $summary = \@{$response->{VarFlds}->{VarDFlds}->{Notes}->{Fld520}} if $response; + eval { + my $doc = $parser->parse_string($content); + $summary = $doc->findvalue('//Fld520'); + }; + if ($@) { + warn "Error parsing response from $url"; + } return $summary if $summary; } 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 66aa1c426e..39d25d5cd3 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -233,6 +233,11 @@ Series Information: &type=series&num=1&client=&upc=&oclc=">Click to open in new window + + + Audiovisual Profile: /avprofile.html&client=&upc=&oclc=&type=xw10">Click to open in new window + + Fiction Notes: /fiction.html&client=&upc=&oclc=&type=xw10">Click to open in new window @@ -424,13 +429,11 @@ - - - + +

Enhanced Descriptions from Syndetics:

-

- - +

+ diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index f98f30e449..5b986ac30e 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -333,9 +333,10 @@ if ( C4::Context->preference("SyndeticsEnabled") ) { if ( C4::Context->preference("SyndeticsEnabled") && C4::Context->preference("SyndeticsSummary") - && $syndetics_elements->{'SUMMARY'} =~ /SUMMARY/) { + && ( $syndetics_elements->{'SUMMARY'} =~ /SUMMARY/ + || $syndetics_elements->{'AVSUMMARY'} =~ /AVSUMMARY/ ) ) { eval { - my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc); + my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements); $template->param( SYNDETICS_SUMMARY => $syndetics_summary ); }; warn $@ if $@; -- 2.39.2