Koha/opac/opac-tags_subject.pl
Jonathan Druart 091d6c513b Bug 17843: Replace C4::Koha::getitemtypeinfo with Koha::ItemTypes
The C4::Koha::getitemtypeinfo subroutine did the almost same job as
GetItemTypes. On top of that it returned the imageurl value processed by
C4::Koha::getitemtypeimagelocation.
This value is only used from the 2 [opac-]shelves.pl scripts. Then it's
better not retrieve it only when we need it.

Test plan:
Play with the different scripts touched by this patch and focus on item
types. The same description as prior to this patch must be displayed.
Note that sometimes it is not the translated description which is
displayed, but that should be fixed on another bug report. Indeed we do
not expect this patch to change any behaviors.

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
2017-07-05 13:42:21 -03:00

80 lines
1.9 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
=head1 opac-tags_subject.pl
TODO :: Description here
=cut
use strict;
use warnings;
use C4::Auth;
use C4::Context;
use C4::Output;
use CGI qw ( -utf8 );
use C4::Biblio;
my $query = new CGI;
my $dbh = C4::Context->dbh;
# open template
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "opac-tags_subject.tt",
query => $query,
type => "opac",
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
debug => 1,
}
);
my $number = $query->param('number') || 100;
my $sth = $dbh->prepare("SELECT entry,weight FROM tags ORDER BY weight DESC LIMIT ?");
$sth->execute($number);
my %result;
my $max=0;
my $min=9999;
my ($entry,$weight);
while (($entry,$weight) = $sth->fetchrow) {
$result{$entry}=$weight;
$max = $weight if $weight > $max;
$min = $weight if $weight < $min;
}
$min++ if $min == $max;
my @loop;
foreach my $entry (sort keys %result) {
my %line;
$line{entry} = $entry;
$line{weight} = int(($result{$entry}-$min)/($max-$min)*25)+10;
push @loop, \%line;
}
$template->param(
LOOP => \@loop,
number => $number
);
output_html_with_http_headers $query, $cookie, $template->output;