This commit is contained in:
tipaul 2003-04-01 12:26:43 +00:00
parent 674c150697
commit 452e65166c
7 changed files with 60 additions and 56 deletions

View file

@ -1,6 +1,9 @@
package C4::Biblio;
# $Id$
# $Log$
# Revision 1.41 2003/04/01 12:26:43 tipaul
# fixes
#
# Revision 1.40 2003/03/11 15:14:03 tipaul
# pod updating
#
@ -571,14 +574,14 @@ sub MARCaddsubfield {
$sth=$dbh->prepare("insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,valuebloblink) values (?,?,?,?,?,?,?)");
$sth->execute($bibid,(sprintf "%03s",$tagid),$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$res);
if ($sth->errstr) {
print STDERR "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n";
warn "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n";
}
# $dbh->do("unlock tables");
} else {
my $sth=$dbh->prepare("insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values (?,?,?,?,?,?,?)");
$sth->execute($bibid,(sprintf "%03s",$tagid),$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue);
if ($sth->errstr) {
print STDERR "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n";
warn "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n";
}
}
&MARCaddword($dbh,$bibid,$tagid,$tagorder,$subfieldcode,$subfieldorder,$subfieldvalue);
@ -691,6 +694,8 @@ sub MARCmodbiblio {
if ($oldrecord eq $record) {
return;
}
# warn "rec : ".$record->as_formatted;
# die;
# otherwise, skip through each subfield...
my @fields = $record->fields();
my $tagorder=0;
@ -718,6 +723,7 @@ sub MARCmodbiblio {
# modify the subfield if it's a different string
if ($oldfield->subfield(@$subfield[0]) ne @$subfield[1] ) {
my $subfieldid=&MARCfindsubfieldid($dbh,$bibid,$field->tag(),$tagorder,@$subfield[0],$subfieldorder);
warn "subfieldid => $subfieldid";
&MARCmodsubfield($dbh,$subfieldid,@$subfield[1]);
}
}
@ -969,35 +975,27 @@ sub MARCkoha2marcOnefield {
sub MARChtml2marc {
my ($dbh,$rtags,$rsubfields,$rvalues,%indicators) = @_;
my $prevtag = @$rtags[0];
my $prevtag = -1;
my $record = MARC::Record->new();
my %subfieldlist={};
my %subfieldlist=();
my $field;
for (my $i=0; $i< @$rtags; $i++) {
# rebuild MARC::Record
if (@$rtags[$i] ne $prevtag) {
# if ($prevtag<10) {
# $prevtag='0'.10;
# }
$indicators{$prevtag}.=' ';
if ($prevtag < 10) {
$record->add_fields((sprintf "%03s",$prevtag),%subfieldlist->{'@'});
} else {
my $field = MARC::Field->new( (sprintf "%03s",$prevtag), substr($indicators{$prevtag},0,1),substr($indicators{$prevtag},1,1), %subfieldlist);
$record->add_fields($field);
}
$indicators{@$rtags[$i]}.=' ';
$field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]);
$prevtag = @$rtags[$i];
%subfieldlist={};
%subfieldlist->{@$rsubfields[$i]} = @$rvalues[$i];
} else {
if (%subfieldlist->{@$rsubfields[$i]}) {
%subfieldlist->{@$rsubfields[$i]} .= '|';
}
%subfieldlist->{@$rsubfields[$i]} .=@$rvalues[$i];
$field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]);
$prevtag= @$rtags[$i];
}
}
# the last has not been included inside the loop... do it now !
my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist);
$record->add_fields($field);
return $record;
}
@ -1063,7 +1061,7 @@ sub MARCaddword {
if (length($word)>1 and !($stopwords->{uc($word)})) {
$sth->execute($bibid,$tag,$tagorder,$subfieldid,$subfieldorder,$word,$word);
if ($sth->err()) {
print STDERR "ERROR ==> insert into marc_word (bibid, tag, tagorder, subfieldid, subfieldorder, word, sndx_word) values ($bibid,$tag,$tagorder,$subfieldid,$subfieldorder,$word,soundex($word))\n";
warn "ERROR ==> insert into marc_word (bibid, tag, tagorder, subfieldid, subfieldorder, word, sndx_word) values ($bibid,$tag,$tagorder,$subfieldid,$subfieldorder,$word,soundex($word))\n";
}
}
}
@ -1130,7 +1128,7 @@ sub NEWnewbiblio {
$sth->execute("biblioitems.biblioitemnumber");
(my $tagfield2, my $tagsubfield2) = $sth->fetchrow;
if ($tagfield1 != $tagfield2) {
print STDERR "Error in NEWnewbiblio : biblio.biblionumber and biblioitems.biblioitemnumber MUST have the same field number";
warn "Error in NEWnewbiblio : biblio.biblionumber and biblioitems.biblioitemnumber MUST have the same field number";
print "Content-Type: text/html\n\nError in NEWnewbiblio : biblio.biblionumber and biblioitems.biblioitemnumber MUST have the same field number";
die;
}

View file

@ -120,10 +120,11 @@ sub themelanguage {
THEME:
foreach my $th (@themes) {
foreach my $la (@languages) {
# warn "File = $htdocs/$th/$la/$tmpl\n";
warn "File = $htdocs/$th/$la/$tmpl\n";
if (-e "$htdocs/$th/$la/$tmpl") {
$theme = $th;
$lang = $la;
warn "FOUND";
last THEME;
}
}

View file

@ -793,6 +793,5 @@ sub getreservetitle {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
# print $query;
return($data);
}

View file

@ -56,7 +56,6 @@ on what is passed to it, it calls the appropriate search function.
# marcsearch : search in the MARC biblio table.
# everything is choosen by the user : what to search, the conditions...
# FIXME this is a 1st version of the Marc Search. It does not use fulltext searching or marc_words table
sub catalogsearch {
my ($dbh, $tags, $subfields, $and_or, $excluding, $operator, $value, $offset,$length) = @_;
@ -127,7 +126,6 @@ sub catalogsearch {
}
}
chop $sql_tables;
warn "select m1.bibid from $sql_tables where $sql_where2 and ($sql_where1)";
my $sth;
if ($sql_where2) {
$sth = $dbh->prepare("select m1.bibid from $sql_tables where $sql_where2 and ($sql_where1)");

View file

@ -47,31 +47,30 @@ returned.
sub find_value {
my ($tagfield,$insubfield,$record) = @_;
my $result;
my @result;
my $indicator;
warn "tagfield : $tagfield /".$record->as_formatted;
if ($tagfield <10) {
if ($record->field($tagfield)) {
$result = $record->field($tagfield)->data();
push @result, $record->field($tagfield)->data();
} else {
$result="";
push @result,"";
}
} else {
foreach my $field ($record->field($tagfield)) {
my @subfields = $field->subfields();
foreach my $subfield (@subfields) {
if (@$subfield[0] eq $insubfield) {
$result .= @$subfield[1];
push @result,@$subfield[1];
$indicator = $field->indicator(1).$field->indicator(2);
}
}
}
}
return($indicator,$result);
return($indicator,@result);
}
=item find_value
=item MARCfindbreeding
$record = MARCfindbreeding($dbh, $breedingid);
@ -88,7 +87,6 @@ sub MARCfindbreeding {
my ($file,$marc) = $sth->fetchrow;
if ($marc) {
my $record = MARC::File::USMARC::decode($marc);
warn "==> ".$record->as_formatted();
if (ref($record) eq undef) {
return -1;
} else {
@ -180,36 +178,47 @@ sub build_tabs ($$$) {
foreach my $subfield (sort(keys %{$tagslib->{$tag}})) {
next if subfield_is_koha_internal_p($subfield);
next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
my %subfield_data;
$subfield_data{tag}=$tag;
$subfield_data{subfield}=$subfield;
$subfield_data{marc_lib}="<DIV id=\"error$i\">".$tagslib->{$tag}->{$subfield}->{lib}."</div>";
$subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
$subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
$subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
# if breeding is not empty
if ($record ne -1) {
my ($x,$value) = find_value($tag,$subfield,$record);
$value=char_decode($value) unless ($is_a_modif);
$indicator = $x if $x; #XXX
if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
$subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh, $authorised_values_sth);
} elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) {
$subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" size=47 maxlength=255> <a href=\"javascript:Dopop('../thesaurus_popup.pl?category=$tagslib->{$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">...</a>"; #"
} elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
require $plugin;
my $extended_param = plugin_parameters($dbh,$record,$tagslib,$i,$tabloop);
my ($function_name,$javascript) = plugin_javascript($dbh,$record,$tagslib,$i,$tabloop);
$subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=47 maxlength=255 OnFocus=\"javascript:Focus$function_name($i)\" OnBlur=\"javascript:Blur$function_name($i)\"> <a href=\"javascript:Clic$function_name($i)\">...</a> $javascript";
} else {
$subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=50 maxlength=255>";
my ($x,@value) = find_value($tag,$subfield,$record);
foreach my $value (@value) {
my %subfield_data;
$subfield_data{tag}=$tag;
$subfield_data{subfield}=$subfield;
$subfield_data{marc_lib}="<DIV id=\"error$i\">".$tagslib->{$tag}->{$subfield}->{lib}."</div>";
$subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
$subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
$subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
$value=char_decode($value) unless ($is_a_modif);
$indicator = $x if $x; #XXX
if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
$subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh, $authorised_values_sth);
} elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) {
$subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" size=47 maxlength=255> <a href=\"javascript:Dopop('../thesaurus_popup.pl?category=$tagslib->{$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">...</a>"; #"
} elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
require $plugin;
my $extended_param = plugin_parameters($dbh,$record,$tagslib,$i,$tabloop);
my ($function_name,$javascript) = plugin_javascript($dbh,$record,$tagslib,$i,$tabloop);
$subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=47 maxlength=255 OnFocus=\"javascript:Focus$function_name($i)\" OnBlur=\"javascript:Blur$function_name($i)\"> <a href=\"javascript:Clic$function_name($i)\">...</a> $javascript";
} else {
$subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=50 maxlength=255>";
}
push(@subfields_data, \%subfield_data);
$i++;
}
# if breeding is empty
} else {
my ($x,$value);
($x,$value) = find_value($tag,$subfield,$record) if ($record ne -1);
$value=char_decode($value) unless ($is_a_modif);
my %subfield_data;
$subfield_data{tag}=$tag;
$subfield_data{subfield}=$subfield;
$subfield_data{marc_lib}="<DIV id=\"error$i\">".$tagslib->{$tag}->{$subfield}->{lib}."</div>";
$subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
$subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
$subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
$subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh, $authorised_values_sth);
} elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) {
@ -223,9 +232,9 @@ sub build_tabs ($$$) {
} else {
$subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" size=50 maxlength=255>";
}
push(@subfields_data, \%subfield_data);
$i++;
}
push(@subfields_data, \%subfield_data);
$i++;
}
if ($#subfields_data >= 0) {
my %tag_data;

View file

@ -74,7 +74,6 @@ if ($op eq "additem") {
$indicators{$ind_tag[$i]} = $indicator[$i];
}
my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
warn "item before NEWnewitem : ".$record->as_formatted();
# MARC::Record builded => now, record in DB
my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$bibid);
$nextop = "additem";

View file

@ -68,7 +68,7 @@ if ($op eq "do_search") {
flagsrequired => {catalogue => 1},
debug => 1,
});
#$template->param(result => \@results);
$template->param(result => \@results);
} else {
($template, $loggedinuser, $cookie)