use C4::OAI::Sets;
use Koha::Cache;
+use Koha::Authority::Types;
use vars qw($VERSION @ISA @EXPORT);
$results{'linked'}->{ $heading->display_form() }++;
}
else {
- my $authtypedata =
- C4::AuthoritiesMarc::GetAuthType( $heading->auth_type() );
+ my $authority_type = Koha::Authority::Types->find( $heading->auth_type() );
my $marcrecordauth = MARC::Record->new();
if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
$marcrecordauth->leader(' nz a22 o 4500');
$field->delete_subfield( code => '9' )
if defined $current_link;
my $authfield =
- MARC::Field->new( $authtypedata->{auth_tag_to_report},
+ MARC::Field->new( $authority_type->auth_tag_to_report,
'', '', "a" => "" . $field->subfield('a') );
map {
$authfield->add_subfields( $_->[0] => $_->[1] )
=cut
sub TransformHtmlToMarc {
- my $cgi = shift;
+ my ($cgi, $isbiblio) = @_;
my @params = $cgi->param();
# creating a new record
my $record = MARC::Record->new();
- my $i = 0;
my @fields;
+ my ($biblionumbertagfield, $biblionumbertagsubfield) = (-1, -1);
+ ($biblionumbertagfield, $biblionumbertagsubfield) =
+ &GetMarcFromKohaField( "biblio.biblionumber", '' ) if $isbiblio;
#FIXME This code assumes that the CGI params will be in the same order as the fields in the template; this is no absolute guarantee!
- while ( $params[$i] ) { # browse all CGI params
+ for (my $i = 0; $params[$i]; $i++ ) { # browse all CGI params
my $param = $params[$i];
my $newfield = 0;
# if we are on biblionumber, store it in the MARC::Record (it may not be in the edited fields)
if ( $param eq 'biblionumber' ) {
- my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' );
if ( $biblionumbertagfield < 10 ) {
$newfield = MARC::Field->new( $biblionumbertagfield, $cgi->param($param), );
} else {
if ( $tag < 10 ) { # no code for theses fields
# in MARC editor, 000 contains the leader.
- if ( $tag eq '000' ) {
+ if ( $tag == $biblionumbertagfield ) {
+ # We do nothing and let $i be incremented
+ }
+ elsif ( $tag eq '000' ) {
# Force a fake leader even if not provided to avoid crashing
# during decoding MARC record containing UTF-8 characters
$record->leader(
# browse subfields for this tag (reason for _code_ match)
while(defined $params[$j] && $params[$j] =~ /_code_/) {
last unless defined $params[$j+1];
+ $j += 2 and next
+ if $tag == $biblionumbertagfield and
+ $cgi->param($params[$j]) eq $biblionumbertagsubfield;
#if next param ne subfield, then it was probably empty
#try next param by incrementing j
if($params[$j+1]!~/_subfield_/) {$j++; next; }
}
push @fields, $newfield if ($newfield);
}
- $i++;
}
$record->append_fields(@fields);