[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha C4/Biblio.pm cataloguing/addbiblio.pl cata...
From: |
Joshua Ferraro |
Subject: |
[Koha-cvs] koha C4/Biblio.pm cataloguing/addbiblio.pl cata... |
Date: |
Mon, 06 Mar 2006 02:45:42 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch:
Changes by: Joshua Ferraro <address@hidden> 06/03/06 02:45:42
Modified files:
C4 : Biblio.pm
cataloguing : addbiblio.pl additem.pl
Log message:
Adding fixes to MARC editor to HEAD
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Biblio.pm.diff?tr1=1.157&tr2=1.158&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/cataloguing/addbiblio.pl.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/cataloguing/additem.pl.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: koha/C4/Biblio.pm
diff -u koha/C4/Biblio.pm:1.157 koha/C4/Biblio.pm:1.158
--- koha/C4/Biblio.pm:1.157 Wed Mar 1 03:07:54 2006
+++ koha/C4/Biblio.pm Mon Mar 6 02:45:41 2006
@@ -29,7 +29,7 @@
use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.157 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.158 $' =~ /\d+/g;
shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
@ISA = qw(Exporter);
@@ -65,7 +65,7 @@
&NEWmodbiblioframework
&MARCkoha2marcBiblio &MARCmarc2koha
- &MARCkoha2marcItem &MARChtml2marc
+ &MARCkoha2marcItem &MARChtml2marc &MARChtml2xml
&MARCgetbiblio &MARCgetitem
&XMLgetbiblio
@@ -621,7 +621,72 @@
}
return $record;
}
+=head2 MARChtml2xml
+$XMLrecord = MARChtml2xml($rtags,$rsubfields,$rvalues,$indicator,$ind_tag);
+
+transforms the parameters (coming from HTML form) into a MARC::File::XML
+object. parameters with r are references to arrays
+
+=cut
+sub MARChtml2xml {
+ 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 $j = -1;
+ for (my $i=0;$i<address@hidden;$i++){
+
+ if ((@$tags[$i] ne $prevtag)){
+ $j++ unless (@$tags[$i] eq "");
+ warn
"IND:".substr(@$indicator[$j],0,1).substr(@$indicator[$j],1,1)."
"address@hidden;
+
+ if (!$first){
+ $xml.="</datafield>\n";
+ $first=1;
+ }
+ 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) {
+ $xml.="<controlfield
tag=\"@$tags[$i]\">@$values[$i]</controlfield>\n";
+ $first=1;
+ }
+ 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;
+ }
+ $xml.="<subfield
code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
+
+ }
+ }
+ $prevtag = @$tags[$i];
+ }
+ $xml.= MARC::File::XML::footer();
+ warn $xml;
+ return $xml
+}
=head2 MARChtml2marc
$MARCrecord = MARChtml2marc($dbh,$rtags,$rsubfields,$rvalues,%indicators);
@@ -2968,8 +3033,11 @@
=cut
-# $Id: Biblio.pm,v 1.157 2006/03/01 03:07:54 kados Exp $
+# $Id: Biblio.pm,v 1.158 2006/03/06 02:45:41 kados Exp $
# $Log: Biblio.pm,v $
+# Revision 1.158 2006/03/06 02:45:41 kados
+# Adding fixes to MARC editor to HEAD
+#
# Revision 1.157 2006/03/01 03:07:54 kados
# rollback ... by accident I committed a rel_2_2 Biblio.pm
#
Index: koha/cataloguing/addbiblio.pl
diff -u koha/cataloguing/addbiblio.pl:1.5 koha/cataloguing/addbiblio.pl:1.6
--- koha/cataloguing/addbiblio.pl:1.5 Sun Feb 26 00:12:51 2006
+++ koha/cataloguing/addbiblio.pl Mon Mar 6 02:45:42 2006
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: addbiblio.pl,v 1.5 2006/02/26 00:12:51 kados Exp $
+# $Id: addbiblio.pl,v 1.6 2006/03/06 02:45:42 kados Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -418,11 +418,8 @@
# build indicator hash.
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
- my %indicators;
- for (my $i=0;$i<=$#ind_tag;$i++) {
- $indicators{$ind_tag[$i]} = $indicator[$i];
- }
- my $record =
MARChtml2marc($dbh,address@hidden,address@hidden,address@hidden,%indicators);
+ my $xml =
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
+ my $record=MARC::Record::new_from_xml($xml);
# check for a duplicate
my ($duplicatebiblionumber,$duplicatebibid,$duplicatetitle) =
FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif);
my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
@@ -466,11 +463,8 @@
# build indicator hash.
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
- my %indicators;
- for (my $i=0;$i<=$#ind_tag;$i++) {
- $indicators{$ind_tag[$i]} = $indicator[$i];
- }
- my $record =
MARChtml2marc($dbh,address@hidden,address@hidden,address@hidden,%indicators);
+ my $xml =
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
+ my $record=MARC::Record::new_from_xml($xml);
# adding an empty field
my $field = MARC::Field->new("$addedfield",'','','a'=> "");
$record->append_fields($field);
Index: koha/cataloguing/additem.pl
diff -u koha/cataloguing/additem.pl:1.3 koha/cataloguing/additem.pl:1.4
--- koha/cataloguing/additem.pl:1.3 Wed Feb 15 03:14:53 2006
+++ koha/cataloguing/additem.pl Mon Mar 6 02:45:42 2006
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: additem.pl,v 1.3 2006/02/15 03:14:53 rangi Exp $
+# $Id: additem.pl,v 1.4 2006/03/06 02:45:42 kados Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -74,11 +74,8 @@
# build indicator hash.
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
- my %indicators;
- for (my $i=0;$i<=$#ind_tag;$i++) {
- $indicators{$ind_tag[$i]} = $indicator[$i];
- }
- my $record =
MARChtml2marc($dbh,address@hidden,address@hidden,address@hidden,%indicators);
+ my $xml =
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
+ my $record=MARC::Record::new_from_xml($xml);
# if autoBarcode is ON, calculate barcode...
if (C4::Context->preference('autoBarcode')) {
my ($tagfield,$tagsubfield) =
&MARCfind_marc_from_kohafield($dbh,"items.barcode");
@@ -124,11 +121,8 @@
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
# my $itemnumber = $input->param('itemnumber');
- my %indicators;
- for (my $i=0;$i<=$#ind_tag;$i++) {
- $indicators{$ind_tag[$i]} = $indicator[$i];
- }
- my $itemrecord =
MARChtml2marc($dbh,address@hidden,address@hidden,address@hidden,%indicators);
+ my $xml =
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
+ my $itemrecord=MARC::Record::new_from_xml($xml);
# MARC::Record builded => now, record in DB
# warn "R: ".$record->as_formatted;
my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) =
NEWmoditem($dbh,$record,$biblionumber,$itemnumber,0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha C4/Biblio.pm cataloguing/addbiblio.pl cata...,
Joshua Ferraro <=