adding GetMarcUrls() fcn to display 856's - adding also output to opac-detail.
authorRyan Higgins <rch@liblime.com>
Fri, 12 Oct 2007 08:05:34 +0000 (03:05 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 12 Oct 2007 12:24:53 +0000 (07:24 -0500)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Biblio.pm
koha-tmpl/opac-tmpl/prog/en/opac-detail.tmpl
opac/opac-detail.pl

index b142ad8..f99ca5d 100644 (file)
@@ -65,6 +65,7 @@ push @EXPORT, qw(
   &GetMarcBiblio
   &GetMarcAuthors
   &GetMarcSeries
+  GetMarcUrls
   &GetUsedMarcStructure
 
   &GetItemsInfo
@@ -1922,11 +1923,50 @@ sub GetMarcAuthors {
     return \@marcauthors;
 }
 
+=head2 GetMarcUrls
+
+=over 4
+
+$marcurls = GetMarcUrls($record,$marcflavour);
+Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop.
+Assumes web resources (not uncommon in MARC21 to omit resource type ind) 
+
+=back
+
+=cut
+
+sub GetMarcUrls {
+    my ($record, $marcflavour) = @_;
+    my @marcurls;
+    my $marcurl;
+    for my $field ($record->field('856')) {
+        my $url = $field->subfield('u');
+        my @notes;
+        for my $note ( $field->subfield('z')) {
+            push @notes , {note => $note};
+        }        
+        $marcurl = {  MARCURL => $url,
+                      notes => \@notes,
+                                       };
+               if($marcflavour eq 'MARC21') {
+               my $s3 = $field->subfield('3');
+                       my $link = $field->subfield('y');
+            $marcurl->{'linktext'} = $link || $s3 || $url ;;
+            $marcurl->{'part'} = $s3 if($link);
+            $marcurl->{'toc'} = 1 if($s3 =~ /^[Tt]able/) ;
+               } else {
+                       $marcurl->{'linktext'} = $url;
+               }
+        push @marcurls, $marcurl;    
+       }
+    return \@marcurls;
+}  #end GetMarcUrls
+
 =head2 GetMarcSeries
 
 =over 4
 
-$marcseriessarray = GetMarcSeries($record,$marcflavour);
+$marcseriesarray = GetMarcSeries($record,$marcflavour);
 Get all series from the MARC record and returns them in an array.
 The series are stored in differents places depending on MARC flavour
 
index bea2e84..e31277d 100644 (file)
     <!-- TMPL_IF name="dewey" -->
     <p><label><b>Dewey:</b></label><!-- TMPL_VAR name="dewey" --></p>
     <!-- /TMPL_IF -->
-    <!-- TMPL_IF name="URLS" -->
-    <p><label><b>URL: </b></label>
-        <!-- TMPL_LOOP name="URLS" -->
-        <a href="<!-- TMPL_VAR name="url" -->"><!-- TMPL_VAR NAME="url" --></a>&nbsp;|&nbsp;
-        <!-- /TMPL_LOOP -->
-    </p>
-    <!-- /TMPL_IF -->
     <p><label><b>Item type : </b></label>
         <!-- TMPL_IF name="description" -->
         <!-- TMPL_VAR name="description" -->
         <!-- TMPL_VAR NAME="itemtype" -->
         <!-- /TMPL_IF -->
     </p>
+    <!-- TMPL_IF name="MARCURLS" -->
+       <!-- TMPL_IF NAME="count" -->
+       <p><label><b>Online Resources:</b></label>
+    <ul>    <!-- TMPL_LOOP name="MARCURLS" -->
+               <li><!-- TMPL_IF NAME="part" --><!-- TMPL_VAR NAME="part" -->
+                       <br /><!-- /TMPL_IF --> 
+               <!-- here you might do a tmpl_if name="toc" and use greybox or equivalent for table of contents -->
+               <a href="<!-- TMPL_VAR NAME="MARCURL" -->"><!-- TMPL_VAR NAME="linktext" --></a>
+                       <!-- TMPL_IF NAME="notes" --><ul><!-- TMPL_LOOP NAME="notes" --><li><!-- TMPL_VAR NAME="note" --></li><!-- /TMPL_LOOP --></ul><!-- /TMPL_IF --></li>
+            <!-- /TMPL_LOOP --></ul>
+    </p>
+    <!-- /TMPL_IF -->
+    <!-- /TMPL_IF -->
 </div>
 
 <!-- TMPL_IF name="count" -->
index 90e0fbc..2933278 100755 (executable)
@@ -99,12 +99,14 @@ $template->param( norequests => $norequests, RequestOnOpac=>$RequestOnOpac );
     my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
     my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
        my $marcseriesarray  = GetMarcSeries($record,$marcflavour);
+       my $marcurlsarray       = GetMarcUrls($record,$marcflavour);
 
     $template->param(
         MARCNOTES   => $marcnotesarray,
         MARCSUBJCTS => $marcsubjctsarray,
         MARCAUTHORS => $marcauthorsarray,
-               MARCSERIES  => $marcseriesarray
+               MARCSERIES  => $marcseriesarray,
+               MARCURLS        => $marcurlsarray,
     );
 
 my @results = ( $dat, );