From: Bill Erickson <berick@esilibrary.com>
Date: Mon, 3 Oct 2011 20:31:45 +0000 (-0400)
Subject: TPac: show non-asset.uri 856 URLs on detail page
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=209b870d5edf0981cdc78d06ee480c51318b9614;p=evergreen%2Fmasslnc.git

TPac: show non-asset.uri 856 URLs on detail page

Display "global" 856 URLs in record detail page.  A "global" URL in this
case is one that has no ownership and has not been extracted out as an
asset.uri.  As of right now, this is any 856 that has no $9, $w, or $n
subfield data.

Links are displayed directly after asset.uri links using the same style.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
---

diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2
index 308998407c..1657bd6893 100644
--- a/Open-ILS/src/templates/opac/parts/misc_util.tt2
+++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2
@@ -37,6 +37,26 @@
         # clean up the ISBN
         args.isbn_clean = args.isbns.0.replace('\ .*', '');
 
+        # Extract the 856 URLs that are not otherwise represented by asset.uri's
+        args.online_res = [];
+        FOR node IN xml.findnodes('//*[@tag="856"]');
+            IF node.findnodes('./*[@code="9" or @code="w" or @code="n"]'); NEXT; END; # asset.uri's
+            label = node.findnodes('./*[@code="y"]');
+            notes = node.findnodes('./*[@code="z" or @code="3"]');
+            FOR href IN node.findnodes('./*[@code="u"]');
+                NEXT UNLESS href;
+                # it's possible for multiple $u's to exist within 1 856 tag.
+                # in that case, honor the label/notes data for the first $u, but
+                # leave any subsequent $u's as unadorned href's. 
+                # use href/link/note keys to be consistent with args.uri's
+                args.online_res.push({
+                    href => href.textContent, 
+                    link => (loop.first AND label) ? label.textContent : href.textContent,
+                    note => (loop.first) ? notes.textContent : ''
+                });
+            END;
+        END;
+ 
         args.holdings = [];
         args.uris = [];
         args.issns = [];
diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2
index bbfb1c14f6..125546cec4 100644
--- a/Open-ILS/src/templates/opac/parts/record/summary.tt2
+++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2
@@ -73,7 +73,7 @@
 [%- IF sfx.size && sfx.0 != '' %]
     </div>    
 [%- END %]
-[%- FOR uri IN args.uris; %]
+[%- FOR uri IN args.uris.merge(args.online_res); %]
 <div class="rdetail_uri">
     <a href="[% uri.href %]">[% uri.link %]</a>[% ' - ' _ uri.note IF uri.note %]
 </div>