[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha C4/Breeding.pm C4/Koha.pm cataloguing/addb... [rel_3_0]
From: |
paul poulain |
Subject: |
[Koha-cvs] koha C4/Breeding.pm C4/Koha.pm cataloguing/addb... [rel_3_0] |
Date: |
Tue, 09 Jan 2007 08:35:05 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: paul poulain <tipaul> 07/01/09 08:35:04
Modified files:
C4 : Breeding.pm Koha.pm
cataloguing : addbiblio.pl
koha-tmpl/intranet-tmpl/prog/en/cataloguing: addbiblio.tmpl
Log message:
Reservoir fixes :
- search the marc_breeding table correctly
- fixes encoding where/if needed
- don't loose frameworkcode when retrieving z3950 server data
SANOP : synch this commit & z3950 search should work like a charm. And
it's even better if you add 2 indexes : 1 on biblioitems.isbn & 1 on
biblioitems.issn. Otherwise, it can be very very long...
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Breeding.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.9&r2=1.9.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Koha.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.40.2.31&r2=1.40.2.32
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.14.2.20&r2=1.14.2.21
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.16&r2=1.1.2.17
Patches:
Index: C4/Breeding.pm
===================================================================
RCS file: /sources/koha/koha/C4/Breeding.pm,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -b -r1.9 -r1.9.2.1
--- C4/Breeding.pm 30 Sep 2005 18:58:25 -0000 1.9
+++ C4/Breeding.pm 9 Jan 2007 08:35:04 -0000 1.9.2.1
@@ -19,6 +19,7 @@
use strict;
use C4::Biblio;
+use C4::Koha;
use MARC::File::USMARC;
require Exporter;
@@ -47,7 +48,10 @@
=head1 DESCRIPTION
-This module doesn't do anything.
+ ImportBreeding import MARC records in the reservoir (marc_breeding table).
+ the records can be properly encoded or not, we try to reencode them in
utf-8 if needed.
+ works perfectly with BNF server, that sends UNIMARC latin1 records. Should
work with other servers too.
+ the FixEncoding sub is in Koha.pm, as it's a general usage sub.
=cut
@@ -70,8 +74,9 @@
my $alreadyindb = 0;
my $alreadyinfarm = 0;
my $notmarcrecord = 0;
+ my $breedingid;
for (my $i=0;$i<=$#marcarray;$i++) {
- my $marcrecord =
MARC::File::USMARC::decode($marcarray[$i]."\x1D");
+ my $marcrecord = FixEncoding($marcarray[$i]."\x1D");
my @warnings = $marcrecord->warnings();
if (scalar($marcrecord->fields()) == 0) {
$notmarcrecord++;
@@ -100,7 +105,7 @@
$alreadyindb++;
} else {
# search in breeding farm
- my $breedingid;
+# my $breedingid;
if ($oldbiblio->{isbn}) {
$searchbreeding->execute($oldbiblio->{isbn},$oldbiblio->{title});
($breedingid) =
$searchbreeding->fetchrow;
@@ -117,19 +122,20 @@
$replacesql
->execute($filename,substr($oldbiblio->{isbn}.$oldbiblio->{issn},0,10),$oldbiblio->{title},$oldbiblio->{author},$recoded,$encoding,$z3950random,$breedingid);
} else {
$insertsql
->execute($filename,substr($oldbiblio->{isbn}.$oldbiblio->{issn},0,10),$oldbiblio->{title},$oldbiblio->{author},$recoded,$encoding,$z3950random);
+ $breedingid=$dbh->{'mysql_insertid'};
}
$imported++;
}
}
}
}
- return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported);
+ return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid);
}
=item BreedingSearch
- ($count, @results) = &BreedingSearch($title,$isbn,$random);
+($count, @results) = &BreedingSearch($title,$isbn,$random);
C<$title> contains the title,
C<$isbn> contains isbn or issn,
C<$random> contains the random seed from a z3950 search.
Index: C4/Koha.pm
===================================================================
RCS file: /sources/koha/koha/C4/Koha.pm,v
retrieving revision 1.40.2.31
retrieving revision 1.40.2.32
diff -u -b -r1.40.2.31 -r1.40.2.32
--- C4/Koha.pm 9 Jan 2007 08:32:30 -0000 1.40.2.31
+++ C4/Koha.pm 9 Jan 2007 08:35:04 -0000 1.40.2.32
@@ -17,7 +17,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: Koha.pm,v 1.40.2.31 2007/01/09 08:32:30 toins Exp $
+# $Id: Koha.pm,v 1.40.2.32 2007/01/09 08:35:04 tipaul Exp $
use strict;
require Exporter;
@@ -25,7 +25,7 @@
use C4::Output;
use vars qw($VERSION @ISA @EXPORT);
-$VERSION = do { my @v = '$Revision: 1.40.2.31 $' =~ /\d+/g; shift(@v) . "." .
join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.40.2.32 $' =~ /\d+/g; shift(@v) . "." .
join( "_", map { sprintf "%03d", $_ } @v ); };
=head1 NAME
@@ -77,6 +77,7 @@
&getitemtypeimagedir
&getitemtypeimagesrc
&GetAuthorisedValues
+ &FixEncoding
&GetKohaAuthorisedValues
$DEBUG
);
@@ -1512,6 +1513,56 @@
return address@hidden;
}
+=item fixEncoding
+
+ $marcrecord = &fixEncoding($marcblob);
+
+Returns a well encoded marcrecord.
+
+=cut
+sub FixEncoding {
+ my $marc=shift;
+ my $record = MARC::Record->new_from_usmarc($marc);
+ if (C4::Context->preference("MARCFLAVOUR") eq "UNIMARC"){
+ use Encode::Guess;
+ my $targetcharset="utf8" if (C4::Context->preference("TemplateEncoding")
eq "utf-8");
+ $targetcharset="latin1" if (C4::Context->preference("TemplateEncoding") eq
"iso-8859-1");
+ my $decoder = guess_encoding($marc, qw/utf8 latin1/);
+# die $decoder unless ref($decoder);
+ if (ref($decoder)) {
+ my $newRecord=MARC::Record->new();
+ foreach my $field ($record->fields()){
+ if ($field->tag()<'010'){
+ $newRecord->insert_grouped_field($field);
+ } else {
+ my $newField;
+ my $createdfield=0;
+ foreach my $subfield ($field->subfields()){
+ if ($createdfield){
+ if (($newField->tag eq '100')) {
+ substr($subfield->[1],26,2,"0103") if ($targetcharset eq
"latin1");
+ substr($subfield->[1],26,4,"5050") if ($targetcharset eq
"utf8");
+ }
+ map
{C4::Biblio::char_decode($_,"UNIMARC");Encode::from_to($_,$decoder->name,$targetcharset);$_=~tr#\r##}
@$subfield;
+ $newField->add_subfields($subfield->[0]=>$subfield->[1]);
+ } else {
+ map
{C4::Biblio::char_decode($_,"UNIMARC");Encode::from_to($_,$decoder->name,$targetcharset);$_=~tr#\r##}
@$subfield;
+
$newField=MARC::Field->new($field->tag(),$field->indicator(1),$field->indicator(2),$subfield->[0]=>$subfield->[1]);
+ $createdfield=1;
+ }
+ }
+ $newRecord->insert_grouped_field($newField);
+ }
+ }
+ # warn $newRecord->as_formatted();
+ return $newRecord;
+ } else {
+ return $record;
+ }
+ } else {
+ return $record;
+ }
+}
=head2 GetKohaAuthorisedValues
Takes $dbh , $kohafield as parameters.
Index: cataloguing/addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.14.2.20
retrieving revision 1.14.2.21
diff -u -b -r1.14.2.20 -r1.14.2.21
--- cataloguing/addbiblio.pl 8 Jan 2007 14:47:08 -0000 1.14.2.20
+++ cataloguing/addbiblio.pl 9 Jan 2007 08:35:04 -0000 1.14.2.21
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: addbiblio.pl,v 1.14.2.20 2007/01/08 14:47:08 tipaul Exp $
+# $Id: addbiblio.pl,v 1.14.2.21 2007/01/09 08:35:04 tipaul Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -99,19 +99,6 @@
foreach my $warning (@warnings) {
warn "WARNING".$warning;
}
-
- my $marcxml = $record->as_xml_record("UTF-8");
- #warn "MARCXML:".$marcxml;
- my $marcxml_entity_encoded;
- use Unicode::Normalize;
- foreach my $line (split(/\n/, $marcxml)) {
- my $nfc_string = NFC($line);
- $nfc_string
=~s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
- $marcxml_entity_encoded .= $nfc_string."\n";
- }
- #warn $marcxml_entity_encoded;
-
$record=MARC::Record->new_from_xml($marcxml_entity_encoded,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
-
if (ref($record) eq undef) {
return -1;
} else {
Index: koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl
===================================================================
RCS file:
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -u -b -r1.1.2.16 -r1.1.2.17
--- koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl 8 Jan 2007
14:47:09 -0000 1.1.2.16
+++ koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl 9 Jan 2007
08:35:04 -0000 1.1.2.17
@@ -296,7 +296,7 @@
}
}
if(error < 4){
- newin=window.open("z3950_search.pl?biblionumber=<!-- TMPL_VAR
NAME="biblionumber"
-->"+strQuery,"z3950search",'width=640,height=400,location=yes,toolbar=no,scrollbars=yes');
+ newin=window.open("z3950_search.pl?biblionumber=<!-- TMPL_VAR
NAME="biblionumber" -->&frameworkcode=<!-- TMPL_VAR NAME="frameworkcode"
-->"+strQuery,"z3950search",'width=640,height=400,location=yes,toolbar=no,scrollbars=yes');
} else {
alert("To perform a z39.50 search, you must enter at least one
of the following: \n\n ISBN\n ISSN\n Title\n Author\n");
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha C4/Breeding.pm C4/Koha.pm cataloguing/addb... [rel_3_0],
paul poulain <=