[Koha-patches] [PATCH] Bug 7943: Authority search results are untranslatable

Jared Camins-Esakov jcamins at cpbibliography.com
Thu Jun 14 00:01:30 CEST 2012


The HTML for authority search results was previously generated in
C4::AuthoritiesMarc::BuildSummary, which meant that it couldn't be
translated. This patch moves the HTML generation into the templates
by introducing a new authorities-search-results.inc include file for
both the OPAC and the Intranet which contains a Template::Toolkit BLOCK
for rendering the authority results. Fixes the authority autocomplete
by removing the untranslatable strings, and returning only data from
the database.

To test:
1. Apply patch.
2. Test authority searching in the authority module in the staff client
3. Test authority searching in the authority control plugin in the
   cataloguing module (and the plugin for UNIMARC field 210$c, if you
   can figure out how)
4. Test authority searching in the OPAC
---
 C4/Auth.pm                                         |    5 +-
 C4/AuthoritiesMarc.pm                              |  335 ++++++++++----------
 authorities/ysearch.pl                             |   15 +-
 cataloguing/addbiblio.pl                           |    1 -
 .../intranet-tmpl/prog/en/css/staff-global.css     |    9 +
 .../en/includes/authorities-search-results.inc     |   60 ++++
 .../modules/authorities/searchresultlist-auth.tt   |    3 +-
 .../en/modules/authorities/searchresultlist.tt     |    3 +-
 .../value_builder/unimarc_field_210c.tt            |    3 +-
 koha-tmpl/opac-tmpl/prog/en/css/opac.css           |    9 +
 .../en/includes/authorities-search-results.inc     |   60 ++++
 .../prog/en/modules/opac-auth-MARCdetail.tt        |   87 +++++
 .../prog/en/modules/opac-authoritiesdetail.tt      |   85 -----
 .../en/modules/opac-authoritiessearchresultlist.tt |    8 +-
 opac/opac-authoritiesdetail.pl                     |   29 +-
 15 files changed, 426 insertions(+), 286 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc
 create mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc
 create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-MARCdetail.tt
 delete mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiesdetail.tt

