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

(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 822-827 our $PERL_DEPS = { Link Here
822
        'required' => '0',
822
        'required' => '0',
823
        'min_ver'  => '0.03',
823
        'min_ver'  => '0.03',
824
    },
824
    },
825
    'MARC::File::MARCMaker' => {
826
        'usage'    => 'Core',
827
        'required' => '1',
828
        'min_ver'  => '0.05',
829
    },
825
};
830
};
826
831
827
1;
832
1;
(-)a/C4/Record.pm (+69 lines)
Lines 25-30 use strict; Link Here
25
25
26
# please specify in which methods a given module is used
26
# please specify in which methods a given module is used
27
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding
27
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding
28
use MARC::File::MARCMaker; #marc2marcmaker
28
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding
29
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding
29
use Biblio::EndnoteStyle;
30
use Biblio::EndnoteStyle;
30
use Unicode::Normalize; # _entity_encode
31
use Unicode::Normalize; # _entity_encode
Lines 58-63 $VERSION = 3.07.00.049; Link Here
58
  &marc2madsxml
59
  &marc2madsxml
59
  &marc2bibtex
60
  &marc2bibtex
60
  &marc2csv
61
  &marc2csv
62
  &marc2marcmaker
61
  &changeEncoding
63
  &changeEncoding
62
);
64
);
63
65
Lines 854-859 sub marc2bibtex { Link Here
854
    return $tex;
856
    return $tex;
855
}
857
}
856
858
859
=head2 marc2marcmaker - Convert from ISO-2709 to MARCMaker format
860
861
    my ( $error, $marcmaker) = marc2marcmaker( $marc, $biblionumber, $unimarc2marc21 );
862
863
Returns a MARCMaker format
864
865
C<$marc> - an ISO-2709  or MARC::Record object
866
867
C<$biblionumber> - The biblionumber of the record
868
869
C<$unimarc2marc21> - Set to 1 to convert UNIMARC to MARC21 on the fly or 0 if don't (Only for UNIMARC environment)
870
871
=cut
872
873
sub marc2marcmaker {
874
875
    my ( $marc, $biblionumber, $unimarc2marc21 ) = @_;
876
877
    # global variables
878
    my ( $marc_mrk_output, $marcxml, $output_xsl, $marc_record_obj, $xsl, $error );
879
880
    if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object
881
        ($unimarc2marc21) ?
882
            $marcxml = C4::Record::marc2marcxml( $marc ) :
883
            $marc_record_obj = $marc;
884
    } elsif ( defined $biblionumber ) {
885
        ($unimarc2marc21) ?
886
            $marcxml = C4::Biblio::GetXmlBiblio( $biblionumber ) :
887
            $marc_record_obj = GetMarcBiblio($biblionumber, 1);
888
    } else { # it's not a MARC::Record object, make it one
889
        eval { $marc_record_obj = MARC::Record->new_from_usmarc( $marc ) }; # handle exceptions
890
    }
891
892
    # conversion to MARC::Record object failed
893
    if ( $@ ) {
894
        $error .= "\nCreation of MARC::Record object failed: " . $MARC::Record::ERROR;
895
        carp "Creation of MARC::Record object failed.";
896
    } elsif ( $marc_record_obj->warnings() ) {
897
        carp "Warnings encountered while processing ISO-2709 record.\n";
898
        my @warnings = $marc_record_obj->warnings();
899
        foreach my $warn (@warnings) {
900
            carp "\t". $warn;
901
        };
902
    }
903
904
    #Convert UNIMARC to MARC21
905
    if ( C4::Context->preference('marcflavour') eq 'UNIMARC' and $unimarc2marc21 ) {
906
        $xsl = C4::Context->config('intrahtdocs') . '/prog/en/xslt/UNIMARC2MARC21.xsl';
907
        my $xslt_engine = Koha::XSLT_Handler->new;
908
        $output_xsl = $xslt_engine->transform( $marcxml, $xsl );
909
        my $err = $xslt_engine->err; # error number
910
        my $errstr = $xslt_engine->errstr; # error message
911
        if ( $err ) {
912
            $error .= "Error when processing $errstr Error number: $err\n";
913
            carp "Error when processing $errstr Error number: $err\n";
914
        }  else {
915
            $marc_record_obj = C4::Record::marcxml2marc( $output_xsl, 'UTF-8', 'MARC21' );
916
        }
917
    }
918
919
    unless ($error) { # if no errors makes MARCMaker convertion
920
        $marc_mrk_output = MARC::File::MARCMaker->encode($marc_record_obj);
921
    }
922
923
    return ( $error, $marc_mrk_output );
924
925
}
857
926
858
=head1 INTERNAL FUNCTIONS
927
=head1 INTERNAL FUNCTIONS
859
928
(-)a/debian/control (-1 / +2 lines)
Lines 70-75 Build-Depends: libalgorithm-checkdigits-perl, Link Here
70
 liblwp-protocol-https-perl|libwww-perl (<6.02), libio-socket-ssl-perl,
70
 liblwp-protocol-https-perl|libwww-perl (<6.02), libio-socket-ssl-perl,
71
 libmail-sendmail-perl,
71
 libmail-sendmail-perl,
72
 libmarc-charset-perl,
72
 libmarc-charset-perl,
73
 libmarc-file-marcmaker-perl
73
 libmarc-record-perl,
74
 libmarc-record-perl,
74
 libmarc-xml-perl,
75
 libmarc-xml-perl,
75
 libmemoize-memcached-perl,
76
 libmemoize-memcached-perl,
Lines 277-282 Depends: libalgorithm-checkdigits-perl, Link Here
277
 liblwp-protocol-https-perl|libwww-perl (<6.02), libio-socket-ssl-perl,
278
 liblwp-protocol-https-perl|libwww-perl (<6.02), libio-socket-ssl-perl,
278
 libmail-sendmail-perl,
279
 libmail-sendmail-perl,
279
 libmarc-charset-perl,
280
 libmarc-charset-perl,
281
 libmarc-file-marcmaker-perl
280
 libmarc-record-perl,
282
 libmarc-record-perl,
281
 libmarc-xml-perl,
283
 libmarc-xml-perl,
282
 libmemoize-memcached-perl,
284
 libmemoize-memcached-perl,
283
- 

Return to bug 15698