From 068b1513e15323d9c5df18e658fd79d9f2793a07 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Wed, 30 May 2012 15:20:40 -0400 Subject: [PATCH] [3.8.x] Bug 7943: Authority search results are untranslatable Content-Type: text/plain; charset="UTF-8" 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 Signed-off-by: Katrin Fischer Tested with MARC21 data. 1) Applies cleanly on current HEAD. 2) Authority search in staff Patch works wonderfully, only some small notes found while testing that have not been changed by this patch: ENH note: Search terms show up nowhere. So if I want to change the sorting, I have to repeat typing in my search term. Even if the form does not keep the term, it should be visible somewhere on the screen what I searched for. ENH note: The pagination on top and at the bottom of the result list are formatted differently. Maybe some missing CSS? ENH note: Also the authority type is not shown at all in the result list. 3) Cataloguing and authority plugins The autocomplete function works nicely. ENH note: There is only one small enhancement I could imagine. If I start my search from 100 it will limit the search to 'persons' but the autocomplete will also suggest other authorities. It would be a bit cleaner, if the autocomplete could limit by the appropriate authority type too. Very nice feature. Plugins overall work nicely. Created links include the authority numbers and work correctly. 4) Authority search in OPAC Works nicely. Display is consistent, but translatability greatly improved. ENH note: In staff we use 'Details' in OPAC we use 'View full heading' - I wonder if maybe 'details' would be better understandable for users? Note: Code reveals a system preference 'AuthDisplayHierarchy' that is not available in the system preference editor. I talked to Jared and he will work on this feature later on. For now it's no regression, as the preference has never been visible. Signed-off-by: Jared Camins-Esakov Rebased for 3.8.x on 21 June 2012. --- C4/Auth.pm | 5 +- C4/AuthoritiesMarc.pm | 335 ++++++++++---------- authorities/ysearch.pl | 10 +- cataloguing/addbiblio.pl | 1 - .../intranet-tmpl/prog/en/css/staff-global.css | 9 + .../en/includes/authorities-search-results.inc | 59 ++++ .../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 | 59 ++++ ...uthoritiesdetail.tt => opac-auth-MARCdetail.tt} | 6 +- .../en/modules/opac-authoritiessearchresultlist.tt | 8 +- opac/opac-authoritiesdetail.pl | 29 +- 14 files changed, 340 insertions(+), 199 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 rename koha-tmpl/opac-tmpl/prog/en/modules/{opac-authoritiesdetail.tt => opac-auth-MARCdetail.tt} (92%) diff --git a/C4/Auth.pm b/C4/Auth.pm index 97ff3d4..fdbb010 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 7fed6d3..61d9591 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(" -- ",@stringssummary); - $resultstring =~ s/\[(.*?)\]//g; - $resultstring =~ s/\n//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.= ''.$field->subfield('a')."\n"; - } - foreach my $field ($record->field('4..')) { - if ($field->subfield('2')) { - my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : "; - $see.= ''.$thesaurus.$field->as_string('abcdefghijlmnopqrstuvwxyz')." -- \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.= ' '.$field->as_string('abcdefgjxyz')." -- \n"; - } elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){ - $narrowerterms.= ''.$field->as_string('abcdefgjxyz')." -- \n"; - } elsif ($field->subfield('a')) { - $seealso.= ''.$field->as_string('abcdefgxyz')." -- \n"; + my $resultstring; + $resultstring = join(" -- ",@stringssummary); + $resultstring =~ s/\[(.*?)\]//g; + $resultstring =~ s/\n/
/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.= ' En '.$language{$lang}.' : '.$field->subfield('a')."
\n"; - } - $broaderterms =~s/-- \n$//; - $narrowerterms =~s/-- \n$//; - $seealso =~s/-- \n$//; - $see =~s/-- \n$//; - $summary = $heading."
".($notes?"$notes
":""); - $summary.= '

TG : '.$broaderterms.'

' if ($broaderterms); - $summary.= '

TS : '.$narrowerterms.'

' if ($narrowerterms); - $summary.= '

TA : '.$seealso.'

' if ($seealso); - $summary.= '

EP : '.$see.'

' if ($see); - $summary.= '

'.$seeheading.'

' 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.= "
      used for/see from: ".$field->as_string(); - } #See Also - foreach my $field ($record->field('5..')) { - $altheading.= "
      see also: ".$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 56ef8e2..561ae4e 100755 --- a/authorities/ysearch.pl +++ b/authorities/ysearch.pl @@ -62,10 +62,14 @@ if ( $auth_status ne "ok" ) { my $startfrom = 0; my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby ); - foreach (@$results) { - my ($value) = $_->{'summary'}; + foreach my $result (@$results) { + my $value = ''; + my $authorized = $result->{'summary'}->{authorized}; + foreach my $heading (@$authorized) { + $value .= $heading . ' '; + } # Removes new lines $value =~ s/
