From 26c87757b4a461f64e7b9df5905c54023273bea2 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 25 Oct 2004 13:28:22 +0000 Subject: [PATCH] rewritting ISBD (doc coming soon...) --- ISBDdetail.pl | 69 +++++++++++++++---- .../default/en/catalogue/ISBDdetail.tmpl | 2 +- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/ISBDdetail.pl b/ISBDdetail.pl index 086f70c935..1ec5eab034 100755 --- a/ISBDdetail.pl +++ b/ISBDdetail.pl @@ -71,23 +71,62 @@ my ($template, $loggedinuser, $cookie) }); my $ISBD = C4::Context->preference('ISBD'); -my @fields = $record->fields(); -foreach my $field (@fields) { - my $tag = $field->tag(); - if ($tag<10) { - } else { - my @subf = $field->subfields; - for my $i (0..$#subf) { - my $subfieldcode = $subf[$i][0]; - my $subfieldvalue = $subf[$i][1]; - my $tagsubf = $tag.$subfieldcode; - $ISBD =~ s/\[(.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue\[$1$tagsubf$2]$2$3/g; +# my @blocs = split /\@/,$ISBD; +# my @fields = $record->fields(); +my $res; +# foreach my $bloc (@blocs) { +# $bloc =~ s/\n//g; + my $bloc = $ISBD; + my $blocres; + foreach my $isbdfield (split /#/,$bloc) { + warn "ISBDFIELD : $isbdfield"; +# $isbdfield= /(.?.?.?)/; + $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/; + my $fieldvalue=$1; + my $textbefore=$2; + my $analysestring=$3; + my $textafter=$4; +# warn "==> $1 / $2 / $3 / $4"; +# my $fieldvalue=substr($isbdfield,0,3); + if ($fieldvalue>0) { + # 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) { + } else { + my @subf = $field->subfields; + for my $i (0..$#subf) { + my $subfieldcode = $subf[$i][0]; + my $subfieldvalue = $subf[$i][1]; + my $tagsubf = $tag.$subfieldcode; + $calculated =~ s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$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; + } + } + $blocres .=$textafter if $hasputtextbefore; + } else { + $blocres.=$isbdfield; } } -} -$ISBD =~ s/\[(.*?)]//g; -$ISBD =~ s/\n/
/g; -$template->param(ISBD => $ISBD, + $res.=$blocres; +# } +$res =~ s/\{(.*?)\}//g; +$res =~ s/\\n/\n/g; +$res =~ s/\n//g; +# remove empty () +$res =~ s/\(\)//g; +$template->param(ISBD => $res, biblionumber => $biblionumber); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl b/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl index bd0def5a6a..88ba4965b8 100644 --- a/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/catalogue/ISBDdetail.tmpl @@ -23,7 +23,7 @@

ISBD

-

ISBD :

+