Limit the number of page index icons that are displayed to 15 maximum.
[koha.git] / detail.pl
1 #!/usr/bin/perl
2 use HTML::Template;
3 use strict;
4 require Exporter;
5 use C4::Database;
6 use C4::Output;  # contains picktemplate
7 use CGI;
8 use C4::Search;
9 use C4::Auth;
10  
11 my $query=new CGI;
12 my $type=$query->param('type');
13 (-e "opac") && ($type='opac');
14 ($type) || ($type='intra');
15 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
16
17
18 my $language='french';
19
20
21 my %configfile;
22 open (KC, "/etc/koha.conf");
23 while (<KC>) {
24  chomp;
25  (next) if (/^\s*#/);
26  if (/(.*)\s*=\s*(.*)/) {
27    my $variable=$1;
28    my $value=$2;
29    # Clean up white space at beginning and end
30    $variable=~s/^\s*//g;
31    $variable=~s/\s*$//g;
32    $value=~s/^\s*//g;
33    $value=~s/\s*$//g;
34    $configfile{$variable}=$value;
35  }
36 }
37
38 my $biblionumber=$query->param('bib');
39
40
41 # change back when ive fixed request.pl
42 my @items = ItemInfo(undef, $biblionumber, $type);
43 my $dat=bibdata($biblionumber);
44 my ($authorcount, $addauthor)= &addauthor($biblionumber);
45 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
46 my ($websitecount, @websites)             = &getwebsites($biblionumber);
47
48 $dat->{'count'}=@items;
49
50 $dat->{'additional'}=$addauthor->[0]->{'author'};
51 for (my $i = 1; $i < $authorcount; $i++) {
52         $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
53 } # for
54
55 my @results;
56
57 $results[0]=$dat;
58
59 my $resultsarray=\@results;
60 my $itemsarray=\@items;
61 my $webarray=\@webbiblioitems;
62 my $sitearray=\@websites;
63
64 my $includes=$configfile{'includes'};
65 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
66 my $templatebase="catalogue/detail.tmpl";
67 ($type eq 'opac') && ($templatebase="catalogue/detail-opac.tmpl");
68 my $startfrom=$query->param('startfrom');
69 ($startfrom) || ($startfrom=0);
70 my $theme=picktemplate($includes, $templatebase);
71
72 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
73
74 my $count=1;
75
76 # now to get the items into a hash we can use and whack that thru
77
78
79 $template->param(startfrom => $startfrom+1);
80 $template->param(endat => $startfrom+20);
81 $template->param(numrecords => $count);
82 my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
83 my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
84 $template->param(nextstartfrom => $nextstartfrom);
85 $template->param(prevstartfrom => $prevstartfrom);
86 # $template->param(template => $templatename);
87 # $template->param(search => $search);
88 $template->param(includesdir => $includes);
89 $template->param(BIBLIO_RESULTS => $resultsarray);
90 $template->param(ITEM_RESULTS => $itemsarray);
91 $template->param(WEB_RESULTS => $webarray);
92 $template->param(SITE_RESULTS => $sitearray);
93 $template->param(loggedinuser => $loggedinuser);
94 print $query->header(-cookie => $cookie), $template->output;
95