From 90e197d6a4f02b0700c8e53b4298bf588f886691 Mon Sep 17 00:00:00 2001 From: charles Date: Mon, 20 Apr 2015 17:24:29 -0400 Subject: [PATCH] Bug 12747 - Add extra column in Z3950 search result This patch uses the standard field syntax (ex: 023$ab), allows writing fields without mentionning subfields and uses whitespace as a field separator instead of semicolon. sponsored by the CCSR ( http://www.ccsr.qc.ca ) --- C4/Breeding.pm | 56 ++++++++++++++++++++++ .../en/modules/admin/preferences/cataloguing.pref | 4 ++ 2 files changed, 60 insertions(+) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index 252d03b..2de5cc7 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -25,6 +25,7 @@ use C4::Biblio; use C4::Koha; use C4::Charset; use MARC::File::USMARC; +use MARC::Field; use C4::ImportBatch; use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority use C4::Languages; @@ -222,6 +223,23 @@ sub Z3950Search { $oConnection[$_]->destroy(); } +<<<<<<< HEAD +======= + my @servers = (); + foreach my $id (@id) { + push @servers, {id => $id}; + } + + my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch'); + $pref_addnumber =~ s/^\s+|\s+$//g; + $pref_addnumber =~ s/\h+/ /g; + if ($pref_addnumber){ + $template->param( + additionalFields => '1', + ); + } + +>>>>>>> c4c12ed... Bug 12747 - Add extra column in Z3950 search result $template->param( breeding_loop => \@breeding_loop, servers => \@servers, @@ -340,6 +358,44 @@ sub _add_rowdata { } $row->{date}//= $row->{date2}; $row->{isbn}=_isbn_replace($row->{isbn}); + + my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch'); + $pref_addnumber =~ s/^\s+|\s+$//g; + $pref_addnumber =~ s/\h+/ /g; + my @addnumber_array = split / /, $pref_addnumber; + my @addnumberfields; + foreach (@addnumber_array) { + my $length = length($_); + my $adTag = substr($_, 0, 3); + if ($record->field($adTag)) { + my $field = $record->field($adTag); + my $fieldContent=''; + if ($length > 3){ + my $adSubfield; + for (my $i=0; $i<$length-4; $i++){ # 4 because 3 digits, 1 dollar sign ($) + $adSubfield = substr($_, 4+$i, 1); + $fieldContent = $fieldContent.$field->subfield($adSubfield).' '; + } + push(@addnumberfields, $_); + $row->{$_} = $fieldContent; + } + else { + if($adTag <= 10){ + my $data = $field->data(); + push(@addnumberfields, $_); + $row->{$_} = $data; + } + else { + my $subfields_text = $field->as_string(); + push(@addnumberfields, $_); + $row->{$_} = $subfields_text; + } + } + } + } + + $row->{'addnumberfields'} = \@addnumberfields; + return $row; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index bc35aad..c200c2b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -215,3 +215,7 @@ Cataloging: yes: "do" no: "don't" - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records. Note that this preference has no effect if UseQueryParser is on. + - + - Determines the MARC field/subfields + - pref: AdditionalFieldsInZ3950ResultSearch + - "are displayed in 'Additional fields' column in the result of a search Z3950 (use whitespace as delimiter ex: 082$ab 090$ab)" -- 1.9.1