moving language chooser to the main page.
[koha.git] / opac / opac-main.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5 use HTML::Template;
6
7 use C4::Auth;       # get_template_and_user
8 use C4::Interface::CGI::Output;
9 use C4::BookShelves;
10 use C4::Koha;
11
12 my $input = new CGI;
13 my $dbh = C4::Context->dbh;
14 my $query="Select itemtype,description from itemtypes order by description";
15 my $sth=$dbh->prepare($query);
16 $sth->execute;
17 my  @itemtype;
18 my %itemtypes;
19 while (my ($value,$lib) = $sth->fetchrow_array) {
20         push @itemtype, $value;
21         $itemtypes{$value}=$lib;
22 }
23
24 my $CGIitemtype=CGI::scrolling_list( -name     => 'itemtype',
25                         -values   => \@itemtype,
26                         -labels   => \%itemtypes,
27                         -size     => 1,
28                         -multiple => 0 );
29 $sth->finish;
30
31 my ($template, $borrowernumber, $cookie)
32     = get_template_and_user({template_name => "opac-main.tmpl",
33                              type => "opac",
34                              query => $input,
35                              authnotrequired => 1,
36                              flagsrequired => {borrow => 1},
37                          });
38 my @options;
39 my $counter=0;
40 foreach my $language (getalllanguages()) {
41         next if $language eq 'images';
42         my $selected='0';
43 #                            next if $currently_selected_languages->{$language};
44         push @options, { language => $language, counter => $counter };
45         $counter++;
46 }
47
48 $template->param(CGIitemtype => $CGIitemtype,
49                                 suggestion => C4::Context->preference("suggestion"),
50                                 virtualshelves => C4::Context->preference("virtualshelves"),
51                                 languages => \@options,
52 );
53 output_html_with_http_headers $input, $cookie, $template->output;