From da77660239b2c3d8abbbc87db159c60a236ccc5b Mon Sep 17 00:00:00 2001
From: phasefx
Date: Fri, 20 Aug 2010 17:18:28 +0000
Subject: [PATCH] eliminate false positives for ContentCafe features for a
given bib
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17288 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
.../perlmods/OpenILS/WWW/AddedContent/ContentCafe.pm | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/ContentCafe.pm b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/ContentCafe.pm
index 19a767d49..c6e7f4ff8 100644
--- a/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/ContentCafe.pm
+++ b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/ContentCafe.pm
@@ -61,7 +61,9 @@ sub toc_html {
my $doc = XML::LibXML->new->parse_string($xml);
$doc->documentElement->setNamespace('http://ContentCafe2.btol.com', 'cc');
my $html = '';
- foreach my $node ( $doc->findnodes('//cc:Toc') ) {
+ my @nodes = $doc->findnodes('//cc:Toc');
+ return 0 if (scalar(@nodes) < 1);
+ foreach my $node ( @nodes ) {
$html .= $node->textContent . '
';
}
return $self->send_html($html);
@@ -87,7 +89,9 @@ sub anotes_html {
my $doc = XML::LibXML->new->parse_string($xml);
$doc->documentElement->setNamespace('http://ContentCafe2.btol.com', 'cc');
my $html = '';
- foreach my $node ( $doc->findnodes('//cc:Biography') ) {
+ my @nodes = $doc->findnodes('//cc:Biography');
+ return 0 if (scalar(@nodes) < 1);
+ foreach my $node ( @nodes ) {
$html .= '' . $node->textContent . '
';
}
return $self->send_html($html);
@@ -114,7 +118,9 @@ sub excerpt_html {
my $doc = XML::LibXML->new->parse_string($xml);
$doc->documentElement->setNamespace('http://ContentCafe2.btol.com', 'cc');
my $html = '';
- foreach my $node ( $doc->findnodes('//cc:Excerpt') ) {
+ my @nodes = $doc->findnodes('//cc:Excerpt');
+ return 0 if (scalar(@nodes) < 1);
+ foreach my $node ( @nodes ) {
$html .= $node->textContent;
}
return $self->send_html($html);
@@ -140,7 +146,9 @@ sub reviews_html {
my $doc = XML::LibXML->new->parse_string($xml);
$doc->documentElement->setNamespace('http://ContentCafe2.btol.com', 'cc');
my $html = '';
- foreach my $node ( $doc->findnodes('//cc:ReviewItem') ) {
+ my @nodes = $doc->findnodes('//cc:ReviewItem');
+ return 0 if (scalar(@nodes) < 1);
+ foreach my $node ( @nodes ) {
my @s_nodes = $node->findnodes('./cc:Supplier');
my @p_nodes = $node->findnodes('./cc:Publication');
my @i_nodes = $node->findnodes('./cc:Issue');
@@ -174,7 +182,9 @@ sub summary_html {
my $doc = XML::LibXML->new->parse_string($xml);
$doc->documentElement->setNamespace('http://ContentCafe2.btol.com', 'cc');
my $html = '';
- foreach my $node ( $doc->findnodes('//cc:AnnotationItem') ) {
+ my @nodes = $doc->findnodes('//cc:AnnotationItem');
+ return 0 if (scalar(@nodes) < 1);
+ foreach my $node ( @nodes ) {
my @s_nodes = $node->findnodes('./cc:Supplier');
my @a_nodes = $node->findnodes('./cc:Annotation');
$html .= '- ' . (scalar(@s_nodes) ? $s_nodes[0]->textContent : '') . '
';
--
2.11.0