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

(-)a/C4/Koha.pm (-40 lines)
Lines 41-47 BEGIN { Link Here
41
	@ISA    = qw(Exporter);
41
	@ISA    = qw(Exporter);
42
	@EXPORT = qw(
42
	@EXPORT = qw(
43
        &GetPrinters &GetPrinter
43
        &GetPrinters &GetPrinter
44
        &getitemtypeinfo
45
        &GetItemTypesCategorized
44
        &GetItemTypesCategorized
46
        &getallthemes
45
        &getallthemes
47
        &getFacets
46
        &getFacets
Lines 123-167 sub GetItemTypesCategorized { Link Here
123
return ($dbh->selectall_hashref($query,'itemtype'));
122
return ($dbh->selectall_hashref($query,'itemtype'));
124
}
123
}
125
124
126
=head2 getitemtypeinfo
127
128
  $itemtype = &getitemtypeinfo($itemtype, [$interface]);
129
130
Returns information about an itemtype. The optional $interface argument
131
sets which interface ('opac' or 'intranet') to return the imageurl for.
132
Defaults to intranet.
133
134
=cut
135
136
sub getitemtypeinfo {
137
    my ($itemtype, $interface) = @_;
138
    my $dbh      = C4::Context->dbh;
139
    require C4::Languages;
140
    my $language = C4::Languages::getlanguage();
141
    my $it = $dbh->selectrow_hashref(q|
142
        SELECT
143
               itemtypes.itemtype,
144
               itemtypes.description,
145
               itemtypes.rentalcharge,
146
               itemtypes.notforloan,
147
               itemtypes.imageurl,
148
               itemtypes.summary,
149
               itemtypes.checkinmsg,
150
               itemtypes.checkinmsgtype,
151
               itemtypes.sip_media_type,
152
               COALESCE( localization.translation, itemtypes.description ) AS translated_description
153
        FROM   itemtypes
154
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
155
            AND localization.entity = 'itemtypes'
156
            AND localization.lang = ?
157
        WHERE itemtypes.itemtype = ?
158
    |, undef, $language, $itemtype );
159
160
    $it->{imageurl} = getitemtypeimagelocation( ( ( defined $interface && $interface eq 'opac' ) ? 'opac' : 'intranet' ), $it->{imageurl} );
161
162
    return $it;
163
}
164
165
=head2 getitemtypeimagedir
125
=head2 getitemtypeimagedir
166
126
167
  my $directory = getitemtypeimagedir( 'opac' );
127
  my $directory = getitemtypeimagedir( 'opac' );
(-)a/t/db_dependent/Koha.t (-8 / +1 lines)
Lines 9-15 use Koha::DateUtils qw(dt_from_string); Link Here
9
use Koha::AuthorisedValue;
9
use Koha::AuthorisedValue;
10
use Koha::AuthorisedValueCategories;
10
use Koha::AuthorisedValueCategories;
11
11
12
use Test::More tests => 7;
12
use Test::More tests => 6;
13
use DateTime::Format::MySQL;
13
use DateTime::Format::MySQL;
14
14
15
BEGIN {
15
BEGIN {
Lines 151-162 subtest 'Authorized Values Tests' => sub { Link Here
151
151
152
};
152
};
153
153
154
subtest 'Itemtype info Tests' => sub {
155
    like ( getitemtypeinfo('BK')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
156
    like ( getitemtypeinfo('BK', 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
157
    like ( getitemtypeinfo('BK', 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
158
};
159
160
### test for C4::Koha->GetDailyQuote()
154
### test for C4::Koha->GetDailyQuote()
161
SKIP:
155
SKIP:
162
    {
156
    {
163
- 

Return to bug 17843