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

(-)a/C4/XSLT.pm (-10 / +8 lines)
Lines 31-38 use Koha::ItemTypes; Link Here
31
use Koha::XSLT::Base;
31
use Koha::XSLT::Base;
32
use Koha::Libraries;
32
use Koha::Libraries;
33
33
34
35
36
my $engine; #XSLT Handler object
34
my $engine; #XSLT Handler object
37
my %authval_per_framework;
35
my %authval_per_framework;
38
    # Cache for tagfield-tagsubfield to decode per framework.
36
    # Cache for tagfield-tagsubfield to decode per framework.
Lines 65-71 Is only used in this module currently. Link Here
65
=cut
63
=cut
66
64
67
sub transformMARCXML4XSLT {
65
sub transformMARCXML4XSLT {
68
    my ($biblionumber, $record) = @_;
66
    my ($biblionumber, $record, $opac) = @_;
69
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
67
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
70
    my $tagslib = &GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
68
    my $tagslib = &GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
71
    my @fields;
69
    my @fields;
Lines 84-90 sub transformMARCXML4XSLT { Link Here
84
                    my ( $letter, $value ) = @$subfield;
82
                    my ( $letter, $value ) = @$subfield;
85
                    # Replace the field value with the authorised value *except* for MARC21/NORMARC field 942$n (suppression in opac)
83
                    # Replace the field value with the authorised value *except* for MARC21/NORMARC field 942$n (suppression in opac)
86
                    if ( !( $tag eq '942' && $subfield->[0] eq 'n' ) || $marcflavour eq 'UNIMARC' ) {
84
                    if ( !( $tag eq '942' && $subfield->[0] eq 'n' ) || $marcflavour eq 'UNIMARC' ) {
87
                        $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib )
85
                        $value = GetAuthorisedValueDesc( $tag, $letter, $value, $frameworkcode, $tagslib, undef, $opac )
88
                            if $av->{ $tag }->{ $letter };
86
                            if $av->{ $tag }->{ $letter };
89
                    }
87
                    }
90
                    push( @new_subfields, $letter, $value );
88
                    push( @new_subfields, $letter, $value );
Lines 397-409 sub buildKohaItemsNamespace { Link Here
397
        else {
395
        else {
398
            $status = "available";
396
            $status = "available";
399
        }
397
        }
400
        my $homebranch     = xml_escape($branches{$item->homebranch});
398
        my $homebranch     = C4::Koha::xml_escape($branches{$item->homebranch});
401
        my $holdingbranch  = xml_escape($branches{$item->holdingbranch});
399
        my $holdingbranch  = C4::Koha::xml_escape($branches{$item->holdingbranch});
402
        my $resultbranch   = C4::Context->preference('OPACResultsLibrary') eq 'homebranch' ? $homebranch : $holdingbranch;
400
        my $resultbranch   = C4::Context->preference('OPACResultsLibrary') eq 'homebranch' ? $homebranch : $holdingbranch;
403
        my $location       = xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location);
401
        my $location       = C4::Koha::xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location);
404
        my $ccode          = xml_escape($item->ccode    && exists $ccodes->{$item->ccode}            ? $ccodes->{$item->ccode}            : $item->ccode);
402
        my $ccode          = C4::Koha::xml_escape($item->ccode    && exists $ccodes->{$item->ccode}            ? $ccodes->{$item->ccode}            : $item->ccode);
405
        my $itemcallnumber = xml_escape($item->itemcallnumber);
403
        my $itemcallnumber = C4::Koha::xml_escape($item->itemcallnumber);
406
        my $stocknumber    = xml_escape($item->stocknumber);
404
        my $stocknumber    = C4::Koha::xml_escape($item->stocknumber);
407
        $xml .=
405
        $xml .=
408
            "<item>"
406
            "<item>"
409
          . "<homebranch>$homebranch</homebranch>"
407
          . "<homebranch>$homebranch</homebranch>"
(-)a/Koha/Biblio.pm (-6 / +2 lines)
Lines 24-30 use URI; Link Here
24
use URI::Escape qw( uri_escape_utf8 );
24
use URI::Escape qw( uri_escape_utf8 );
25
25
26
use C4::Koha qw( GetNormalizedISBN );
26
use C4::Koha qw( GetNormalizedISBN );
27
use C4::XSLT qw( XSLTParse4Display );
27
use C4::XSLT qw( transformMARCXML4XSLT );
28
28
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils qw( dt_from_string );
30
use Koha::DateUtils qw( dt_from_string );
Lines 831-841 sub get_marc_notes { Link Here
831
    my %hiddenlist = map { $_ => 1 }
831
    my %hiddenlist = map { $_ => 1 }
832
        split( /,/, C4::Context->preference('NotesToHide'));
832
        split( /,/, C4::Context->preference('NotesToHide'));
833
    my $record = $self->metadata->record;
833
    my $record = $self->metadata->record;
834
834
    $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac );
835
    my $xslfile = C4::Context->preference('XSLTDetailsDisplay') || 'default';
836
    my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
837
    my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
838
    XSLTParse4Display( $self->biblionumber, $record, "XSLTDetailsDisplay", 1, undef, $sysxml, $xslfile, $lang, undef );
839
835
840
    foreach my $field ( $record->field($scope) ) {
836
    foreach my $field ( $record->field($scope) ) {
841
        my $tag = $field->tag();
837
        my $tag = $field->tag();
(-)a/t/db_dependent/Koha/Biblio.t (-4 / +19 lines)
Lines 22-27 use Test::More tests => 14; Link Here
22
use C4::Biblio qw( AddBiblio ModBiblio );
22
use C4::Biblio qw( AddBiblio ModBiblio );
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::Acquisition::Orders;
24
use Koha::Acquisition::Orders;
25
use Koha::AuthorisedValueCategories;
26
use Koha::AuthorisedValues;
27
use Koha::MarcSubfieldStructures;
25
28
26
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
27
use t::lib::Mocks;
30
use t::lib::Mocks;
Lines 580-586 subtest 'subscriptions() tests' => sub { Link Here
580
};
583
};
581
584
582
subtest 'get_marc_notes() MARC21 tests' => sub {
585
subtest 'get_marc_notes() MARC21 tests' => sub {
583
    plan tests => 11;
586
    plan tests => 13;
584
587
585
    $schema->storage->txn_begin;
588
    $schema->storage->txn_begin;
586
589
Lines 594-615 subtest 'get_marc_notes() MARC21 tests' => sub { Link Here
594
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
597
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
595
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
598
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
596
        MARC::Field->new( '541', '', '', a => 'Note5' ),
599
        MARC::Field->new( '541', '', '', a => 'Note5' ),
600
        MARC::Field->new( '590', '', '', a => 'CODE' ),
597
    );
601
    );
602
603
    Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
604
    Koha::AuthorisedValue->new({ category => 'TEST', authorised_value => 'CODE', lib => 'Description should show', lib_opac => 'Description should show OPAC' })->store;
605
    my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
606
    $mss->update({ authorised_value => "TEST" });
607
598
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
608
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
599
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
609
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
610
600
    my $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' });
611
    my $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' });
601
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
612
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
602
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
613
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
603
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
614
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
604
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" );
615
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" );
605
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
616
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
606
    is( @$notes, 5, 'No more notes' );
617
    is( @$notes, 6, 'No more notes' );
607
    $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21', opac => 1 });
618
    $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21', opac => 1 });
608
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
619
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
609
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
620
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
610
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
621
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
611
    is( $notes->[3]->{marcnote}, 'Note5', 'Fifth note shows after fourth skipped' );
622
    is( $notes->[3]->{marcnote}, 'Note5', 'Fifth note shows after fourth skipped' );
612
    is( @$notes, 4, 'No more notes' );
623
    is( @$notes, 5, 'No more notes' );
624
625
    $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' });
626
    is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' );
627
    $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21', opac => 1 });
628
    is( $notes->[4]->{marcnote}, 'Description should show OPAC', 'Authorised value is correctly parsed for OPAC to show description rather than code' );
613
629
614
    $schema->storage->txn_rollback;
630
    $schema->storage->txn_rollback;
615
};
631
};
616
- 

Return to bug 28734