Bugzilla – Attachment 38293 Details for
Bug 10985
Unimarc: Authority summary does not work as expected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 10985: [UNIMARC] Fix authority summary
PASSED-QA-Bug-10985-UNIMARC-Fix-authority-summary.patch (text/plain), 9.92 KB, created by
Katrin Fischer
on 2015-04-21 21:30:36 UTC
(
hide
)
Description:
[PASSED QA] Bug 10985: [UNIMARC] Fix authority summary
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2015-04-21 21:30:36 UTC
Size:
9.92 KB
patch
obsolete
>From fc9beb952417fd1a9d3682255849b91c55b49ca7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 2 Oct 2013 14:16:09 +0200 >Subject: [PATCH] [PASSED QA] Bug 10985: [UNIMARC] Fix authority summary > >The problem is the template in authority type summary is not respected >at all. It is only read to see which fields and subfields should appear >in the summary. >This patch fixes that. >It also fixes a bug in auth_finder.pl plugin when summary contains >fields other than 2XX. > >Test plan: >0/ You must use a UNIMARC setup for those tests >1/ edit an authority type summary with: > NP : [200a][, 200b][ 200d][-- 152b --][ ; 200c][ (200f)] [001*] [ppn: 009*] >2/ create a new authority with previous fields (it is possible some > fields don't exist). >3/ search this authority and verify the summary is someting like: > NP : Name, D.-- NP -- 23849 ppn: my_ppn >4/ Verify some summary for existing authorities and check they are > correct. >5/ Edit a biblio record and use the plugin auth_finder.pl (for example > in a 7XX field) >6/ Do a search and verify the summary is correct >7/ Click on 'choose' or one of the numbered links ('1', '2', ... ; you >should have multiple 2XX fields for the numbered links to show up) >8/ Verify that the biblio field is correctly filled. > >/!\ For the ppn, it should be defined in the zebra indexes. > >In MARC21 and NORMARC setups, this patch should change nothing, please >verify that too (you can check that the auth_finder.pl plugin is still >working and the auth type summary is correctly displayed in authorities >search and auth_finder.pl plugin). > >Signed-off-by: Frederic Demians <f.demians@tamil.fr> > >It works as described, both in authority search result page, and in authority >data entry plugin. > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/AuthoritiesMarc.pm | 56 ++++++++++++---------- > .../en/includes/authorities-search-results.inc | 13 +++-- > .../modules/authorities/searchresultlist-auth.tt | 6 +-- > .../en/includes/authorities-search-results.inc | 13 +++-- > t/db_dependent/AuthoritiesMarc.t | 8 ++-- > 5 files changed, 49 insertions(+), 47 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 4860eba..03b0b51 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -908,6 +908,8 @@ sub BuildSummary { > # for MARC21, the authority type summary displays a label meant for > # display > if (C4::Context->preference('marcflavour') ne 'UNIMARC') { >+ $summary{label} = $authref->{summary}; >+ } else { > $summary{summary} = $authref->{summary}; > } > } >@@ -942,35 +944,37 @@ sub BuildSummary { > # suit the MARC21 version, so for now the "templating" > # feature will be enabled only for UNIMARC for backwards > # compatibility. >- if ($summary_template and C4::Context->preference('marcflavour') eq 'UNIMARC') { >- my @fields = $record->fields(); >-# $reported_tag = '$9'.$result[$counter]; >- my @repets; >- foreach my $field (@fields) { >- my $tag = $field->tag(); >- my $tagvalue = $field->as_string(); >- my $localsummary= $summary_template; >- $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; >+ if ($summary{summary} and C4::Context->preference('marcflavour') eq 'UNIMARC') { >+ my @matches = ($summary{summary} =~ m/\[(.*?)(\d{3})([\*a-z0-9])(.*?)\]/g); >+ my (@textbefore, @tag, @subtag, @textafter); >+ for(my $i = 0; $i < scalar @matches; $i++){ >+ push @textbefore, $matches[$i] if($i%4 == 0); >+ push @tag, $matches[$i] if($i%4 == 1); >+ push @subtag, $matches[$i] if($i%4 == 2); >+ push @textafter, $matches[$i] if($i%4 == 3); >+ } >+ for(my $i = scalar @tag; $i >= 0; $i--){ >+ my $textbefore = $textbefore[$i] || ''; >+ my $tag = $tag[$i] || ''; >+ my $subtag = $subtag[$i] || ''; >+ my $textafter = $textafter[$i] || ''; >+ my $value = ''; >+ my $field = $record->field($tag); >+ if ( $field ) { >+ if($subtag eq '*') { >+ if($tag < 10) { >+ $value = $textbefore . $field->data() . $textafter; >+ } >+ } else { >+ my @subfields = $field->subfield($subtag); >+ if(@subfields > 0) { >+ $value = $textbefore . join (" - ", @subfields) . $textafter; >+ } > } > } >- if ($localsummary ne $summary_template) { >- $localsummary =~ s/\[(.*?)\]//g; >- $localsummary =~ s/\n/<br>/g; >- push @repets, $localsummary; >- } >+ $summary{summary} =~ s/\[\Q$textbefore$tag$subtag$textafter\E\]/$value/; > } >- $summary{repets} = \@repets; >+ $summary{summary} =~ s/\\n/<br \/>/g; > } > my @authorized; > my @notes; >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 >index ceff1a4..a009c7d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc >@@ -50,13 +50,12 @@ > [% END %] > [% END %] > [% BLOCK authresult %] >- [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %] >- <div class="authres_repet"> >- [% FOREACH repet IN summary.repets %] >- <span>[% repet | html %]</span> >- [% UNLESS loop.last %] | [% END %] >- [% END %] >- </div> >+ [% IF ( summary.label ) %][% summary.label | html %]:[% END %] >+ [% IF summary.summary %] >+ <div class="authority-summary"> >+ [% summary.summary %] >+ </div> >+ [% END %] > [% UNLESS ( summary.summaryonly ) %] > <div class="authorizedheading"> > [% FOREACH authorize IN summary.authorized %] >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 898de87..fd2e92b 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 >@@ -73,9 +73,9 @@ function doauth(authid, index, repet) > <td>[% PROCESS authresult summary=resul.summary %]</td> > <td>[% resul.used %] times</td> > <td> >- [% IF resul.summary && resul.summary.repets && resul.summary.repets.size > 1 %] >- [% FOREACH repet IN resul.summary.repets %] >- <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '[% loop.count %]')" title="[% repet | html %]">[% loop.count %]</a> >+ [% IF resul.summary && resul.summary.authorized && resul.summary.authorized.size > 1 %] >+ [% FOREACH authorized IN resul.summary.authorized %] >+ <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '[% loop.count %]')" title="[% authorized.heading | html %]">[% loop.count %]</a> > [% END %] > [% ELSE %] > <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '')">choose</a> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc >index c378817..043556d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc >@@ -50,13 +50,12 @@ > [% END # / BLOCK showreference %] > > [% BLOCK authresult %] >- [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %] >- <div class="authres_repet"> >- [% FOREACH repet IN summary.repets %] >- <span>[% repet | html %]</span> >- [% UNLESS loop.last %] | [% END %] >- [% END %] >- </div> >+ [% IF ( summary.label ) %][% summary.label | html %]:[% END %] >+ [% IF summary.summary %] >+ <div class="authority-summary"> >+ [% summary.summary %] >+ </div> >+ [% END %] > [% UNLESS ( summary.summaryonly ) %] > <div class="authorizedheading"> > [% FOREACH authorize IN summary.authorized %] >diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t >index bc4adeb..f432a5d 100755 >--- a/t/db_dependent/AuthoritiesMarc.t >+++ b/t/db_dependent/AuthoritiesMarc.t >@@ -61,6 +61,8 @@ my $dbh = C4::Context->dbh; > $dbh->{AutoCommit} = 0; > $dbh->{RaiseError} = 1; > >+t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); >+ > is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string"); > > my $expectedhierarchy = [ [ { >@@ -135,7 +137,7 @@ my $expected_marc21_summary = { > } > ], > 'seefrom' => [], >- 'summary' => 'Geographic Name', >+ 'label' => 'Geographic Name', > 'type' => 'Geographic Name' > }; > is_deeply( >@@ -178,9 +180,7 @@ my $expected_unimarc_name_summary = { > 'otherscript' => [], > 'seealso' => [], > 'seefrom' => [], >- 'repets' => [ >- 'Fossey, Brigitte' >- ], >+ 'summary' => 'Fossey, Brigitte', > 'type' => 'Auteur' > }; > >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10985
:
21714
|
36809
|
37599
| 38293