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

(-)a/Koha/Objects/Record/Collections.pm (-2 / +11 lines)
Lines 56-62 Allowed formats are marcxml, mij, marc and txt. Defaults to marcxml. Link Here
56
=cut
56
=cut
57
57
58
sub print_collection {
58
sub print_collection {
59
    my ( $self, $format ) = @_;
59
    my ( $self, $format, $embed_items ) = @_;
60
61
    $embed_items //= 0;
60
62
61
    my ( $start, $glue, $end, @parts );
63
    my ( $start, $glue, $end, @parts );
62
64
Lines 87-93 sub print_collection { Link Here
87
        }
89
        }
88
        MARC::File::XML->default_record_format($schema)
90
        MARC::File::XML->default_record_format($schema)
89
            if $format eq 'marcxml';
91
            if $format eq 'marcxml';
90
        push @parts, $serializers{$format}->( $element->record );
92
93
        my $record;
94
        if ( $embed_items ) {
95
            $record = $element->metadata_record( { embed_items => 1 } );
96
        } else {
97
            $record = $element->record;
98
        }
99
        push @parts, $serializers{$format}->( $record );
91
    }
100
    }
92
    return ( defined $start ? $start : '' ) . join( $glue, @parts ) . ( defined $end ? $end : '' );
101
    return ( defined $start ? $start : '' ) . join( $glue, @parts ) . ( defined $end ? $end : '' );
93
}
102
}
(-)a/Koha/REST/V1/Biblios.pm (-6 / +5 lines)
Lines 68-74 sub get { Link Here
68
            );
68
            );
69
        } else {
69
        } else {
70
            my $metadata = $biblio->metadata;
70
            my $metadata = $biblio->metadata;
71
            my $record   = $metadata->record;
71
            my $record   = $metadata->record( { embed_items => 1 } );
72
            my $schema   = $metadata->schema // C4::Context->preference("marcflavour");
72
            my $schema   = $metadata->schema // C4::Context->preference("marcflavour");
73
73
74
            $c->respond_to(
74
            $c->respond_to(
Lines 791-814 sub list { Link Here
791
            $c->res->headers->add( 'Content-Type', 'application/marcxml+xml' );
791
            $c->res->headers->add( 'Content-Type', 'application/marcxml+xml' );
792
            return $c->render(
792
            return $c->render(
793
                status => 200,
793
                status => 200,
794
                text   => $biblios->print_collection('marcxml')
794
                text   => $biblios->print_collection('marcxml', 1)
795
            );
795
            );
796
        } elsif ( $c->req->headers->accept =~ m/application\/marc-in-json(;.*)?$/ ) {
796
        } elsif ( $c->req->headers->accept =~ m/application\/marc-in-json(;.*)?$/ ) {
797
            $c->res->headers->add( 'Content-Type', 'application/marc-in-json' );
797
            $c->res->headers->add( 'Content-Type', 'application/marc-in-json' );
798
            return $c->render(
798
            return $c->render(
799
                status => 200,
799
                status => 200,
800
                data   => $biblios->print_collection('mij')
800
                data   => $biblios->print_collection('mij', 1)
801
            );
801
            );
802
        } elsif ( $c->req->headers->accept =~ m/application\/marc(;.*)?$/ ) {
802
        } elsif ( $c->req->headers->accept =~ m/application\/marc(;.*)?$/ ) {
803
            $c->res->headers->add( 'Content-Type', 'application/marc' );
803
            $c->res->headers->add( 'Content-Type', 'application/marc' );
804
            return $c->render(
804
            return $c->render(
805
                status => 200,
805
                status => 200,
806
                text   => $biblios->print_collection('marc')
806
                text   => $biblios->print_collection('marc', 1)
807
            );
807
            );
808
        } elsif ( $c->req->headers->accept =~ m/text\/plain(;.*)?$/ ) {
808
        } elsif ( $c->req->headers->accept =~ m/text\/plain(;.*)?$/ ) {
809
            return $c->render(
809
            return $c->render(
810
                status => 200,
810
                status => 200,
811
                text   => $biblios->print_collection('txt')
811
                text   => $biblios->print_collection('txt', 1)
812
            );
812
            );
813
        } else {
813
        } else {
814
            return $c->render(
814
            return $c->render(
815
- 

Return to bug 41618