/ /g; $value =~ s/\n//g; - print nsb_clean($value) . "\n"; + print nsb_clean($value) . "\n"; } 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 0fc678c..1587a0f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -2236,3 +2236,12 @@ div#acqui_order_supplierlist > div.supplier > span.action { div#acqui_order_supplierlist > div.supplier > div.baskets { margin-top: 0.5em; } + + +.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..92314b1 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc @@ -0,0 +1,59 @@ +[% BLOCK showreference %] + [% IF marcflavour == 'UNIMARC' %] + [% SWITCH type %] + [% CASE 'broader' %] + [% heading %] -- + [% CASE 'narrower' %] + [% heading %] -- + [% CASE 'narrower' %] + [% heading %] -- + [% CASE 'seefrom' %] + [% heading %] -- + [% CASE 'seealso' %] + [% heading %] -- + [% END %] + [% ELSE %] + [% IF ( label ) %][% label %][% END %] + [% heading %] + [% UNLESS ( type=='seefrom' || type=='seealso' ) %][% 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 %][% END %] + [% END %] +[% END %] +[% BLOCK authresult %] + [% IF ( summary.summary ) %][% summary.summary %]:[% END %] + [% UNLESS ( summary.summaryonly ) %] + [% FOREACH authorize IN summary.authorized %] + [% authorize %] + [% END %] + [% IF ( marcflavour == 'UNIMARC' ) %] + [% FOREACH note IN summary.notes %] + [% note %] + [% 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 %] +
+ [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type %] +
+ [% END %] + [% END %] + [% IF ( summary.seealso ) %] + [% FOREACH seeals IN summary.seealso %] +
+ [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type %] +
+ [% 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' %] Koha › Cataloging authority plugin [% INCLUDE 'doc-head-close.inc' %] @@ -67,7 +68,7 @@ function jumpfull(page) [% FOREACH resul IN result %] - [% resul.summary %] + [% PROCESS authresult summary=resul.summary %] [% resul.used %] times [% 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' %] Koha › Authorities › Authority search results [% INCLUDE 'doc-head-close.inc' %] @@ -63,7 +64,7 @@ function searchauthority() { [% ELSE %] [% END %] - [% resul.summary %] + [% PROCESS authresult summary=resul.summary %] Details [% UNLESS ( resul.isEDITORS ) %] 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' %] UNIMARC field 210c builder [% INCLUDE 'doc-head-close.inc' %] @@ -59,7 +60,7 @@ [% FOREACH resul IN result %] - [% resul.summary %] + [% PROCESS authresult summary=resul.summary %] [% resul.used %] times [% 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 bdb2dc9..4400647 100644 --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -2371,6 +2371,15 @@ span.sep { text-shadow: 1px 1px 0 #FFF; } +.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..92314b1 --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc @@ -0,0 +1,59 @@ +[% BLOCK showreference %] + [% IF marcflavour == 'UNIMARC' %] + [% SWITCH type %] + [% CASE 'broader' %] + [% heading %] -- + [% CASE 'narrower' %] + [% heading %] -- + [% CASE 'narrower' %] + [% heading %] -- + [% CASE 'seefrom' %] + [% heading %] -- + [% CASE 'seealso' %] + [% heading %] -- + [% END %] + [% ELSE %] + [% IF ( label ) %][% label %][% END %] + [% heading %] + [% UNLESS ( type=='seefrom' || type=='seealso' ) %][% 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 %][% END %] + [% END %] +[% END %] +[% BLOCK authresult %] + [% IF ( summary.summary ) %][% summary.summary %]:[% END %] + [% UNLESS ( summary.summaryonly ) %] + [% FOREACH authorize IN summary.authorized %] + [% authorize %] + [% END %] + [% IF ( marcflavour == 'UNIMARC' ) %] + [% FOREACH note IN summary.notes %] + [% note %] + [% 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 %] +
+ [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type %] +
+ [% END %] + [% END %] + [% IF ( summary.seealso ) %] + [% FOREACH seeals IN summary.seealso %] +
+ [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type %] +
+ [% END %] + [% END %] + [% END %] + [% END %] +[% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiesdetail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-MARCdetail.tt similarity index 92% rename from koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiesdetail.tt rename to koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-MARCdetail.tt index 287f6d1..8e87d71 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiesdetail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-MARCdetail.tt @@ -66,8 +66,10 @@ function showChildren(mynumber) {

[% Tag0X.tag %]

    [% FOREACH subfiel IN Tag0X.subfield %] -

    [% subfiel.marc_lib %]: [% subfiel.marc_value %]

    - [% END %] +

    [% subfiel.marc_lib %]: + [% IF subfiel.isurl %][% subfiel.marc_value %] + [% ELSE %][% subfiel.marc_value %][% END %]

    + [% END %]
[% END %] 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 › [% IF ( total ) %]Authority search result[% ELSE %]No results found[% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -52,11 +53,8 @@ [% ELSE %] [% END %] - [% resul.summary %] - - - [% authtypetext %] - + [% PROCESS authresult summary=resul.summary %] + [% authtypetext %] [% UNLESS ( resul.isEDITORS ) %] [% resul.used %] biblios 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} = - "$subf[$i][1]"; - } - 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