[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/cataloguing addbiblio.pl [rel_3_0]
From: |
Antoine Farnault |
Subject: |
[Koha-cvs] koha/cataloguing addbiblio.pl [rel_3_0] |
Date: |
Mon, 04 Sep 2006 09:15:47 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/09/04 09:15:47
Modified files:
cataloguing : addbiblio.pl
Log message:
-1- sync with dev_week
-2- sync with rel_2_2
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.14&r2=1.14.2.1
Patches:
Index: addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -b -r1.14 -r1.14.2.1
--- addbiblio.pl 3 Apr 2006 00:17:13 -0000 1.14
+++ addbiblio.pl 4 Sep 2006 09:15:47 -0000 1.14.2.1
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: addbiblio.pl,v 1.14 2006/04/03 00:17:13 kados Exp $
+# $Id: addbiblio.pl,v 1.14.2.1 2006/09/04 09:15:47 toins Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -26,7 +26,6 @@
use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::Search;
-use C4::SearchMarc; # also includes Biblio.pm, SearchMarc is used to
FindDuplicate
use C4::Context;
use C4::Log;
use C4::Koha; # XXX subfield_is_koha_internal_p
@@ -34,6 +33,9 @@
use MARC::File::USMARC;
use MARC::File::XML;
+if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
+ MARC::File::XML->default_record_format( 'UNIMARC' );
+}
use vars qw( $tagslib);
use vars qw( $authorised_values_sth);
use vars qw( $is_a_modif );
@@ -97,6 +99,44 @@
if (ref($record) eq undef) {
return -1;
} else {
+ if (C4::Context->preference("z3950NormalizeAuthor") and
C4::Context->preference("z3950AuthorAuthFields")){
+ my ($tag,$subfield) =
MARCfind_marc_from_kohafield($dbh,"biblio.author");
+# my $summary =
C4::Context->preference("z3950authortemplate");
+ my $auth_fields =
C4::Context->preference("z3950AuthorAuthFields");
+ my @auth_fields= split /,/,$auth_fields;
+ my $field;
+ warn $record->as_formatted;
+ if ($record->field($tag)){
+ foreach my $tmpfield
($record->field($tag)->subfields){
+# foreach my $subfieldcode
($tmpfield->subfields){
+ my $subfieldcode=shift
@$tmpfield;
+ my $subfieldvalue=shift
@$tmpfield;
+ if ($field){
+
$field->add_subfields("$subfieldcode"=>$subfieldvalue) if ($subfieldcode ne
$subfield);
+ } else {
+
$field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if
($subfieldcode ne $subfield);
+ }
+ }
+ warn $field->as_formatted;
+# }
+ }
+ $record->delete_field($record->field($tag));
+ foreach my $fieldtag (@auth_fields){
+ next unless ($record->field($fieldtag));
+ my $lastname =
$record->field($fieldtag)->subfield('a');
+ my $firstname=
$record->field($fieldtag)->subfield('b');
+ my $title =
$record->field($fieldtag)->subfield('c');
+ my $number=
$record->field($fieldtag)->subfield('d');
+ if ($title){
+#
$field->add_subfields("$subfield"=>"[ ".ucfirst($title).ucfirst($firstname)."
".$number." ]");
+
$field->add_subfields("$subfield"=>ucfirst($title)." ".ucfirst($firstname)."
".$number);
+ }else{
+#
$field->add_subfields("$subfield"=>"[ ".ucfirst($firstname).",
".ucfirst($lastname)." ]");
+
$field->add_subfields("$subfield"=>ucfirst($firstname).", ".ucfirst($lastname));
+ }
+ }
+ $record->insert_fields_ordered($field);
+ }
return $record,$encoding;
}
}
@@ -165,6 +205,9 @@
=cut
sub create_input () {
my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
+ # must be encoded as utf-8 before it reaches the editor
+ #use Encode;
+ #$value = encode('utf-8', $value);
$value =~ s/"/"/g;
my $dbh = C4::Context->dbh;
my %subfield_data;
@@ -183,14 +226,14 @@
$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
onblur=\"this.style.backgroundColor='#ffffff';\"
onfocus=\"this.style.backgroundColor='#ffff00;'\"\" tabindex=\"1\"
type=\"text\" name=\"field_value\" value=\"$value\" size=\"70\"
maxlength=\"255\" DISABLE READONLY> <a style=\"cursor: help;\"
href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
+ $subfield_data{marc_value}="<input type=\"text\"
onblur=\"this.style.backgroundColor='#ffffff';\"
onfocus=\"this.style.backgroundColor='#ffff00;'\"\" tabindex=\"1\"
type=\"text\" name=\"field_value\" value=\"$value\" size=\"70\"
maxlength=\"255\" DISABLE READONLY> <a style=\"cursor: help;\"
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
# (the cgidir differs)
- my $cgidir = C4::Context->intranetdir ."/cgi-bin/value_builder";
+ my $cgidir = C4::Context->intranetdir
."/cgi-bin/cataloguing/value_builder";
unless (opendir(DIR, "$cgidir")) {
- $cgidir = C4::Context->intranetdir."/value_builder";
+ $cgidir =
C4::Context->intranetdir."/cataloguing/value_builder";
}
my
$plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
require $plugin;
@@ -205,7 +248,7 @@
# it's a standard field
} else {
if (length($value) >100) {
- $subfield_data{marc_value}="<textarea
name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
+ $subfield_data{marc_value}="<textarea tabindex=\"1\"
name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
} else {
$subfield_data{marc_value}="<input
onblur=\"this.style.backgroundColor='#ffffff';\"
onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"text\"
name=\"field_value\" value=\"$value\" size=\"70\">"; #"
}
@@ -414,7 +457,8 @@
my $record=-1;
my $encoding="";
#$record = MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
-$record=get_record($biblionumber) if ($biblionumber);
+my $dbh = C4::Context->dbh;
+$record=MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
@@ -450,9 +494,9 @@
if (!$duplicatebiblionumber or $confirm_not_duplicate) {
# MARC::Record built => now, record in DB
if ($is_a_modif) {
- warn "CONFIRM ITS A MODIF : .$biblionumber";
-
NEWmodbiblioframework($dbh,$biblionumber,$frameworkcode);
- NEWmodbiblio($dbh,$record,$biblionumber,$frameworkcode);
+ warn "CONFIRM ITS A MODIF :".$biblionumber;
+ NEWmodbiblioframework($biblionumber,$frameworkcode);
+ NEWmodbiblio($record,$biblionumber,$frameworkcode);
} else {
my $biblioitemnumber;
($biblionumber,$biblioitemnumber) =
NEWnewbiblio($dbh,$record,$frameworkcode);
@@ -481,6 +525,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');
@@ -488,10 +534,18 @@
my @ind_tag = $input->param('ind_tag');
my @indicator = $input->param('indicator');
my $xml =
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
- my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
+ my $record;
+ if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
+ $record =
MARChtml2marc($dbh,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
+ } else {
+ my $xml =
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
+
$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
+ }
# adding an empty field
+ for (my $i=1;$i<=$cntrepeatfield;$i++){
my $field =
MARC::Field->new("$addedfield",'','','$tagaddfield_subfield' => "");
$record->append_fields($field);
+ }
build_tabs ($template, $record, $dbh,$encoding);
build_hidden_data;
$template->param(
- [Koha-cvs] koha/cataloguing addbiblio.pl [rel_3_0],
Antoine Farnault <=