From 6645791b3e0aebd2e198f87a518a155407abb38a Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Thu, 18 Oct 2007 18:42:14 -0500 Subject: [PATCH] Ordering items on holdingbranch for ISBD. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- catalogue/ISBDdetail.pl | 12 ++++++--- opac/opac-ISBDdetail.pl | 58 ++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl index d47a7b0fa1..068408d476 100755 --- a/catalogue/ISBDdetail.pl +++ b/catalogue/ISBDdetail.pl @@ -111,6 +111,10 @@ my $res; # $bloc =~ s/\n//g; my $bloc = $ISBD; my $blocres; + +my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$itemtype); +# @big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array; + foreach my $isbdfield ( split /#/, $bloc ) { # $isbdfield= /(.?.?.?)/; @@ -127,7 +131,9 @@ foreach my $isbdfield ( split /#/, $bloc ) { # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue; # warn "FV : $fieldvalue"; my $hasputtextbefore = 0; - foreach my $field ( $record->field($fieldvalue) ) { + my @fieldslist = $record->field($fieldvalue); + @fieldslist= sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf); + foreach my $field ( @fieldslist ) { my $calculated = $analysestring; my $tag = $field->tag(); if ( $tag < 10 ) { @@ -140,10 +146,8 @@ foreach my $isbdfield ( split /#/, $bloc ) { get_authorised_value_desc( $itemtype,$tagslib, $tag, $subf[$i][0], $subf[$i][1], '', $dbh ); my $tagsubf = $tag . $subfieldcode; - $calculated =~ -s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; + $calculated =~s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; } - # field builded, store the result if ( $calculated && !$hasputtextbefore ) { # put textbefore if not done diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index fbe7950d12..c052d5a942 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -107,6 +107,8 @@ my $res; # $bloc =~ s/\n//g; my $bloc = $ISBD; my $blocres; +my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$itemtype); + foreach my $isbdfield ( split /#/, $bloc ) { # $isbdfield= /(.?.?.?)/; @@ -119,38 +121,40 @@ foreach my $isbdfield ( split /#/, $bloc ) { # warn "==> $1 / $2 / $3 / $4"; # my $fieldvalue=substr($isbdfield,0,3); if ( $fieldvalue > 0 ) { + my $hasputtextbefore = 0; + my @fieldslist = $record->field($fieldvalue); + @fieldslist = sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf); # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue; # warn "FV : $fieldvalue"; - my $hasputtextbefore = 0; - foreach my $field ( $record->field($fieldvalue) ) { - my $calculated = $analysestring; - my $tag = $field->tag(); - if ( $tag < 10 ) { + foreach my $field ( @fieldslist ) { + my $calculated = $analysestring; + my $tag = $field->tag(); + if ( $tag < 10 ) { + } + else { + my @subf = $field->subfields; + for my $i ( 0 .. $#subf ) { + my $subfieldcode = $subf[$i][0]; + my $subfieldvalue = + GetAuthorisedValueDesc( $tag, $subf[$i][0], + $subf[$i][1], '', $tagslib ); + my $tagsubf = $tag . $subfieldcode; + $calculated =~ + s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; } - else { - my @subf = $field->subfields; - for my $i ( 0 .. $#subf ) { - my $subfieldcode = $subf[$i][0]; - my $subfieldvalue = - GetAuthorisedValueDesc( $tag, $subf[$i][0], - $subf[$i][1], '', $tagslib ); - my $tagsubf = $tag . $subfieldcode; - $calculated =~ -s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; - } - - # field builded, store the result - if ( $calculated && !$hasputtextbefore ) - { # put textbefore if not done - $blocres .= $textbefore; - $hasputtextbefore = 1; - } - - # remove punctuation at start - $calculated =~ s/^( |;|:|\.|-)*//g; - $blocres .= $calculated; + + # field builded, store the result + if ( $calculated && !$hasputtextbefore ) + { # put textbefore if not done + $blocres .= $textbefore; + $hasputtextbefore = 1; } + + # remove punctuation at start + $calculated =~ s/^( |;|:|\.|-)*//g; + $blocres .= $calculated; + } } $blocres .= $textafter if $hasputtextbefore; } -- 2.39.5