Summary: | ISBD parsing does not preserve subfield order | ||
---|---|---|---|
Product: | Koha | Reporter: | Chris Cormack <chris> |
Component: | MARC Bibliographic data support | Assignee: | Galen Charlton <gmcharlt> |
Status: | Failed QA --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | mtompset, paul.poulain, pongtawat |
Version: | Main | ||
Hardware: | PC | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Attachments: | Add option 'all' to ISBD template |
Description
Chris Cormack
2010-05-21 01:06:34 UTC
Just need to figure out the other half of that test case, and I'll be able to complete something. :) I don't remember what I was thinking, nor do I understand the problem. Resetting back to defaults. I don't think diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 10faa83..9a5a372 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -958,11 +958,11 @@ sub GetISBDView { if ( ( $template eq 'opac' ) && ( $tagslib->{$fieldvalue}->{$subfvalue}->{'hidden'} || 0 ) > 0 ); foreach my $field (@fieldslist) { + my $tag = $field->tag(); foreach my $subfield ( $field->subfield($subfvalue) ) { - my $calculated = $analysestring; - my $tag = $field->tag(); if ( $tag < 10 ) { } else { + my $calculated = $analysestring; my $subfieldvalue = GetAuthorisedValueDesc( $tag, $subfvalue, $subfield, '', $tagslib ); my $tagsubf = $tag . $subfvalue; $calculated =~ s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; @@ -988,7 +988,16 @@ sub GetISBDView { my $tag = $field->tag(); if ( $tag < 10 ) { } else { - my @subf = $field->subfields; + my @ordered_subfields; + while ($calculated =~ /(\d\d\d)([0-9a-zA-Z])/g) { + push @ordered_subfields,$2; + } + my @subf; + foreach my $subtag (@ordered_subfields) { + foreach my $subfield ($field->subfields) { + push @subf,[@{$subfield}] if $subfield->[0] eq $subtag; + } + } for my $i ( 0 .. $#subf ) { my $valuecode = $subf[$i][1]; my $subfieldcode = $subf[$i][0]; Was what people were wanting. I made a patch that add an option "all" to the field list that will show all subfields in order as they appeared in the record, separated by specified separator. Test 1. Add a MARC record with 650 with some subfields, says a z x a 2. Assume the ISBD preference define template for 650 as follows: #650|<br/><br/><label>Subjects--Topical Terms: </label>|{\n6503 }{\n650a}{ 650b }{ 650c }{ 650d }{ 650e }{--650x}{--650z}{--650y}{--650v}| 3. Go to ISBD tab, it will show: Subjects--Topical Terms: a--a--x--z 4. Apply patch 5. Go to ISBD tab, it will show the same result as in 3. 6. Change ISBD template for 650 to #650|<br/><br/><label>Subjects--Topical Terms: </label>|all--| 7. Go to ISBD tab, it will show: Subjects--Topical Terms: a--z--x--a Separator can be changed to something else, just put it after "all" (Patch tested on 16.11) Created attachment 60566 [details] [review] Add option 'all' to ISBD template This adds functionality to C4::Biblio. It requires tests. None were provided. |