From c3a260cbc682b7e18b7f7f5c272bf696f112332c Mon Sep 17 00:00:00 2001 From: erickson Date: Sun, 1 May 2011 15:29:39 +0000 Subject: [PATCH] ContentCafe summary of avaible item content Added "available_json" support for Content Cafe. Returns and array of available content for a given item, where the content type is mapped to one of the Evergreen standard added content types, e.g. "summary", "anotes", "reviews", ... git-svn-id: svn://svn.open-ils.org/ILS/trunk@20367 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../lib/OpenILS/WWW/AddedContent/ContentCafe.pm | 21 ++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm index c6e7f4f..9ecaebe 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm @@ -206,6 +206,27 @@ sub summary_json { $self->fetch_content('AnnotationDetail', $key)); } +sub available_json { + my($self, $key) = @_; + my $xml = $self->fetch_content('AvailableContent', $key); + my $doc = XML::LibXML->new->parse_string($xml); + + my @avail; + for my $node ($doc->findnodes('//*[text()="true"]')) { + push(@avail, 'summary') if $node->nodeName eq 'Annotation'; + push(@avail, 'jacket') if $node->nodeName eq 'Jacket'; + push(@avail, 'toc') if $node->nodeName eq 'TOC'; + push(@avail, 'anotes') if $node->nodeName eq 'Biography'; + push(@avail, 'excerpt') if $node->nodeName eq 'Excerpt'; + push(@avail, 'reviews') if $node->nodeName eq 'Review'; + } + + return { + content_type => 'text/plain', + content => OpenSRF::Utils::JSON->perl2JSON(\@avail) + }; +} + # -------------------------------------------------------------------------- -- 1.7.2.5