More better call number browser, uses supercat directly, doesn't use mvr
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 22 Jul 2011 17:04:37 +0000 (13:04 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 22 Jul 2011 17:04:37 +0000 (13:04 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/web/templates/default/opac/parts/record/cnbrowse.tt2
Open-ILS/web/templates/default/opac/parts/record/extras.tt2

index 235cb6a..a1f6777 100644 (file)
@@ -202,14 +202,26 @@ sub any_call_number_label {
 sub browse_call_numbers {
     my ($self) = @_;
 
-    my $cn = $self->any_call_number_label or return [];
-
-    my $search = create OpenSRF::AppSession("open-ils.search");
-
-    return $search->request(
-        "open-ils.search.callnumber.browse", 
-        $cn, $self->cgi->param("loc"), 9, $self->cgi->param("cnoffset")
-    )->gather(1);
+    my $cn = $self->any_call_number_label or
+        return [];
+
+    my $org_unit = $self->ctx->{get_aou}->($self->cgi->param('loc')) ||
+        $self->ctx->{aou_tree}->();
+
+    my $supercat = create OpenSRF::AppSession("open-ils.supercat");
+    my $results = $supercat->request(
+        "open-ils.supercat.call_number.browse", 
+        $cn, $org_unit->shortname, 9, $self->cgi->param("cnoffset")
+    )->gather(1) || [];
+
+    return [
+        map {
+            $_->record->marc(
+                (new XML::LibXML)->parse_string($_->record->marc)
+            );
+            $_;
+        } @$results
+    ];
 }
 
 sub get_hold_copy_summary {
index 1ee18c7..88e4fbf 100644 (file)
@@ -8,7 +8,7 @@
             <thead>
                 <tr>
                     <td>
-                        <a id='cn_browse_prev' class='classic_link' href=">[% ctx.opac_root %]/record/[% ctx.bre_id _ extras_propagator _ '&amp;cnoffset=' _ ((CGI.param('cnoffset') || 0) - 1) _ '&amp;expand=cnbrowse#cnbrowse' %]"<b>[%
+                        <a id='cn_browse_prev' class='classic_link' href="[% ctx.opac_root %]/record/[% ctx.bre_id _ extras_propagator _ '&amp;cnoffset=' _ ((CGI.param('cnoffset') || 0) - 1) _ '&amp;expand=cnbrowse#cnbrowse' %]"<b>[%
                             l("&lt;&lt; Previous Page")
                         %]</b></a>
                     </td>
                 </tr>
             </thead>
             <tbody id='cn_tbody'>
-            [% tr_open = 0; FOR ent IN ctx.browsed_call_numbers %]
+            [% tr_open = 0; FOR cn IN ctx.browsed_call_numbers %]
                 [%- IF loop.index % 3 == 0; tr_open = 1 %]
                 <tr id='cn_browse_row'>
                 [% END -%]
                     <td id='cn_browse_td' class='cn_browse_item' width='25%' valign='top'>
-                        [%  # Not to extend to life of the mvr fieldmapper class,
-                            # but should we add a upc field to it to make this better?
-                            IF ent.mods.isbn %]
-                        <a href="[% ctx.opac_root %]/record/[% ent.cn.record _ extras_propagator %]"><img height='60' width='50' 
+                        [%  rec_attrs = {marc_xml => cn.record.marc};
+                            PROCESS get_marc_attrs args=rec_attrs;
+                            ident = rec_attrs.isbn_clean || rec_attrs.upc;
+                            IF ident %]
+                        <a href="[% ctx.opac_root %]/record/[% cn.record.id _ extras_propagator %]"><img height='60' width='50' 
                             class='cn_browse_info' name='cn_browse_pic' border='0'
-                            src="[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% ent.mods.isbn %]" /></a>
+                            src="[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% ident %]" /></a>
                         [% END %]
-                        <div class='cn_browse_info bold' name='cn_browse_cn'>[% ent.cn.label %]</div>
+                        <div class='cn_browse_info bold' name='cn_browse_cn'>[% cn.label %]</div>
                         <div class='cn_browse_info'>
-                            <a name='cn_browse_title' class='classic_link' href="[% ctx.opac_root %]/record/[% ent.cn.record _ extras_propagator %]">[% ent.mods.title %]</a>
+                            <a name='cn_browse_title' class='classic_link' href="[% ctx.opac_root %]/record/[% cn.record.id _ extras_propagator %]">[% rec_attrs.title %]</a>
                         </div>
-                        [% IF ent.mods.author %]<div class='cn_browse_info'>
+                        [% IF rec_attrs.author %]<div class='cn_browse_info'>
                             <a name='cn_browse_author' class='classic_link'
-                                href="[% ctx.opac_root %]/results?qtype=author&amp;query=[%- ent.mods.author | replace('[,\.:;]', '') | uri %]&amp;loc=[% CGI.param('loc') | uri %]">[% ent.mods.author %]</a>
+                                href="[% ctx.opac_root %]/results?qtype=author&amp;query=[%- rec_attrs.author | replace('[,\.:;]', '') | uri %]&amp;loc=[% CGI.param('loc') | uri %]">[% rec_attrs.author %]</a>
                         </div>[% END %]
-                        <div class='cn_browse_info' name='cn_browse_lib'>[% ctx.get_aou(ent.cn.owning_lib).name %]</div>
+                        <div class='cn_browse_info' name='cn_browse_lib'>[% cn.owning_lib.name %]</div>
                     </td>
                 [% IF loop.index % 3 == 2; tr_open = 0 %]
                 </tr>
index 2bfa8be..c53ce31 100644 (file)
@@ -43,8 +43,8 @@
                     # to extras.
                     # XXX move this off into a helper function
 
-                    extras_propagator = propagator.replace('&amp;expand=.+($|&|;)', '$1');
-                    extras_propagator = extras_propagator.replace('&amp;cnoffset=.+($|&|;)', '$1');
+                    extras_propagator = propagator.replace('(&amp;)?expand=.+($|&|;)', '$2');
+                    extras_propagator = extras_propagator.replace('(&amp;)?cnoffset=.+($|&|;)', '$2');
 
 
                     href = ctx.full_path _ extras_propagator _ '&amp;expand=' _ name _ '#' _ name; %]