Bugzilla – Attachment 128182 Details for
Bug 29597
Add tomarcplugin option to bulkmarcimport.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
ToMarcExample.pm
ToMarcExample.pm (text/plain), 1.80 KB, created by
David Gustafsson
on 2021-12-02 18:29:57 UTC
(
hide
)
Description:
ToMarcExample.pm
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2021-12-02 18:29:57 UTC
Size:
1.80 KB
patch
obsolete
>package Koha::Plugin::ToMarcExample; > >use Modern::Perl; >use Encode qw(encode); >## Required for all plugins >use base qw(Koha::Plugins::Base); > >use MARC::Record; >use MARC::Batch; >use MARC::File::USMARC; > >## Here we set our plugin version >our $VERSION = 0.01; > >## Here is our metadata, some keys are required, some are optional >our $metadata = { > name => 'to_marc example plugin', > author => 'David Gustafsson', > description => '', > date_authored => '2021-11-30', > date_updated => '2021-11-30', > minimum_version => '16.05', > maximum_version => undef, > version => $VERSION, >}; > >## This is the minimum code required for a plugin's 'new' method >## More can be added, but none should be removed >sub new { > my ( $class, $args ) = @_; > > ## We need to add our metadata here so our base class can access it > $args->{'metadata'} = $metadata; > $args->{'metadata'}->{'class'} = $class; > > ## Here, we call the 'new' method for our base class > ## This runs some additional magic and checking > ## and returns our actual $self > my $self = $class->SUPER::new($args); > > return $self; >} > > >## The existiance of a 'to_marc' subroutine means the plugin is capable >## of converting some type of file to MARC for use from the stage records >## for import tool >sub to_marc { > my ($self, $args) = @_; > > my $marc_batch; > my $fh; > { > open($fh, "<", \$args->{data}); > binmode $fh, ':raw'; > $marc_batch = MARC::Batch->new('USMARC', $fh); > } > > my @records; > while (my $record = $marc_batch->next()) { > my $field = MARC::Field->new('590','','','a' => 'ToMarcExample added field'); > $record->append_fields($field); > push @records, $record; > } > close($fh); #? > return encode('UTF-8', join('', map { $_->as_usmarc() } @records), 1) || undef; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 29597
:
128181
| 128182 |
128361