1 package Packages::DoIndex;
10 use Packages::Config qw( $TOPDIR );
11 use Packages::I18N::Locale;
14 our @ISA = qw( Exporter );
15 our @EXPORT = qw( do_index );
18 my ($params, $opts, $html_header) = @_;
20 if ($params->{errors}{suite}) {
21 fatal_error( _g( "suite not valid or not specified" ) );
23 if (@{$opts->{suite}} > 1) {
24 fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
26 if (@{$opts->{subsection}} > 1) {
27 fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
30 my $wwwdir = "$TOPDIR/www";
31 my $path = "$opts->{suite}[0]/";
32 $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
33 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
34 # we don't have translated index pages for subsections yet
35 $opts->{lang} = 'en' if @{$opts->{subsection}};
36 $path .= "index.$opts->{lang}.html";
38 unless (@Packages::CGI::fatal_errors) {
40 if (open( INDEX, '<', "$wwwdir/$path" )) {
41 my $charset = get_charset( $opts->{lang} );
42 print header( -charset => $charset );
45 while (read INDEX, $buffer, 4096) {
51 fatal_error( sprintf( _g( "couldn't read index file %s: %s" ),
56 %$html_header = ( title => _g('Error'),
57 lang => $opts->{lang},
59 print_search_field => 'packages',
60 search_field_values => {
61 keywords => _g('search for a package'),
62 searchon => 'default',
67 debug => $Packages::Search::debug,