[Koha-cvs] koha/authorities authorities.pl [rel_2_2]

paul poulain paul at koha-fr.org
Thu Aug 10 13:41:46 CEST 2006


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch:		rel_2_2
Changes by:	paul poulain <tipaul>	06/08/10 11:41:46

Modified files:
	authorities    : authorities.pl 

Log message:
	fix for #1128 (repeated field problem)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/authorities.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.8.2.10&r2=1.8.2.11

Patches:
Index: authorities.pl
===================================================================
RCS file: /cvsroot/koha/koha/authorities/authorities.pl,v
retrieving revision 1.8.2.10
retrieving revision 1.8.2.11
diff -u -b -r1.8.2.10 -r1.8.2.11
--- authorities.pl	20 Jun 2006 16:21:42 -0000	1.8.2.10
+++ authorities.pl	10 Aug 2006 11:41:45 -0000	1.8.2.11
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: authorities.pl,v 1.8.2.10 2006/06/20 16:21:42 oleonard Exp $
+# $Id: authorities.pl,v 1.8.2.11 2006/08/10 11:41:45 tipaul Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -201,7 +201,7 @@
 					next if (length $subfield !=1);
 					next if ($tagslib->{$tag}->{$subfield}->{tab} eq -1);
 					next if ($tag<10);
-					next if (defined($record->field($tag)->subfield($subfield)));
+					next if (defined($field->subfield($subfield)));
 					push(@subfields_data, &create_input($tag,$subfield,'',$i,$record,$authorised_values_sth));
 					$i++;
 				}
@@ -329,8 +329,18 @@
 	# build indicator hash.
 	my @ind_tag = $input->param('ind_tag');
 	my @indicator = $input->param('indicator');
+	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 = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
+	} else {
 	my $xml = AUTHhtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
-        my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
+		$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
+	}
+	warn "REC : ".$record->as_formatted;
         # 
 # MARC::Record built => now, record in DB
 	# check for a duplicate
@@ -358,16 +368,25 @@
 #------------------------------------------------------------------------------------------------------------------------------
 } elsif ($op eq "addfield") {
 #------------------------------------------------------------------------------------------------------------------------------
-	my $addedfield = $input->param('addfield_field');
+	my $addedfield = substr('000'.$input->param('addfield_field'),-3);
 	my @tags = $input->param('tag');
 	my @subfields = $input->param('subfield');
 	my @values = $input->param('field_value');
 	# build indicator hash.
 	my @ind_tag = $input->param('ind_tag');
 	my @indicator = $input->param('indicator');
+	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 = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
+	} else {
 	my $xml = AUTHhtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
-        my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
-        # 
+		$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
+	}
+	warn "REC : ".$record->as_formatted;
 	my $field = MARC::Field->new("$addedfield",'','','a'=> "");
 	$record->append_fields($field);
 





More information about the Koha-cvs mailing list