diff --git a/C4/Auth.pm b/C4/Auth.pm
index c97046a..66e70bd 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -315,7 +315,7 @@ sub get_template_and_user {
             "BiblioDefaultView".C4::Context->preference("BiblioDefaultView")         => 1,
             EnhancedMessagingPreferences => C4::Context->preference('EnhancedMessagingPreferences'),
             GoogleJackets                => C4::Context->preference("GoogleJackets"),
-	    OpenLibraryCovers            => C4::Context->preference("OpenLibraryCovers"),
+            OpenLibraryCovers            => C4::Context->preference("OpenLibraryCovers"),
             KohaAdminEmailAddress        => "" . C4::Context->preference("KohaAdminEmailAddress"),
             LoginBranchcode              => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"),
             LoginFirstname               => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
@@ -328,7 +328,8 @@ sub get_template_and_user {
             XSLTDetailsDisplay           => C4::Context->preference("XSLTDetailsDisplay"),
             XSLTResultsDisplay           => C4::Context->preference("XSLTResultsDisplay"),
             using_https                  => $in->{'query'}->https() ? 1 : 0,
-            noItemTypeImages            => C4::Context->preference("noItemTypeImages"),
+            noItemTypeImages             => C4::Context->preference("noItemTypeImages"),
+            marcflavour                  => C4::Context->preference("marcflavour"),
     );
 
     if ( $in->{'type'} eq "intranet" ) {
diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index 5ea5098..c92c319 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -46,12 +46,12 @@ BEGIN {
     	&DelAuthority
     	&GetAuthority
     	&GetAuthorityXML
-    
+
     	&CountUsage
     	&CountUsageChildren
     	&SearchAuthorities
     
-    	&BuildSummary
+        &BuildSummary
     	&BuildUnimarcHierarchies
     	&BuildUnimarcHierarchy
     
@@ -926,9 +926,9 @@ sub FindDuplicateAuthority {
 
 =head2 BuildSummary
 
-  $text= &BuildSummary( $record, $authid, $authtypecode)
+  $summary= &BuildSummary( $record, $authid, $authtypecode)
 
-return HTML encoded Summary
+Returns a hashref with a summary of the specified record.
 
 Comment : authtypecode can be infered from both record and authid.
 Moreover, authid can also be inferred from $record.
@@ -936,171 +936,176 @@ Would it be interesting to delete those things.
 
 =cut
 
-sub BuildSummary{
-## give this a Marc record to return summary
-  my ($record,$authid,$authtypecode)=@_;
-  my $dbh=C4::Context->dbh;
-  my $summary;
-  # handle $authtypecode is NULL or eq ""
-  if ($authtypecode) {
-  	my $authref = GetAuthType($authtypecode);
-  	$summary = $authref->{summary};
-  }
-  # FIXME: should use I18N.pm
-  my %language;
-  $language{'fre'}="Français";
-  $language{'eng'}="Anglais";
-  $language{'ger'}="Allemand";
-  $language{'ita'}="Italien";
-  $language{'spa'}="Espagnol";
-  my %thesaurus;
-  $thesaurus{'1'}="Peuples";
-  $thesaurus{'2'}="Anthroponymes";
-  $thesaurus{'3'}="Oeuvres";
-  $thesaurus{'4'}="Chronologie";
-  $thesaurus{'5'}="Lieux";
-  $thesaurus{'6'}="Sujets";
-  #thesaurus a remplir
-  my @fields = $record->fields();
-  my $reported_tag;
-  # if the library has a summary defined, use it. Otherwise, build a standard one
-  # FIXME - it appears that the summary field in the authority frameworks
-  #         can work as a display template.  However, this doesn't
-  #         suit the MARC21 version, so for now the "templating"
-  #         feature will be enabled only for UNIMARC for backwards
-  #         compatibility.
-  if ($summary and C4::Context->preference('marcflavour') eq 'UNIMARC') {
-    my @fields = $record->fields();
-    #             $reported_tag = '$9'.$result[$counter];
-	my @stringssummary;
-    foreach my $field (@fields) {
-      my $tag = $field->tag();
-      my $tagvalue = $field->as_string();
-      my $localsummary= $summary;
-	  $localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g;
-      if ($tag<10) {
-        if ($tag eq '001') {
-          $reported_tag.='$3'.$field->data();
-        }
-      } else {
-        my @subf = $field->subfields;
-        for my $i (0..$#subf) {
-          my $subfieldcode = $subf[$i][0];
-          my $subfieldvalue = $subf[$i][1];
-          my $tagsubf = $tag.$subfieldcode;
-          $localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g;
-        }
-      }
-	  push @stringssummary, $localsummary if ($localsummary ne $summary);
+sub BuildSummary {
+    ## give this a Marc record to return summary
+    my ($record,$authid,$authtypecode)=@_;
+    my $dbh=C4::Context->dbh;
+    my %summary;
+    # handle $authtypecode is NULL or eq ""
+    if ($authtypecode) {
+        my $authref = GetAuthType($authtypecode);
+        $summary{authtypecode} = $authref->{authtypecode};
+        $summary{type} = $authref->{authtypetext};
+        $summary{summary} = $authref->{summary};
     }
-	my $resultstring;
-	$resultstring = join(" -- ", at stringssummary);
-    $resultstring =~ s/\[(.*?)\]//g;
-    $resultstring =~ s/\n/<br\/>/g;
-	$summary      =  $resultstring;
-  } else {
-    my $heading = '';
-    my $altheading = '';
-    my $seealso = '';
-    my $broaderterms = '';
-    my $narrowerterms = '';
-    my $see = '';
-    my $seeheading = '';
-    my $notes = '';
+    my $marc21subfields = 'abcdfghjklmnopqrstuvxyz';
+    my %marc21controlrefs = ( 'a' => 'earlier',
+        'b' => 'later',
+        'd' => 'acronym',
+        'f' => 'musical',
+        'g' => 'broader',
+        'h' => 'narrower',
+        'i' => 'subfi',
+        't' => 'parent'
+    );
+    my %thesaurus;
+    $thesaurus{'1'}="Peuples";
+    $thesaurus{'2'}="Anthroponymes";
+    $thesaurus{'3'}="Oeuvres";
+    $thesaurus{'4'}="Chronologie";
+    $thesaurus{'5'}="Lieux";
+    $thesaurus{'6'}="Sujets";
+    #thesaurus a remplir
     my @fields = $record->fields();
-    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
-    # construct UNIMARC summary, that is quite different from MARC21 one
-      # accepted form
-      foreach my $field ($record->field('2..')) {
-        $heading.= $field->as_string('abcdefghijlmnopqrstuvwxyz');
-      }
-      # rejected form(s)
-      foreach my $field ($record->field('3..')) {
-        $notes.= '<span class="note">'.$field->subfield('a')."</span>\n";
-      }
-      foreach my $field ($record->field('4..')) {
-        if ($field->subfield('2')) {
-            my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : ";
-            $see.= '<span class="UF">'.$thesaurus.$field->as_string('abcdefghijlmnopqrstuvwxyz')."</span> -- \n";
+    my $reported_tag;
+# if the library has a summary defined, use it. Otherwise, build a standard one
+# FIXME - it appears that the summary field in the authority frameworks
+#         can work as a display template.  However, this doesn't
+#         suit the MARC21 version, so for now the "templating"
+#         feature will be enabled only for UNIMARC for backwards
+#         compatibility.
+    if ($summary{summary} and C4::Context->preference('marcflavour') eq 'UNIMARC') {
+        my @fields = $record->fields();
+#             $reported_tag = '$9'.$result[$counter];
+        my @stringssummary;
+        foreach my $field (@fields) {
+            my $tag = $field->tag();
+            my $tagvalue = $field->as_string();
+            my $localsummary= $summary{summary};
+            $localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g;
+            if ($tag<10) {
+                if ($tag eq '001') {
+                    $reported_tag.='$3'.$field->data();
+                }
+            } else {
+                my @subf = $field->subfields;
+                for my $i (0..$#subf) {
+                    my $subfieldcode = $subf[$i][0];
+                    my $subfieldvalue = $subf[$i][1];
+                    my $tagsubf = $tag.$subfieldcode;
+                    $localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g;
+                }
+            }
+            push @stringssummary, $localsummary if ($localsummary ne $summary{summary});
         }
-      }
-      # see :
-      foreach my $field ($record->field('5..')) {
-            
-        if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) {
-          $broaderterms.= '<span class="BT"> '.$field->as_string('abcdefgjxyz')."</span> -- \n";
-        } elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){
-          $narrowerterms.= '<span class="NT">'.$field->as_string('abcdefgjxyz')."</span> -- \n";
-        } elsif ($field->subfield('a')) {
-          $seealso.= '<span class="RT">'.$field->as_string('abcdefgxyz')."</a></span> -- \n";
+        my $resultstring;
+        $resultstring = join(" -- ", at stringssummary);
+        $resultstring =~ s/\[(.*?)\]//g;
+        $resultstring =~ s/\n/<br>/g;
+        $summary{summary}      =  $resultstring;
+    } else {
+        my @authorized;
+        my @notes;
+        my @seefrom;
+        my @seealso;
+        my @otherscript;
+        my @fields = $record->fields();
+        if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
+# construct UNIMARC summary, that is quite different from MARC21 one
+# accepted form
+            foreach my $field ($record->field('2..')) {
+                push @authorized, $field->as_string('abcdefghijlmnopqrstuvwxyz');
+            }
+# rejected form(s)
+            foreach my $field ($record->field('3..')) {
+                push @notes, $field->subfield('a');
+            }
+            foreach my $field ($record->field('4..')) {
+                my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : '';
+                push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom' };
+            }
+# see :
+            foreach my $field ($record->field('5..')) {
+                if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) {
+                    push @seealso, { $field->as_string('abcdefgjxyz'), type => 'broader' };
+                } elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){
+                    push @seealso, { heading => $field->as_string('abcdefgjxyz'), type => 'narrower' };
+                } elsif ($field->subfield('a')) {
+                    push @seealso, { heading => $field->as_string('abcdefgxyz'), type => 'seealso' };
+                }
+            }
+# // form
+            foreach my $field ($record->field('7..')) {
+                my $lang = substr($field->subfield('8'),3,3);
+                push @otherscript, { lang => $lang, term => $field->subfield('a') };
+            }
+        } else {
+# construct MARC21 summary
+# FIXME - looping over 1XX is questionable
+# since MARC21 authority should have only one 1XX
+            foreach my $field ($record->field('1..')) {
+                my $tag = $field->tag();
+                next if "152" eq $tag;
+# FIXME - 152 is not a good tag to use
+# in MARC21 -- purely local tags really ought to be
+# 9XX
+                if ($tag eq '100') {
+                    push @authorized, $field->as_string('abcdefghjklmnopqrstvxyz68');
+                } elsif ($tag eq '110') {
+                    push @authorized, $field->as_string('abcdefghklmnoprstvxyz68');
+                } elsif ($tag eq '111') {
+                    push @authorized, $field->as_string('acdefghklnpqstvxyz68');
+                } elsif ($tag eq '130') {
+                    push @authorized, $field->as_string('adfghklmnoprstvxyz68');
+                } elsif ($tag eq '148') {
+                    push @authorized, $field->as_string('abvxyz68');
+                } elsif ($tag eq '150') {
+                    push @authorized, $field->as_string('abvxyz68');
+                } elsif ($tag eq '151') {
+                    push @authorized, $field->as_string('avxyz68');
+                } elsif ($tag eq '155') {
+                    push @authorized, $field->as_string('abvxyz68');
+                } elsif ($tag eq '180') {
+                    push @authorized, $field->as_string('vxyz68');
+                } elsif ($tag eq '181') {
+                    push @authorized, $field->as_string('vxyz68');
+                } elsif ($tag eq '182') {
+                    push @authorized, $field->as_string('vxyz68');
+                } elsif ($tag eq '185') {
+                    push @authorized, $field->as_string('vxyz68');
+                } else {
+                    push @authorized, $field->as_string();
+                }
+            } #See From
+            foreach my $field ($record->field('4..')) {
+                my $type = 'seefrom';
+                $type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w'));
+                if ($type eq 'subfi') {
+                    push @seefrom, { heading => $field->as_string($marc21subfields), type => $field->subfield('i') };
+                } else {
+                    push @seefrom, { heading => $field->as_string($marc21subfields), type => $type };
+                }
+            } #See Also
+            foreach my $field ($record->field('5..')) {
+                my $type = 'seealso';
+                $type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w'));
+                if ($type eq 'subfi') {
+                    push @seealso, { heading => $field->as_string($marc21subfields), type => $field->subfield('i') };
+                } else {
+                    push @seealso, { heading => $field->as_string($marc21subfields), type => $type };
+                }
+            }
+            foreach my $field ($record->field('6..')) {
+                push @notes, $field->as_string();
+            }
         }
-      }
-      # // form
-      foreach my $field ($record->field('7..')) {
-        my $lang = substr($field->subfield('8'),3,3);
-        $seeheading.= '<span class="langue"> En '.$language{$lang}.' : </span><span class="OT"> '.$field->subfield('a')."</span><br />\n";  
-      }
-            $broaderterms =~s/-- \n$//;
-            $narrowerterms =~s/-- \n$//;
-            $seealso =~s/-- \n$//;
-            $see =~s/-- \n$//;
-      $summary = $heading."<br />".($notes?"$notes <br />":"");
-      $summary.= '<p><div class="label">TG : '.$broaderterms.'</div></p>' if ($broaderterms);
-      $summary.= '<p><div class="label">TS : '.$narrowerterms.'</div></p>' if ($narrowerterms);
-      $summary.= '<p><div class="label">TA : '.$seealso.'</div></p>' if ($seealso);
-      $summary.= '<p><div class="label">EP : '.$see.'</div></p>' if ($see);
-      $summary.= '<p><div class="label">'.$seeheading.'</div></p>' if ($seeheading);
-      } else {
-      # construct MARC21 summary
-          # FIXME - looping over 1XX is questionable
-          # since MARC21 authority should have only one 1XX
-          foreach my $field ($record->field('1..')) {
-              next if "152" eq $field->tag(); # FIXME - 152 is not a good tag to use
-                                              # in MARC21 -- purely local tags really ought to be
-                                              # 9XX
-              if ($record->field('100')) {
-                  $heading.= $field->as_string('abcdefghjklmnopqrstvxyz68');
-              } elsif ($record->field('110')) {
-                                      $heading.= $field->as_string('abcdefghklmnoprstvxyz68');
-              } elsif ($record->field('111')) {
-                                      $heading.= $field->as_string('acdefghklnpqstvxyz68');
-              } elsif ($record->field('130')) {
-                                      $heading.= $field->as_string('adfghklmnoprstvxyz68');
-              } elsif ($record->field('148')) {
-                                      $heading.= $field->as_string('abvxyz68');
-              } elsif ($record->field('150')) {
-                  $heading.= $field->as_string('abvxyz68');
-              #$heading.= $field->as_formatted();
-              my $tag=$field->tag();
-              $heading=~s /^$tag//g;
-              $heading =~s /\_/\$/g;
-              } elsif ($record->field('151')) {
-                                      $heading.= $field->as_string('avxyz68');
-              } elsif ($record->field('155')) {
-                                      $heading.= $field->as_string('abvxyz68');
-              } elsif ($record->field('180')) {
-                                      $heading.= $field->as_string('vxyz68');
-              } elsif ($record->field('181')) {
-                                      $heading.= $field->as_string('vxyz68');
-              } elsif ($record->field('182')) {
-                                      $heading.= $field->as_string('vxyz68');
-              } elsif ($record->field('185')) {
-                                      $heading.= $field->as_string('vxyz68');
-              } else {
-                  $heading.= $field->as_string();
-              }
-          } #See From
-          foreach my $field ($record->field('4..')) {
-              $seeheading.= "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>used for/see from:</i> ".$field->as_string();
-          } #See Also
-          foreach my $field ($record->field('5..')) {
-              $altheading.= "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$field->as_string();
-          }
-          $summary .= ": " if $summary;
-          $summary.=$heading.$seeheading.$altheading;
-      }
-  }
-  return $summary;
+        $summary{authorized} = \@authorized;
+        $summary{notes} = \@notes;
+        $summary{seefrom} = \@seefrom;
+        $summary{seealso} = \@seealso;
+        $summary{otherscript} = \@otherscript;
+    }
+    return \%summary;
 }
 
 =head2 BuildUnimarcHierarchies
diff --git a/authorities/ysearch.pl b/authorities/ysearch.pl
index 1f7e5ef..c9e7c47 100755
--- a/authorities/ysearch.pl
+++ b/authorities/ysearch.pl
@@ -66,14 +66,15 @@ if ( $auth_status ne "ok" ) {
 
 print "[";
 my $i = 0;
-    foreach (@$results) {
+    foreach my $result (@$results) {
         if($i > 0){ print ","; }
-        my ($value) = $_->{'summary'};
-            # Removes new lines
-            $value =~ s/<br \/>/ /g;
-            $value =~ s/\n//g;
-            $value = "{\"summary\":\"" . $value . "\"" . "}";
+        my $value = '';
+        my $authorized = $result->{'summary'}->{authorized};
+        foreach my $heading (@$authorized) {
+            $value .= $heading . ' ';
+        }
+        $value = "{\"summary\":\"" . $value . "\"" . "}";
         print nsb_clean($value) . "\n";
         $i++;
     }
-print "]";
\ No newline at end of file
+print "]";
diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
index d5778a4..643fc53 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -984,7 +984,6 @@ $template->param(
     frameworkcode => $frameworkcode,
     itemtype => $frameworkcode,
     borrowernumber => $loggedinuser, 
-    marcflavour => C4::Context->preference("marcflavour"),
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index 555005b..7513a6f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -2364,3 +2364,12 @@ ul.ui-tabs-nav li {
 #header_search .ui-corner-top {
      border-radius: 0 0 4px 4px;
 }
+
+
+.authref {
+    text-indent: 2em;
+}
+
+.authref .label {
+    font-style: italic;
+}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc
new file mode 100644
index 0000000..44ea78c
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc
@@ -0,0 +1,60 @@
+[% BLOCK showreference %]
+    [% IF marcflavour == 'UNIMARC' %]
+        [% SWITCH type %]
+        [% CASE 'broader' %]
+            <span class="BT">[% heading %]</span> --
+        [% CASE 'narrower' %]
+            <span class="NT">[% heading %]</span> --
+        [% CASE 'narrower' %]
+            <span class="NT">[% heading %]</span> --
+        [% CASE 'seefrom' %]
+            <span class="UF">[% heading %]</span> --
+        [% CASE 'seealso' %]
+            <span class="RT">[% heading %]</span> --
+        [% END %]
+    [% ELSE %]
+        [% IF ( label ) %]<span class="label">[% label %]</span>[% END %]
+        <span class="heading">[% heading %]</span>
+        [% UNLESS ( type=='seefrom' || type=='seealso' ) %]<span class="type">[% SWITCH type %]
+        [% CASE 'earlier' %](Earlier heading)
+        [% CASE 'later' %](Later heading)
+        [% CASE 'acronym' %](Acronym)
+        [% CASE 'musical' %](Musical composition)
+        [% CASE 'broader' %](Broader heading)
+        [% CASE 'narrower' %](Narrower heading)
+        [% CASE %]([% type %])
+        [% END %]</span>[% END %]
+    [% END %]
+[% END %]
+[% BLOCK authresult %]
+    [% IF ( summary.summary ) %][% summary.summary %]:[% END %]
+    [% UNLESS ( summary.summaryonly ) %]
+        [% FOREACH authorize IN summary.authorized %]
+            <span class="authorizedheading">[% authorize %]</span>
+        [% END %]
+        [% IF ( marcflavour == 'UNIMARC' ) %]
+            [% FOREACH note IN summary.notes %]
+                <span class="note">[% note %]</span>
+            [% END %]
+            [% FOREACH seefro IN summary.seefrom %]
+                [% PROCESS showreference heading=seefro.heading label="" type=seefro.type %]
+            [% END %]
+        [% ELSE %]
+            [% IF ( summary.seefrom ) %]
+                [% FOREACH seefro IN summary.seefrom %]
+                    <div class="seefrom authref">
+                    [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type %]
+                    </div>
+                [% END %]
+            [% END %]
+            [% IF ( summary.seealso ) %]
+                [% FOREACH seeals IN summary.seealso %]
+                    <div class="seealso authref">
+                    [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type %]
+                    </div>
+                [% END %]
+            [% END %]
+        [% END %]
+    [% END %]
+[% END %]
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt
index 7fd5607..2881710 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt
@@ -1,3 +1,4 @@
+[% PROCESS 'authorities-search-results.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Cataloging authority plugin</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -67,7 +68,7 @@ function jumpfull(page)
                 </tr>
                 [% FOREACH resul IN result %]
                     <tr>
-                        <td>[% resul.summary %]</td>
+                        <td>[% PROCESS authresult summary=resul.summary %]</td>
                         <td>[% resul.used %] times</td>
                         <td>
                           [% IF resul.repets %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt
index 1131871..038959f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt
@@ -1,3 +1,4 @@
+[% PROCESS 'authorities-search-results.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Authorities &rsaquo; Authority search results</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -63,7 +64,7 @@ function searchauthority() {
     [% ELSE %]
     <tr>
     [% END %]
-      <td>[% resul.summary %]</td>
+      <td>[% PROCESS authresult summary=resul.summary %]</td>
       <td><a href="detail.pl?authid=[% resul.authid %]">Details</a></td>
   [% UNLESS ( resul.isEDITORS ) %]
       <td>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt
index 5306146..043e700 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt
@@ -1,3 +1,4 @@
+[% PROCESS 'authorities-search-results.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>UNIMARC field 210c builder</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -59,7 +60,7 @@
                 </tr>
                 [% FOREACH resul IN result %]
                     <tr>
-                        <td>[% resul.summary %]</td>
+                        <td>[% PROCESS authresult summary=resul.summary %]</td>
                         <td>[% resul.used %] times</td>
                         <td>
                 [% IF ( resul.to_report ) %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
index 6223025..e2996a9 100644
--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css
+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
@@ -2585,6 +2585,15 @@ ul.ui-tabs-nav li {
     color: #222222;
 }
 
+.authref {
+    text-indent: 2em;
+}
+
+.authref .label {
+ font-style: italic;
+}
+
+
 /* ## BABELTHEQUE ## */
 /* Uncomment if babeltheque configuration no contains these lines */
 /*
diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc
new file mode 100644
index 0000000..44ea78c
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc
@@ -0,0 +1,60 @@
+[% BLOCK showreference %]
+    [% IF marcflavour == 'UNIMARC' %]
+        [% SWITCH type %]
+        [% CASE 'broader' %]
+            <span class="BT">[% heading %]</span> --
+        [% CASE 'narrower' %]
+            <span class="NT">[% heading %]</span> --
+        [% CASE 'narrower' %]
+            <span class="NT">[% heading %]</span> --
+        [% CASE 'seefrom' %]
+            <span class="UF">[% heading %]</span> --
+        [% CASE 'seealso' %]
+            <span class="RT">[% heading %]</span> --
+        [% END %]
+    [% ELSE %]
+        [% IF ( label ) %]<span class="label">[% label %]</span>[% END %]
+        <span class="heading">[% heading %]</span>
+        [% UNLESS ( type=='seefrom' || type=='seealso' ) %]<span class="type">[% SWITCH type %]
+        [% CASE 'earlier' %](Earlier heading)
+        [% CASE 'later' %](Later heading)
+        [% CASE 'acronym' %](Acronym)
+        [% CASE 'musical' %](Musical composition)
+        [% CASE 'broader' %](Broader heading)
+        [% CASE 'narrower' %](Narrower heading)
+        [% CASE %]([% type %])
+        [% END %]</span>[% END %]
+    [% END %]
+[% END %]
+[% BLOCK authresult %]
+    [% IF ( summary.summary ) %][% summary.summary %]:[% END %]
+    [% UNLESS ( summary.summaryonly ) %]
+        [% FOREACH authorize IN summary.authorized %]
+            <span class="authorizedheading">[% authorize %]</span>
+        [% END %]
+        [% IF ( marcflavour == 'UNIMARC' ) %]
+            [% FOREACH note IN summary.notes %]
+                <span class="note">[% note %]</span>
+            [% END %]
+            [% FOREACH seefro IN summary.seefrom %]
+                [% PROCESS showreference heading=seefro.heading label="" type=seefro.type %]
+            [% END %]
+        [% ELSE %]
+            [% IF ( summary.seefrom ) %]
+                [% FOREACH seefro IN summary.seefrom %]
+                    <div class="seefrom authref">
+                    [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type %]
+                    </div>
+                [% END %]
+            [% END %]
+            [% IF ( summary.seealso ) %]
+                [% FOREACH seeals IN summary.seealso %]
+                    <div class="seealso authref">
+                    [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type %]
+                    </div>
+                [% END %]
+            [% END %]
+        [% END %]
+    [% END %]
+[% END %]
+
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-MARCdetail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-MARCdetail.tt
new file mode 100644
index 0000000..8e87d71
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-MARCdetail.tt
@@ -0,0 +1,87 @@
+[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo;  Entry
+[% INCLUDE 'doc-head-close.inc' %]
+[% IF ( displayhierarchy ) %]
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/hierarchy.css">
+<script language="JavaScript" type="text/javascript">
+function showParents(mynumber) {
+  var parents=document.getElementsByName(mynumber+'p')
+  for(i=0;i<parents.length;i++){
+    if (parents[i].style.display == "none") {
+      parents[i].style.display ="block";
+    } else {
+      parents[i].style.display ="none";
+    }
+  } 
+}
+function showChildren(mynumber) {
+  var children=document.getElementsByName(mynumber+'c')
+  for(i=0;i<children.length;i++){
+    if (children[i].style.display == "none") {
+      children[i].style.display = "block";
+    } else {
+      children[i].style.display = "none";
+    }
+  }
+}
+</script>
+[% END %]
+</head>
+<body id="opac-authoritiesdetail">
+
+<div id="doc3" class="yui-t1">
+   <div id="bd">
+[% INCLUDE 'masthead.inc' %]
+	<div id="yui-main">
+	<div class="yui-b"><div class="yui-g">
+<div id="userauthdetails" class="container">
+
+[% IF ( displayhierarchy ) %]
+
+<div class="hierarchies">
+[% FOREACH loophierarchie IN loophierarchies %]
+  <div class="hierarchy">
+  [% FOREACH loopelemen IN loophierarchie.loopelement %]
+    <div id="[% loopelemen.loopauthid %]" class="[% loopelemen.class %]">
+    [% IF ( loopelemen.current_value ) %]
+        [% loopelemen.value %]
+    [% ELSE %]
+        <a href="opac-authoritiesdetail.pl?authid=[% loopelemen.loopauthid %]" title="Term">[% loopelemen.value %]</a>
+    [% END %]
+    [% IF ( loopelemen.ifchildren ) %]
+      <sub><a class="parents" title="Narrower terms" href="JavaScript:showChildren('[% loopelemen.loopauthid %]');">+</a></sub><br/>
+      [% FOREACH loopchildre IN loopelemen.loopchildren %]
+        <div name="[% loopchildre.loopauthid %]c" class="child"> <a href="opac-authoritiesdetail.pl?authid=[% loopchildre.childauthid %]">[% loopchildre.childvalue %]</a></div>
+      [% END %]
+    [% END %]
+    </div>
+  [% END %]
+    
+  </div>
+[% END %]
+</div>
+[% END %]
+<h1>Entry [% authtypetext %]</h1>
+	<p>Used in <a href="opac-search.pl?type=opac&amp;q=[% authid %]&amp;idx=an,phr">[% count %] records</a></p>
+        [% FOREACH Tag0X IN Tab0XX %]
+        <p><b>[% Tag0X.tag %]</b></p>
+        <ul>
+        [% FOREACH subfiel IN Tag0X.subfield %]
+            <p><b>[% subfiel.marc_lib %]:</b>
+            [% IF subfiel.isurl %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value %]</a>
+            [% ELSE %][% subfiel.marc_value %][% END %]</p>
+        [% END %]
+        </ul>
+        [% END %]
+</div>	
+
+</div>
+</div>
+</div>
+[% IF ( OpacNav ) %]
+<div class="yui-b">
+<div id="leftmenus" class="container">
+[% INCLUDE 'navigation.inc' %]
+</div>
+</div>[% END %]
+</div>
+[% INCLUDE 'opac-bottom.inc' %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiesdetail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiesdetail.tt
deleted file mode 100644
index 287f6d1..0000000
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiesdetail.tt
+++ /dev/null
@@ -1,85 +0,0 @@
-[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo;  Entry
-[% INCLUDE 'doc-head-close.inc' %]
-[% IF ( displayhierarchy ) %]
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/hierarchy.css">
-<script language="JavaScript" type="text/javascript">
-function showParents(mynumber) {
-  var parents=document.getElementsByName(mynumber+'p')
-  for(i=0;i<parents.length;i++){
-    if (parents[i].style.display == "none") {
-      parents[i].style.display ="block";
-    } else {
-      parents[i].style.display ="none";
-    }
-  } 
-}
-function showChildren(mynumber) {
-  var children=document.getElementsByName(mynumber+'c')
-  for(i=0;i<children.length;i++){
-    if (children[i].style.display == "none") {
-      children[i].style.display = "block";
-    } else {
-      children[i].style.display = "none";
-    }
-  }
-}
-</script>
-[% END %]
-</head>
-<body id="opac-authoritiesdetail">
-
-<div id="doc3" class="yui-t1">
-   <div id="bd">
-[% INCLUDE 'masthead.inc' %]
-	<div id="yui-main">
-	<div class="yui-b"><div class="yui-g">
-<div id="userauthdetails" class="container">
-
-[% IF ( displayhierarchy ) %]
-
-<div class="hierarchies">
-[% FOREACH loophierarchie IN loophierarchies %]
-  <div class="hierarchy">
-  [% FOREACH loopelemen IN loophierarchie.loopelement %]
-    <div id="[% loopelemen.loopauthid %]" class="[% loopelemen.class %]">
-    [% IF ( loopelemen.current_value ) %]
-        [% loopelemen.value %]
-    [% ELSE %]
-        <a href="opac-authoritiesdetail.pl?authid=[% loopelemen.loopauthid %]" title="Term">[% loopelemen.value %]</a>
-    [% END %]
-    [% IF ( loopelemen.ifchildren ) %]
-      <sub><a class="parents" title="Narrower terms" href="JavaScript:showChildren('[% loopelemen.loopauthid %]');">+</a></sub><br/>
-      [% FOREACH loopchildre IN loopelemen.loopchildren %]
-        <div name="[% loopchildre.loopauthid %]c" class="child"> <a href="opac-authoritiesdetail.pl?authid=[% loopchildre.childauthid %]">[% loopchildre.childvalue %]</a></div>
-      [% END %]
-    [% END %]
-    </div>
-  [% END %]
-    
-  </div>
-[% END %]
-</div>
-[% END %]
-<h1>Entry [% authtypetext %]</h1>
-	<p>Used in <a href="opac-search.pl?type=opac&amp;q=[% authid %]&amp;idx=an,phr">[% count %] records</a></p>
-        [% FOREACH Tag0X IN Tab0XX %]
-        <p><b>[% Tag0X.tag %]</b></p>
-        <ul>
-        [% FOREACH subfiel IN Tag0X.subfield %]
-                <p><b>[% subfiel.marc_lib %]:</b> [% subfiel.marc_value %]</p>
-            [% END %]
-        </ul>
-        [% END %]
-</div>	
-
-</div>
-</div>
-</div>
-[% IF ( OpacNav ) %]
-<div class="yui-b">
-<div id="leftmenus" class="container">
-[% INCLUDE 'navigation.inc' %]
-</div>
-</div>[% END %]
-</div>
-[% INCLUDE 'opac-bottom.inc' %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
index 5fdfb27..a27480a 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
@@ -1,3 +1,4 @@
+[% PROCESS 'authorities-search-results.inc' %]
 [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; [% IF ( total ) %]Authority search result[% ELSE %]No results found[% END %]
 [% INCLUDE 'doc-head-close.inc' %]
 </head>
@@ -52,11 +53,8 @@
             [% ELSE %]
                 <tr>
             [% END %]
-					<td>[% resul.summary %]</td>
-
-						<td>
-					[% authtypetext %]
-						</td>
+                    <td>[% PROCESS authresult summary=resul.summary %]</td>
+                    <td>[% authtypetext %]</td>
 					[% UNLESS ( resul.isEDITORS ) %]
 						<td>
 							 <a href="/cgi-bin/koha/opac-search.pl?type=opac&amp;op=do_search&amp;q=an=[% resul.authid %]">[% resul.used %] biblios</a>
diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl
index 6610dfd..41b994f 100755
--- a/opac/opac-authoritiesdetail.pl
+++ b/opac/opac-authoritiesdetail.pl
@@ -52,9 +52,8 @@ my $query = new CGI;
 
 my $dbh = C4::Context->dbh;
 
-my $authid       = $query->param('authid');
-my $authtypecode = &GetAuthTypeCode( $authid );
-my $tagslib      = &GetTagsLabels( 1, $authtypecode );
+my $display_hierarchy = C4::Context->preference("AuthDisplayHierarchy");
+my $show_marc = $query->param('marc') || 1; # Currently only MARC view is available
 
 # open template
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -67,8 +66,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
+my $authid       = $query->param('authid');
+my $authtypecode = &GetAuthTypeCode( $authid );
+my $tagslib      = &GetTagsLabels( 0, $authtypecode );
+
+
 my $record;
-if (C4::Context->preference("AuthDisplayHierarchy")){
+if ($display_hierarchy){
   my $trees=BuildUnimarcHierarchies($authid);
   my @trees = split /;/,$trees ;
   push @trees,$trees unless (@trees);
@@ -88,7 +92,7 @@ if (C4::Context->preference("AuthDisplayHierarchy")){
     push @loophierarchies, { 'loopelement' =>\@loophierarchy};
   }
   $template->param(
-    'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"),
+    'displayhierarchy' => $display_hierarchy,
     'loophierarchies' =>\@loophierarchies,
   );
 }
@@ -145,15 +149,10 @@ foreach my $field (@fields) {
             my %subfield_data;
             $subfield_data{marc_lib} =
               $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
-            if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl} ) {
-                $subfield_data{marc_value} =
-                  "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
-            }
-            else {
-                $subfield_data{marc_value} = $subf[$i][1];
-            }
             $subfield_data{marc_subfield} = $subf[$i][0];
             $subfield_data{marc_tag}      = $field->tag();
+            $subfield_data{isurl} =  $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl};
+            $subfield_data{marc_value} = $subf[$i][1];
             push( @subfields_data, \%subfield_data );
         }
     }
@@ -186,12 +185,6 @@ $template->param(
     biblio_fields        => $biblio_fields,
     authtypetext         => $authtypes->{$authtypecode}{'authtypetext'},
     authtypesloop        => \@authtypesloop,
-    LibraryName          => C4::Context->preference("LibraryName"),
-    OpacNav              => C4::Context->preference("OpacNav"),
-    opaccredits          => C4::Context->preference("opaccredits"),
-    opacsmallimage       => C4::Context->preference("opacsmallimage"),
-    opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
-    opaccolorstylesheet  => C4::Context->preference("opaccolorstylesheet"),
 );
 output_html_with_http_headers $query, $cookie, $template->output;
 
-- 
1.7.2.5



More information about the Koha-patches mailing list