fixing additional authors links on detail pages in opac and staff catalogs
authorJoshua Ferraro <jmf@liblime.com>
Tue, 18 Dec 2007 22:50:37 +0000 (16:50 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 19 Dec 2007 01:34:45 +0000 (19:34 -0600)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Biblio.pm
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl

index db37136..1c6d43b 100755 (executable)
@@ -1879,12 +1879,8 @@ sub GetMarcSubjects {
             }
                        my $separator = C4::Context->preference("authoritysep") unless $counter==0;
                        # ignore $9
-                       push @subfields_loop, {code => $code, value => $value, link_loop => \@link_loop, separator => $separator} unless ($subject_subfield->[0] == 9 );
-                       # this needs to be added back in in a way that the template can expose it properly
-                       #if ( $code == 9 ) {
-            #    $link = "an:".$subject_subfield->[1];
-            #    $flag = 1;
-            #}
+                       my @this_link_loop = @link_loop;
+                       push @subfields_loop, {code => $code, value => $value, link_loop => \@this_link_loop, separator => $separator} unless ($subject_subfield->[0] == 9 );
                        $counter++;
                }
                 
@@ -1926,25 +1922,37 @@ sub GetMarcAuthors {
 
     foreach my $field ( $record->fields ) {
         next unless $field->tag() >= $mintag && $field->tag() <= $maxtag;
-        my %hash;
+               my @subfields_loop;
+        my @link_loop;
         my @subfields = $field->subfields();
         my $count_auth = 0;
+               # if there is an authority link, build the link with Koha-Auth-Number: subfield9
+               my $subfield9 = $field->subfield('9');
         for my $authors_subfield (@subfields) {
-                       #unimarc-specific line
-            next if ($marcflavour eq 'UNIMARC' and (($authors_subfield->[0] eq '3') or ($authors_subfield->[0] eq '5')));
+                       # don't load unimarc subfields 3, 5
+            next if ($marcflavour eq 'UNIMARC' and ($authors_subfield->[0] =~ (3|5) ) );
             my $subfieldcode = $authors_subfield->[0];
-            my $value;
-            # deal with UNIMARC author responsibility
-                       if ( $marcflavour eq 'UNIMARC' and ($authors_subfield->[0] eq '4')) {
-               $value = "(".GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ).")";
-            } else {
-                $value        = $authors_subfield->[1];
-            }
-            $hash{tag}       = $field->tag;
-            $hash{value}    .= $value . " " if ($subfieldcode != 9) ;
-            $hash{link}     .= $value if ($subfieldcode eq 9);
+            my $value = $authors_subfield->[1];
+                       my $linkvalue = $value;
+                       $linkvalue =~ s/(\(|\))//g;
+                       my $operator = " and " unless $count_auth==0;
+                       # if we have an authority link, use that as the link, otherwise use standard searching
+                       if ($subfield9) {
+                               @link_loop = ({'limit' => 'Koha-Auth-Number' ,link => "$subfield9" });
+                       }
+                       else {
+                               # reset $linkvalue if UNIMARC author responsibility
+                               if ( $marcflavour eq 'UNIMARC' and ($authors_subfield->[0] eq '4')) {
+                       $linkvalue = "(".GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ).")";
+               }
+                               push @link_loop, {'limit' => 'au', link => $linkvalue, operator => $operator };
+                       }
+                       my @this_link_loop = @link_loop;
+                       my $separator = C4::Context->preference("authoritysep") unless $count_auth==0;
+                       push @subfields_loop, {code => $subfieldcode, value => $value, link_loop => \@this_link_loop, separator => $separator} unless ($authors_subfield->[0] == 9 );
+                       $count_auth++;
         }
-        push @marcauthors, \%hash;
+        push @marcauthors, { MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop };
     }
     return \@marcauthors;
 }
index 1affc8b..76b6474 100644 (file)
@@ -61,17 +61,16 @@ function verify_images() {
                <ul>
         <!-- TMPL_IF name="MARCAUTHORS" -->
             <li><strong>Additional Authors:</strong><ul>
-                <!-- TMPL_LOOP NAME="MARCAUTHORS" -->
-                <li><a href="/cgi-bin/koha/catalogue/search.pl?q=Koha-Auth-Number:<!-- TMPL_VAR NAME="link" -->">
-                    <!-- TMPL_VAR NAME="value" -->
-                </a></li>
+                       <!-- TMPL_LOOP NAME="MARCAUTHORS" -->
+                <li><!-- TMPL_LOOP NAME="MARCAUTHOR_SUBFIELDS_LOOP" --><!-- TMPL_VAR NAME="separator" --><a title="‡<!-- TMPL_VAR NAME=code --> <!-- TMPL_VAR NAME=value -->" href="/cgi-bin/koha/catalogue/search.pl?q=<!-- TMPL_LOOP NAME=link_loop --><!-- TMPL_VAR NAME=operator --><!-- TMPL_VAR name='limit' -->:<!-- TMPL_VAR NAME=link --><!-- /TMPL_LOOP -->"><!-- TMPL_VAR NAME="value" --></a><!-- /TMPL_LOOP --></li>
                 <!-- /TMPL_LOOP -->
+
                </ul>
             </li>
         <!-- /TMPL_IF -->
                <!-- TMPL_IF name="publishercode" -->
     <li><strong>Published by:</strong>
-        <a href="/cgi-bin/koha/opac-search.pl?q=pb:<!-- TMPL_VAR NAME="publishercode"-->">
+        <a href="/cgi-bin/koha/catalogue/search.pl?q=pb:<!-- TMPL_VAR NAME="publishercode"-->">
             <!-- TMPL_VAR NAME="publishercode" --> 
         </a> <!-- TMPL_IF name="place" -->(<!-- TMPL_VAR NAME="place"-->)<!--/TMPL_IF--> <!-- TMPL_IF NAME="publicationyear" -->, <!-- TMPL_VAR NAME="publicationyear" --><!-- /TMPL_IF --> <!-- TMPL_IF NAME="editionstatement" --><!-- TMPL_VAR NAME="editionstatement" --><!-- /TMPL_IF --> <!-- TMPL_IF NAME="editionresponsability" --><!-- TMPL_VAR NAME="editionresponsability" --><!-- /TMPL_IF -->
     </li>
index 03f9388..fe25014 100755 (executable)
 
     <!-- TMPL_IF name="MARCAUTHORS" -->
     <p><span class="label">Authors:</span>
-        <!-- TMPL_LOOP NAME="MARCAUTHORS" -->
-        <a href="/cgi-bin/koha/opac-search.pl?q=au:<!-- TMPL_VAR NAME="value" -->">
-            <!-- TMPL_VAR NAME="value" -->
-        </a>|
-        <!-- /TMPL_LOOP -->
+                               <!-- TMPL_LOOP NAME="MARCAUTHORS" -->
+                <!-- TMPL_LOOP NAME="MARCAUTHOR_SUBFIELDS_LOOP" --><!-- TMPL_VAR NAME="separator" --><a title="‡<!-- TMPL_VAR NAME=code --> <!-- TMPL_VAR NAME=value -->" href="/cgi-bin/koha/opac-search.pl?q=<!-- TMPL_LOOP NAME=link_loop --><!-- TMPL_VAR NAME=operator --><!-- TMPL_VAR name='limit' -->:<!-- TMPL_VAR NAME=link --><!-- /TMPL_LOOP -->"><!-- TMPL_VAR NAME="value" --></a><!-- /TMPL_LOOP -->
+                <!-- /TMPL_LOOP -->
+
     </p>
     <!-- /TMPL_IF -->
     <!-- TMPL_IF name="editionstatement" -->