|
Lines 24-33
use Koha::Database;
Link Here
|
| 24 |
|
24 |
|
| 25 |
use Koha::Biblio; |
25 |
use Koha::Biblio; |
| 26 |
use Koha::Libraries; |
26 |
use Koha::Libraries; |
| 27 |
use MARC::File::MiJ; |
|
|
| 28 |
use MARC::File::USMARC; |
| 29 |
use MARC::File::XML; |
| 30 |
use MARC::Record; |
| 31 |
|
27 |
|
| 32 |
use base qw(Koha::Objects Koha::Objects::Record::Collections); |
28 |
use base qw(Koha::Objects Koha::Objects::Record::Collections); |
| 33 |
|
29 |
|
|
Lines 39-83
Koha::Biblios - Koha Biblio object set class
Link Here
|
| 39 |
|
35 |
|
| 40 |
=head2 Class methods |
36 |
=head2 Class methods |
| 41 |
|
37 |
|
| 42 |
=head3 print_collection |
|
|
| 43 |
my $collection_text = $result_set->print_collection($format) |
| 44 |
|
| 45 |
Return a text representation of a collection (group of records) in the specified format. |
| 46 |
Allowed formats are marcxml, mij, marc and txt. Defaults to marcxml. |
| 47 |
|
| 48 |
=cut |
| 49 |
|
| 50 |
sub print_collection { |
| 51 |
my ( $self, $format ) = @_; |
| 52 |
|
| 53 |
my ($start, $glue, $end, @parts); |
| 54 |
|
| 55 |
my %serializers = ( |
| 56 |
'mij' => \&MARC::File::MiJ::encode, |
| 57 |
'marc' => \&MARC::File::USMARC::encode, |
| 58 |
'txt' => \&MARC::Record::as_formatted, |
| 59 |
'marcxml' => \&MARC::File::XML::record |
| 60 |
); |
| 61 |
if ($format eq 'mij') { |
| 62 |
$start = '['; |
| 63 |
$glue = ','; |
| 64 |
$end = ']'; |
| 65 |
} elsif ($format eq 'marc') { |
| 66 |
$glue = "\n"; |
| 67 |
} elsif ($format eq 'txt') { |
| 68 |
$glue = "\n\n"; |
| 69 |
} else { |
| 70 |
$glue = ''; |
| 71 |
$format = 'marcxml'; |
| 72 |
$start = MARC::File::XML::header(); |
| 73 |
$end = MARC::File::XML::footer(); |
| 74 |
} |
| 75 |
while (my $biblio = $self->next) { |
| 76 |
push @parts, $serializers{$format}->($biblio->metadata->record); |
| 77 |
} |
| 78 |
return (defined $start ? $start : '').join($glue, @parts).(defined $end ? $end : ''); |
| 79 |
} |
| 80 |
|
| 81 |
=head3 pickup_locations |
38 |
=head3 pickup_locations |
| 82 |
|
39 |
|
| 83 |
my $biblios = Koha::Biblios->search(...); |
40 |
my $biblios = Koha::Biblios->search(...); |
| 84 |
- |
|
|