use unapi for record retrieval on details page; includes svf attrs for matttype,...
authorberick <berick@esilibrary.com>
Wed, 13 Apr 2011 18:25:58 +0000 (14:25 -0400)
committerberick <berick@esilibrary.com>
Wed, 13 Apr 2011 18:25:58 +0000 (14:25 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/web/templates/default/opac/parts/misc_util.tt2
Open-ILS/web/templates/default/opac/parts/record/body.tt2
Open-ILS/web/templates/default/opac/parts/record/summary.tt2

index f636744..3a54fbc 100644 (file)
@@ -11,32 +11,35 @@ my $U = 'OpenILS::Application::AppUtils';
 #   record : bre object
 sub load_record {
     my $self = shift;
-    $self->ctx->{page} = 'record';
+    my $ctx = $self->ctx;
+    $ctx->{page} = 'record';
 
-    my $org = $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id;
+    my $org = $self->cgi->param('loc') || $ctx->{aou_tree}->()->id;
     my $depth = $self->cgi->param('depth') || 0;
     my $copy_limit = int($self->cgi->param('copy_limit') || 10);
     my $copy_offset = int($self->cgi->param('copy_offset') || 0);
 
-    my $rec_id = $self->ctx->{page_args}->[0]
+    my $rec_id = $ctx->{page_args}->[0]
         or return Apache2::Const::HTTP_BAD_REQUEST;
 
     # run copy retrieval in parallel to bib retrieval
+    # XXX unapi
     my $copy_rec = OpenSRF::AppSession->create('open-ils.cstore')->request(
         'open-ils.cstore.json_query.atomic', 
         $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset));
 
-    $self->ctx->{record} = $self->editor->retrieve_biblio_record_entry($rec_id);
-    $self->ctx->{marc_xml} = XML::LibXML->new->parse_string($self->ctx->{record}->marc);
+    my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra}'});
+    $ctx->{bre_id} = $rec_data[0]->{id};
+    $ctx->{marc_xml} = $rec_data[0]->{marc_xml};
 
-    $self->ctx->{copies} = $copy_rec->gather(1);
-    $self->ctx->{copy_limit} = $copy_limit;
-    $self->ctx->{copy_offset} = $copy_offset;
+    $ctx->{copies} = $copy_rec->gather(1);
+    $ctx->{copy_limit} = $copy_limit;
+    $ctx->{copy_offset} = $copy_offset;
 
     for my $expand ($self->cgi->param('expand')) {
-        $self->ctx->{"expand_$expand"} = 1;
+        $ctx->{"expand_$expand"} = 1;
         if($expand eq 'marchtml') {
-            $self->ctx->{marchtml} = $self->mk_marc_html($rec_id);
+            $ctx->{marchtml} = $self->mk_marc_html($rec_id);
         } 
     }
 
index 8a9c0f3..3e6b175 100644 (file)
             END;
         END;
 
+        # "mattype" == "custom marc format specifier"
         FOR icon_style IN ['mattype', 'item_type']; 
-            node = xml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
+            node = xml.findnodes(
+                '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
             IF node;
                 args.format_label = node.getAttribute('coded-value')
                 args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png';
index 9de517d..3444a59 100644 (file)
@@ -1,6 +1,5 @@
 <!-- ****************** page_rdetail.xml ***************************** -->
-[%  record = ctx.record;
-    attrs = {marc_xml => ctx.marc_xml};
+[%  attrs = {marc_xml => ctx.marc_xml};
     PROCESS "default/opac/parts/misc_util.tt2";
     PROCESS get_marc_attrs args=attrs %]
 <div id='canvas_main' class='canvas'>
index 5e81b8e..79eb75b 100644 (file)
                             <span class='opac-auto-030'>[% l("Author") %]:</span>
                             <em><a title='[% l("Perform an author search") %]'
                                     id='rdetail_author'
-                                    href="[% ctx.opac_root %]/results?qtype=author&query=[% attrs.author | replace('[,\.:;]', '') | uri %]&loc=[% CGI.param('loc') | uri %]">[% attrs.author %]</a>
-                            </em>
+                                    href="[% ctx.opac_root %]/results?qtype=author&query=[%-
+                                        attrs.author | replace('[,\.:;]', '') | uri %]&loc=[% CGI.param('loc') | uri %]">[% attrs.author %]</a></em>
                             [% END %]
                         </td>
                         <td align="right" valign="top" nowrap="nowrap" style="white-space:nowrap;">
                             <div style="width:230px;text-align:left;margin-top:3px;">
                                 <div style="float:right;">
                                     <div class="rdetail_aux_utils opac-auto-010">
-                                        <a href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&" : ""; %]hold_target=[% record.id %]&hold_type=T" id="rdetail_place_hold" class="no-dec"><img
-                                            src="[% ctx.media_prefix %]/images/green_check.png" alt="[% l('place hold') %]" />
-                                            <span style="position:relative;top:-3px;left:3px;">Place Hold</span></a>
+                                        <a href="[% ctx.opac_root %]/place_hold[%-
+                                            propagator; propagator.length > 1 ? "&" : ""; %]hold_target=[% ctx.bre_id %]&hold_type=T" id="rdetail_place_hold" class="no-dec"><img
+                                            src="[% ctx.media_prefix %]/images/green_check.png" alt="[% l('place hold') %]" /><span 
+                                                style="position:relative;top:-3px;left:3px;">[% l('Place Hold') %]</span></a>
                                     </div>
                                     <div class="rdetail_aux_utils opac-auto-121">
