+ my (%results,%archs);
+ foreach my $result (sort { $a->[0] cmp $b->[0] } @results) {
+ my $file = shift @$result;
+ my %pkgs;
+ foreach (@$result) {
+ my ($pkg, $arch) = split /:/, $_;
+ next unless $opts->{h_archs}{$arch};
+ $pkgs{$pkg}{$arch}++;
+ $archs{$arch}++ unless $arch eq 'all';
+ }
+ next unless keys %pkgs;
+ $results{$file} = \%pkgs;
+ }
+ my @all_archs = keys %archs;
+ @all_archs = @ARCHITECTURES unless @all_archs;
+ debug( "all_archs = @all_archs", 1 ) if DEBUG;
+ msg(_g("Limit search to a specific architecture:")." ".
+ join( ' ', map { '[<a href="'.make_search_url('',"keywords=$keyword_esc",{arch=>$_}).
+ "\">$_</a>]" } @all_archs ) )
+ unless (@{$opts->{arch}} == 1) || (@all_archs == 1);
+ msg(sprintf(_g('Search in <a href="%s">all architectures</a>'),
+ make_search_url('',"keywords=$keyword_esc",{arch=>undef})))
+ if @{$opts->{arch}} == 1;
+
+ if (!@Packages::CGI::fatal_errors && !keys(%results)) {
+ error( _g( "Nothing found" ) );
+ }
+
+ if (keys %results) {
+ $$page_content .= "<p>".sprintf( _g( 'Found %s results' ),
+ scalar keys %results )."</p>";
+ $$page_content .= '<div
+ id="pcontentsres"><table><colgroup><col><col></colgroup><tr><th>'._g('File').'</th><th>'._g('Packages')
+ ."</th></tr>\n";
+ foreach my $file (sort keys %results) {
+ my $file_enc = encode_entities($file);
+ foreach my $kw (@{$opts->{keywords}}) {
+ my $kw_enc = encode_entities($kw);
+ $file_enc =~ s#(\Q$kw_enc\E)#<span class="keyword">$1</span>#g;
+ }
+ $$page_content .= "<tr><td class=\"file\">/$file_enc</td><td>";
+ my @pkgs;
+ foreach my $pkg (sort keys %{$results{$file}}) {
+ my $arch_str = '';
+ my @archs = keys %{$results{$file}{$pkg}};
+ unless ($results{$file}{$pkg}{all} ||
+ (@archs == @all_archs)) {
+ if (@archs < @all_archs/2) {
+ $arch_str = ' ['.join(' ',sort @archs).']';
+ } else {
+ $arch_str = ' ['._g('not').' '.
+ join(' ', grep { !$results{$file}{$pkg}{$_} } @all_archs).']';
+ }
+ }
+ push @pkgs, "<a href=\"".make_url($pkg,'',{suite=>$suite})."\">$pkg</a>$arch_str";