[Koha-cvs] koha/C4 Biblio.pm [rel_2_2]

Joshua Ferraro jmf at kados.org
Wed Mar 8 17:31:04 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch: 	rel_2_2
Changes by:	Joshua Ferraro <kados at savannah.gnu.org>	06/03/08 16:31:04

Modified files:
	C4             : Biblio.pm 

Log message:
	bugfix for Biblio.pm based on feedback from production system. previous
	version was dropping subfields in cases where the previous tag in the
	editor contained values (but only when multiple subfields existed in
	both tags). This version will be tested again in production environment
	to ensure it is actually fixed.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Biblio.pm.diff?only_with_tag=rel_2_2&tr1=1.115.2.45&tr2=1.115.2.46&r1=text&r2=text

Patches:
Index: koha/C4/Biblio.pm
diff -u koha/C4/Biblio.pm:1.115.2.45 koha/C4/Biblio.pm:1.115.2.46
--- koha/C4/Biblio.pm:1.115.2.45	Wed Mar  8 10:49:36 2006
+++ koha/C4/Biblio.pm	Wed Mar  8 16:31:04 2006
@@ -1040,60 +1040,61 @@
 	my ($tags,$subfields,$values,$indicator,$ind_tag) = @_;        
 	use MARC::File::XML;
 	my $xml= MARC::File::XML::header();
-	my $prevvalue;
-	my $prevtag=-1;
-	my $first=1;
+    my $prevvalue;
+    my $prevtag=-1;
+    my $first=1;
 	my $j = -1;
-	for (my $i=0;$i<=@$tags;$i++){
+    for (my $i=0;$i<=@$tags;$i++){
 		if ((@$tags[$i] ne $prevtag)){
 			$j++ unless (@$tags[$i] eq "");
-			# deal with &, <, >,", ' that are not valid in a XML file.
-			@$values[$i] =~ s/&/&amp;/g;
-			@$values[$i] =~ s/</&lt;/g;
-			@$values[$i] =~ s/>/&gt;/g;
-			@$values[$i] =~ s/"/&quot;/g;
-			@$values[$i] =~ s/'/&apos;/g;
+			#warn "IND:".substr(@$indicator[$j],0,1).substr(@$indicator[$j],1,1)." ".@$tags[$i];
 			if (!$first){
-				$xml.="</datafield>\n";
-				$first=1;
+		    	$xml.="</datafield>\n";
+				if (@$tags[$i] > 10) {
+						my $ind1 = substr(@$indicator[$j],0,1);
+                        my $ind2 = substr(@$indicator[$j],1,1);
+                        $xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
+                        $xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
+                        $first=0;
+				} else {
+		    	$first=1;
 				}
-			else {
-				if (@$values[$i] ne "") {
-					# leader
-					if (@$tags[$i] eq "000") {
+            } else {
+		    	if (@$values[$i] ne "") {
+		    		# leader
+		    		if (@$tags[$i] eq "000") {
 						$xml.="<leader>@$values[$i]</leader>\n";
 						$first=1;
-						# rest of the fixed fields
-					} elsif (@$tags[$i] < 10) {
+					# rest of the fixed fields
+		    		} elsif (@$tags[$i] < 10) {
 						$xml.="<controlfield tag=\"@$tags[$i]\">@$values[$i]</controlfield>\n";
 						$first=1;
-					}
-					else {
+		    		} else {
 						my $ind1 = substr(@$indicator[$j],0,1);
 						my $ind2 = substr(@$indicator[$j],1,1);
 						$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
 						$xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
 						$first=0;			
-					}
-				}
-			}
-		} else {
-			if (@$values[$i] eq "") {
+		    		}
+		    	}
 			}
-			else {
-				if ($first){
-					my $ind1 = substr(@$indicator[$j],0,1);                        
-					my $ind2 = substr(@$indicator[$j],1,1);
-					$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
-					$first=0;
+		} else { # @$tags[$i] eq $prevtag
+                if (@$values[$i] eq "") {
+                }
+                else {
+					if ($first){
+						my $ind1 = substr(@$indicator[$j],0,1);                        
+						my $ind2 = substr(@$indicator[$j],1,1);
+						$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
+						$first=0;
+					}
+		    	$xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
 				}
-				$xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
-			}
 		}
-			$prevtag = @$tags[$i];
-        }
-        $xml.= MARC::File::XML::footer();
-# 	warn $xml;
+		$prevtag = @$tags[$i];
+	}
+	$xml.= MARC::File::XML::footer();
+	warn $xml;
 	return $xml
 }
 sub MARChtml2marc {
@@ -2992,10 +2993,14 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.115.2.45 2006/03/08 10:49:36 tipaul Exp $
+# $Id: Biblio.pm,v 1.115.2.46 2006/03/08 16:31:04 kados Exp $
 # $Log: Biblio.pm,v $
-# Revision 1.115.2.45  2006/03/08 10:49:36  tipaul
-# deal with &, <, >,", ' that are not valid in a XML file.
+# Revision 1.115.2.46  2006/03/08 16:31:04  kados
+# bugfix for Biblio.pm based on feedback from production system. previous
+# version was dropping subfields in cases where the previous tag in the
+# editor contained values (but only when multiple subfields existed in
+# both tags). This version will be tested again in production environment
+# to ensure it is actually fixed.
 #
 # Revision 1.115.2.44  2006/03/01 17:26:08  kados
 # Adding 'use MARC::File::XML' to routine ... needed for additem.pl to work





More information about the Koha-cvs mailing list