From 52adf7fd7a556451e3637c0849f8da4cca2875fc Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 28 Jun 2011 13:24:37 -0400 Subject: [PATCH] Display multiple copies and URIs per record in search results By building up a list of hashes in args.holding instead of a single result, we can display multiple copies in search results. Similarly, adding args.uri to misc_util.tt2 gives us the list of located URIs to display in search results. Note that the XPath for holdings_xml in in-db unapi will change slightly. Signed-off-by: Dan Scott Signed-off-by: Dan Scott --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 2 +- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 2 +- .../web/templates/default/opac/parts/misc_util.tt2 | 57 ++++++++++++++++++++-- .../templates/default/opac/parts/result/table.tt2 | 26 +++++++--- 4 files changed, 75 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 02fd651c03..eba1b74500 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -28,7 +28,7 @@ sub load_record { 'open-ils.cstore.json_query.atomic', $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset)); - my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra}'}); + my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra,acp}'}); $ctx->{bre_id} = $rec_data[0]->{id}; $ctx->{marc_xml} = $rec_data[0]->{marc_xml}; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index 787228c906..82b8865fe0 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -179,7 +179,7 @@ sub load_rresults { my ($facets, @data) = $self->get_records_and_facets( $rec_ids, $results->{facet_key}, { - flesh => '{holdings_xml,mra}', + flesh => '{holdings_xml,mra,acp}', site => $site, depth => $depth } diff --git a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 index 0e7cd2c492..04add44516 100644 --- a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 @@ -27,10 +27,59 @@ args.isbn_clean = args.isbn.replace('\ .*', ''); args.holdings = []; - FOR holding IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]'); - args.holdings.push( - holding.getAttribute('label') - ); + args.uris = []; + + # URI info is in volumes/volume/uris/volume, instead of uri element + i = 0; + FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]'); + i = i + 1; + + # Check volume visibility - could push this into XPath + vol.label = volume.getAttribute('label'); + NEXT IF volume.getAttribute('opac_visible') == 'false'; + NEXT IF volume.getAttribute('deleted') == 'true'; + + IF vol.label == '##URI##'; + FOR uri IN xml.findnodes('//*[local-name()="uris"]/*[local-name()="volume"]', volume); + res.href = uri.getAttribute('href'); + res.link = uri.getAttribute('label'); + res.note = uri.getAttribute('use_restriction'); + args.uris.push(res); + END; + NEXT; + ELSE; + copies = xml.findnodes('//*[local-name()="copies"]/*[local-name()="copy"]', volume); + FOR copy IN copies; + # Check copy visibility + cp.deleted = copy.getAttribute('deleted'); + cp.visible = copy.getAttribute('opac_visible'); + NEXT IF (cp.deleted == 'true' OR cp.visible == 'false'); + + # Iterate through all of the children to determine visibility + FOR node IN cp.childNodes; + NEXT IF cp.visible == 'false'; + vis = node.getAttribute('opac_visible'); + del = node.getAttribute('deleted'); + IF vis == 'false' or del == 'true'; + cp.visible = 'false'; + END; + END; + + NEXT IF cp.visible == 'false'; + + loc = xml.findnodes('//*[local-name()="location"]', copy); + circlib = xml.findnodes('//*[local-name()="circlib"]', copy); + status = xml.findnodes('//*[local-name()="status"]', copy); + + holding = { + label => vol.label, + location => loc.0.textContent, + library => circlib.0.textContent, + status => status.0.textContent + }; + args.holdings.push(holding); + END; + END; END; # Extract the copy count summary diff --git a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 index 6fc3b2e350..efb50f7bef 100644 --- a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 @@ -103,12 +103,6 @@ - - - - + + [% FOR copy IN args.holdings %] + + + + + [% END %] + + [% FOR uri IN args.uris%] + + + + + [% END %] + +
- [% l('Call number:') %] - [% args.holdings.0 %]
[% l('Publisher:') %] @@ -135,6 +129,26 @@ [% args.phys_desc %]
+ [% l('Call number:') %] + [% copy.label _ ' ' _ copy.location _ ' ' _ copy.library _ ' ' _ copy.status %]
+ [% l('Electronic resource') %] + [% uri.link %][% ' - ' _ uri.note IF uri.note %]
[% l('[_1] of [quant,_2,copy,copies] available', -- 2.11.0