From 1978babc9faf51d2764829523537e9cdda0ef92d Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 23 Jan 2008 15:04:23 -0600 Subject: [PATCH] Bug Fixing : Encoding in Z3950 searches encoding is now defaulted to MARC8 encoding is now supported for USMARC and UNIMARC flavours. Adding Encoding field to updatedatabase.pl Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Koha.pm | 19 ++++++++++++------- cataloguing/z3950_search.pl | 2 +- installer/data/mysql/updatedatabase.pl | 9 +++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 4239fa6cba..3697f4adb0 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -765,6 +765,7 @@ sub displayServers { value => $data->{host} . ":" . $data->{port} . "/" . $data->{database}, + encoding => ($data->{encoding}?$data->{encoding}:"iso-5426"), checked => "checked", icon => $data->{icon}, zed => $data->{type} eq 'zed', @@ -915,7 +916,7 @@ sub FixEncoding { my $marc=shift; my $encoding=shift; my $record = MARC::Record->new_from_usmarc($marc); - if (C4::Context->preference("marcflavour") eq "UNIMARC"){ +# if (C4::Context->preference("marcflavour") eq "UNIMARC"){ my $targetcharset="utf8"; if ($encoding && $targetcharset ne $encoding){ my $newRecord=MARC::Record->new(); @@ -931,9 +932,11 @@ sub FixEncoding { my $createdfield=0; foreach my $subfield ($field->subfields()){ if ($createdfield){ - if (($newField->tag eq '100')) { + if ((C4::Context->preference("marcflavour") eq "UNIMARC") && ($newField->tag eq '100')) { substr($subfield->[1],26,4,"5050") if ($targetcharset eq "utf8"); - } + } elsif (C4::Context->preference("marcflavour") eq "USMARC"){ + $newRecord->encoding("UTF-8"); + } map {$decoder->convert($_)} @$subfield; $newField->add_subfields($subfield->[0]=>$subfield->[1]); } else { @@ -956,9 +959,11 @@ sub FixEncoding { # my $utf8=eval{MARC::Charset::marc8_to_utf8($subfield->[1])}; # if ($@) {warn "z3950 character conversion error $@ ";$utf8=$subfield->[1]}; my $utf8=char_decode5426($subfield->[1]); - if (($field->tag eq '100')) { + if ((C4::Context->preference("marcflavour") eq "UNIMARC") && ($field->tag eq '100')) { substr($utf8,26,4,"5050"); - } + } elsif (C4::Context->preference("marcflavour") eq "USMARC"){ + $newRecord->encoding("UTF-8"); + } if ($createdfield){ $newField->add_subfields($subfield->[0]=>$utf8); } else { @@ -974,8 +979,8 @@ sub FixEncoding { return $newRecord; } return $record; - } - return $record; +# } +# return $record; } diff --git a/cataloguing/z3950_search.pl b/cataloguing/z3950_search.pl index 7c4e1462a0..3346f607b8 100755 --- a/cataloguing/z3950_search.pl +++ b/cataloguing/z3950_search.pl @@ -147,7 +147,7 @@ else { || $DEBUG && warn( "" . $oConnection[$s]->errmsg() ); $serverhost[$s] = $server->{host}; - $encoding[$s] = $server->{encoding}; + $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); $s++; } ## while fetch } # foreach diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 9cab61b582..13eb7c35cb 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -960,6 +960,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.049"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE z3950servers + ADD `encoding` text default NULL, + "); + print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n"; + SetVersion ($DBversion); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table -- 2.39.5