-                                        [%  operation = ctx.mylist.grep(record.id).size ? "delete" : "add";
-                                            label = (operation == "add") ? "Add to" : "Remove from"; %]
+                                        [%  
+                                            operation = ctx.mylist.grep(ctx.bre_id).size ? "delete" : "add";
+                                            label = (operation == "add") ? l("Add to my list") : l("Remove from my list"); 
+                                        %]
                                         <form action="[% ctx.opac_root %]/mylist/[% operation %]" method="POST">
-                                            <input type="hidden" name="record" value="[% record.id %]" />
+                                            <input type="hidden" name="record" value="[% ctx.bre_id %]" />
                                             <div class="pos-abs">
                                                 <div class="opac-auto-149">
-                                                    <input type="submit" title="[% l(label _ ' my list') %]" value="[% l(label _ ' my list') %]" class="subtle-button" />
+                                                    <input type="submit" title="[% label %]" value="[% label %]" class="subtle-button" />
                                                 </div>
                                             </div>
-                                            <input type="image"
-                                                alt="[% l(label _ ' my list') %]"
+                                            <input type="image" alt="[% label %]"
                                                 src="[% ctx.media_prefix %]/images/clipboard.png" />
                                         </form>
                                     </div>
                                 </div>
                                 <div style="float:right;margin-right:17px;">
-                                    [% IF attrs.format %]
-                                    <img alt="[% attrs.format %]"
-                                        src="[% ctx.media_prefix %]/images/[% attrs.format_icon %]" />
+                                    [% IF attrs.format_icon %]
+                                    <img alt="[% attrs.format_label %]" title="[% attrs.format_label %]" src="[% attrs.format_icon %]" />
                                     [% END %]
                                 </div>
                             </div>
             <td>
                 [%# For some reason, browsers render &copy (as in, &copy_limit=foo) as the copyright 
                     symbol, even though it's inside inside the href attribute string.  Use ; instead %]
-                <a href="[% ctx.opac_root %]/record/[% record.id %]?copy_offset=[% new_offset %];copy_limit=[% ctx.copy_limit %]">&laquo; [%
+                <a href="[% ctx.opac_root %]/record/[% ctx.bre_id %]?copy_offset=[% new_offset %];copy_limit=[% ctx.copy_limit %]">&laquo; [%
                     l('Previous [_1]', ctx.copy_offset - new_offset)
                 %]</a>
             </td>
         [% END %]
         [% IF ctx.copies.size >= ctx.copy_limit %]
             <td>
-                <a href="[% ctx.opac_root %]/record/[% record.id %]?copy_offset=[% ctx.copy_offset + ctx.copy_limit %];copy_limit=[% ctx.copy_limit %]">[%
+                <a href="[% ctx.opac_root %]/record/[% ctx.bre_id %]?copy_offset=[% ctx.copy_offset + ctx.copy_limit %];copy_limit=[% ctx.copy_limit %]">[%
                     l('Next [_1]', ctx.copy_limit)
                 %] &raquo;</a>
             </td>
                                 </div>
                             </td>
                             <td width="1" valign="top" align="right" style="white-space:nowrap;">
-                                <a href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&" : ""; %]hold_target=[% record.id %]&hold_type=T"><img alt="[% l('Place Hold') %]"
+                                <a href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&" : ""; %]hold_target=[% ctx.bre_id %]&hold_type=T"><img alt="[% l('Place Hold') %]"
                                     src="[% ctx.media_prefix %]/images/place_hold.gif" /></a>
                                 <a href="#" id="rd_reviews_and_more" target="_blank"><img
                                     alt="[% l('Reviews and More') %]" src="[% ctx.media_prefix %]/images/reviews.gif" /></a>