[Koha-cvs] koha/acqui.simple addbiblio.pl [dev_week]
Ryan Higgins
rch at liblime.com
Sat Dec 9 00:07:23 CET 2006
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Ryan Higgins <rych> 06/12/08 23:07:23
Modified files:
acqui.simple : addbiblio.pl
Log message:
sync with rel_2_2
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/acqui.simple/addbiblio.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.52.2.40.2.13&r2=1.52.2.40.2.14
Patches:
Index: addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/acqui.simple/Attic/addbiblio.pl,v
retrieving revision 1.52.2.40.2.13
retrieving revision 1.52.2.40.2.14
diff -u -b -r1.52.2.40.2.13 -r1.52.2.40.2.14
--- addbiblio.pl 9 Oct 2006 15:15:19 -0000 1.52.2.40.2.13
+++ addbiblio.pl 8 Dec 2006 23:07:23 -0000 1.52.2.40.2.14
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: addbiblio.pl,v 1.52.2.40.2.13 2006/10/09 15:15:19 kados Exp $
+# $Id: addbiblio.pl,v 1.52.2.40.2.14 2006/12/08 23:07:23 rych Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -94,26 +94,7 @@
$sth->execute($id);
my ($file,$marc,$encoding) = $sth->fetchrow;
if ($marc) {
- my $record = MARC::Record->new_from_usmarc($marc);
- #my $record = MARC::File::USMARC::decode($marc);
-
- my @warnings = $record->warnings();
- 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'));
-
+ my $record = fixEncoding($marc);
if (ref($record) eq undef) {
return -1;
} else {
@@ -123,7 +104,7 @@
my $auth_fields = C4::Context->preference("z3950AuthorAuthFields");
my @auth_fields= split /,/,$auth_fields;
my $field;
- warn $record->as_formatted;
+ #warn $record->as_formatted;
if ($record->field($tag)){
foreach my $tmpfield ($record->field($tag)->subfields){
# foreach my $subfieldcode ($tmpfield->subfields){
@@ -135,7 +116,7 @@
$field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if ($subfieldcode ne $subfield);
}
}
-# warn $field->as_formatted;
+ #warn $field->as_formatted;
# }
}
$record->delete_field($record->field($tag));
@@ -155,6 +136,7 @@
}
$record->insert_fields_ordered($field);
}
+# warn $record->as_formatted."";
return $record,$encoding;
}
}
@@ -244,7 +226,7 @@
$subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth);
# it's a thesaurus / authority field
} elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
- $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=\"67\" maxlength=\"255\" disabled=\"disabled\" readonly=\"readonly\" \/> <a href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
+ $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=\"67\" maxlength=\"255\" DISABLE READONLY> <a href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
# it's a plugin field
} elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
# opening plugin. Just check wether we are on a developper computer on a production one
@@ -495,6 +477,7 @@
my $record=-1;
my $encoding="";
$record = MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
+#warn "REC : ".$record->as_formatted;
($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
$is_a_modif=0;
@@ -521,7 +504,12 @@
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
- $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ my %indicators;
+ for (my $i=0;$i<=$#ind_tag;$i++) {
+ $indicators{$ind_tag[$i]} = $indicator[$i];
+ }
+ $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
+# warn "RECORD : ".$record->as_formatted;
} else {
my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
@@ -569,6 +557,8 @@
} elsif ($op eq "addfield") {
#------------------------------------------------------------------------------------------------------------------------------
my $addedfield = $input->param('addfield_field');
+ my $cntrepeatfield=$input->param('repeat_field');
+ $cntrepeatfield=1 unless ($cntrepeatfield);
my $tagaddfield_subfield = $input->param('addfield_subfield');
my @tags = $input->param('tag');
my @subfields = $input->param('subfield');
@@ -577,10 +567,22 @@
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
- my $record=MARC::Record->new_from_xml($xml, 'UTF-8'); #C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
- # adding an empty field
- my $field = MARC::Field->new("$addedfield",'','','$tagaddfield_subfield' => "");
+ my $record;
+ if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
+ my %indicators;
+ for (my $i=0;$i<=$#ind_tag;$i++) {
+ $indicators{$ind_tag[$i]} = $indicator[$i];
+ }
+ $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
+ } else {
+ my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
+ $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
+ }
+ for (my $i=1;$i<=$cntrepeatfield;$i++){
+ my $field = MARC::Field->new("$addedfield",'','',"$tagaddfield_subfield" => "");
$record->append_fields($field);
+ }
+ #warn "result : ".$record->as_formatted;
build_tabs ($template, $record, $dbh,$encoding);
build_hidden_data;
$template->param(
More information about the Koha-cvs
mailing list