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

(-)a/C4/Koha.pm (-4 / +6 lines)
Lines 419-438 sub getframeworkinfo { Link Here
419
419
420
=head2 getitemtypeinfo
420
=head2 getitemtypeinfo
421
421
422
  $itemtype = &getitemtype($itemtype);
422
  $itemtype = &getitemtypeinfo($itemtype, [$interface]);
423
423
424
Returns information about an itemtype.
424
Returns information about an itemtype. The optional $interface argument
425
sets which interface ('opac' or 'intranet') to return the imageurl for.
426
Defaults to intranet.
425
427
426
=cut
428
=cut
427
429
428
sub getitemtypeinfo {
430
sub getitemtypeinfo {
429
    my ($itemtype) = @_;
431
    my ($itemtype, $interface) = @_;
430
    my $dbh        = C4::Context->dbh;
432
    my $dbh        = C4::Context->dbh;
431
    my $sth        = $dbh->prepare("select * from itemtypes where itemtype=?");
433
    my $sth        = $dbh->prepare("select * from itemtypes where itemtype=?");
432
    $sth->execute($itemtype);
434
    $sth->execute($itemtype);
433
    my $res = $sth->fetchrow_hashref;
435
    my $res = $sth->fetchrow_hashref;
434
436
435
    $res->{imageurl} = getitemtypeimagelocation( 'intranet', $res->{imageurl} );
437
    $res->{imageurl} = getitemtypeimagelocation( ( ( defined $interface && $interface eq 'opac' ) ? 'opac' : 'intranet' ), $res->{imageurl} );
436
438
437
    return $res;
439
    return $res;
438
}
440
}
(-)a/C4/VirtualShelves/Page.pm (-1 / +1 lines)
Lines 271-277 sub shelfpage { Link Here
271
                    #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
271
                    #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
272
                    #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
272
                    #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
273
                    $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
273
                    $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
274
                    $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'} )->{'imageurl'};
274
                    $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'};
275
                    $this_item->{'coins'}     = GetCOinSBiblio( $record );
275
                    $this_item->{'coins'}     = GetCOinSBiblio( $record );
276
                    $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
276
                    $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
277
                    $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
277
                    $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
(-)a/t/db_dependent/Koha.t (-2 / +7 lines)
Lines 7-13 use strict; Link Here
7
use warnings;
7
use warnings;
8
use C4::Context;
8
use C4::Context;
9
9
10
use Test::More tests => 8;
10
use Test::More tests => 9;
11
11
12
BEGIN {
12
BEGIN {
13
    use_ok('C4::Koha');
13
    use_ok('C4::Koha');
Lines 55-57 if($insert_success){ Link Here
55
    $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
55
    $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
56
}
56
}
57
57
58
- 
58
subtest 'Itemtype info Tests' => sub {
59
    like ( getitemtypeinfo('BK')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
60
    like ( getitemtypeinfo('BK', 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
61
    like ( getitemtypeinfo('BK', 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
62
};
63

Return to bug 9174