View | Details | Raw Unified | Return to bug 12409
Collapse All | Expand All

(-)a/C4/Record.pm (-43 / +47 lines)
Lines 661-714 sub marc2bibtex { Link Here
661
    $author = join ' and ', @texauthors;
661
    $author = join ' and ', @texauthors;
662
662
663
    # Defining the conversion hash according to the marcflavour
663
    # Defining the conversion hash according to the marcflavour
664
    my %bh;
664
    my @bh;
665
    if ( $marcflavour eq "UNIMARC" ) {
665
    if ( $marcflavour eq "UNIMARC" ) {
666
	
666
667
	# FIXME, TODO : handle repeatable fields
667
        # FIXME, TODO : handle repeatable fields
668
	# TODO : handle more types of documents
668
        # TODO : handle more types of documents
669
669
670
	# Unimarc to bibtex hash
670
        # Unimarc to bibtex hash
671
	%bh = (
671
        @bh = (
672
672
673
	    # Mandatory
673
            # Mandatory
674
	    author    => $author,
674
            author    => $author,
675
	    title     => $record->subfield("200", "a") || "",
675
            title     => $record->subfield("200", "a") || "",
676
	    editor    => $record->subfield("210", "g") || "",
676
            editor    => $record->subfield("210", "g") || "",
677
	    publisher => $record->subfield("210", "c") || "",
677
            publisher => $record->subfield("210", "c") || "",
678
	    year      => $record->subfield("210", "d") || $record->subfield("210", "h") || "",
678
            year      => $record->subfield("210", "d") || $record->subfield("210", "h") || "",
679
679
680
	    # Optional
680
            # Optional
681
	    volume  =>  $record->subfield("200", "v") || "",
681
            volume  =>  $record->subfield("200", "v") || "",
682
	    series  =>  $record->subfield("225", "a") || "",
682
            series  =>  $record->subfield("225", "a") || "",
683
	    address =>  $record->subfield("210", "a") || "",
683
            address =>  $record->subfield("210", "a") || "",
684
	    edition =>  $record->subfield("205", "a") || "",
684
            edition =>  $record->subfield("205", "a") || "",
685
	    note    =>  $record->subfield("300", "a") || "",
685
            note    =>  $record->subfield("300", "a") || "",
686
	    url     =>  $record->subfield("856", "u") || ""
686
            url     =>  $record->subfield("856", "u") || ""
687
	);
687
        );
688
    } else {
688
    } else {
689
689
690
	# Marc21 to bibtex hash
690
        # Marc21 to bibtex hash
691
	%bh = (
691
        @bh = (
692
692
693
	    # Mandatory
693
            # Mandatory
694
	    author    => $author,
694
            author    => $author,
695
	    title     => $record->subfield("245", "a") || "",
695
            title     => $record->subfield("245", "a") || "",
696
	    editor    => $record->subfield("260", "f") || "",
696
            editor    => $record->subfield("260", "f") || "",
697
        publisher => $record->subfield("264", "b") || $record->subfield("260", "b") || "",
697
            publisher => $record->subfield("264", "b") || $record->subfield("260", "b") || "",
698
        year      => $record->subfield("264", "c") || $record->subfield("260", "c") || $record->subfield("260", "g") || "",
698
            year      => $record->subfield("264", "c") || $record->subfield("260", "c") || $record->subfield("260", "g") || "",
699
699
700
	    # Optional
700
            # Optional
701
	    # unimarc to marc21 specification says not to convert 200$v to marc21
701
            # unimarc to marc21 specification says not to convert 200$v to marc21
702
	    series  =>  $record->subfield("490", "a") || "",
702
            series  =>  $record->subfield("490", "a") || "",
703
        address =>  $record->subfield("264", "a") || $record->subfield("260", "a") || "",
703
            address =>  $record->subfield("264", "a") || $record->subfield("260", "a") || "",
704
	    edition =>  $record->subfield("250", "a") || "",
704
            edition =>  $record->subfield("250", "a") || "",
705
	    note    =>  $record->subfield("500", "a") || "",
705
            note    =>  $record->subfield("500", "a") || "",
706
	    url     =>  $record->subfield("856", "u") || ""
706
            url     =>  $record->subfield("856", "u") || ""
707
	);
707
        );
708
    }
708
    }
709
709
710
    $tex .= "\@book{";
710
    $tex .= "\@book{";
711
    $tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = {$bh{$_}}) : () } keys %bh);
711
    my @elt;
712
    for ( my $i = 0 ; $i < scalar( @bh ) ; $i = $i + 2 ) {
713
        next unless $bh[$i+1];
714
        push @elt, qq|\t$bh[$i] = {$bh[$i+1]}|;
715
    }
716
    $tex .= join(",\n", $id, @elt);
712
    $tex .= "\n}\n";
717
    $tex .= "\n}\n";
713
718
714
    return $tex;
719
    return $tex;
715
- 

Return to bug 12409