bug 1890: fixing calls to C4::Search::SimpleSearch
[koha_gimpoz] / opac / opac-rss.pl
index c7b463e..d73a6cb 100755 (executable)
@@ -72,7 +72,8 @@ my $size = $cgi->param('size') || 50;
 
 # the filename of the cached rdf file.
 my $filename = md5_base64($query);
-my $rss = new XML::RSS( version => '1.0' );
+$filename =~ s/\///g;
+my $rss = new XML::RSS( version => '1.0', encoding=>C4::Context->preference("TemplateEncoding"), output=>C4::Context->preference("TemplateEncoding"),language=>C4::Context->preference('opaclanguages'));
 
 # the site URL
 my $url = $cgi->url();
@@ -88,11 +89,8 @@ if ( -e "rss/$filename" ) {
 
 # check if we have to rebuild the RSS feed (once every 30mn), or just return the actual rdf
     my $rdf_stamp = $rss->{'channel'}->{'dc'}->{'date'};
-    $rdf_stamp =~ /(.*)-(.*)-(.*):(.*):(.*):(.*)/;
-    my (
-        $stamp_year, $stamp_month, $stamp_day,
-        $stamp_hour, $stamp_min,   $stamp_sec
-    ) = ( $1, $2, $3, $4, $5, $6 );
+    my ( $stamp_year, $stamp_month, $stamp_day, $stamp_hour, $stamp_min, $stamp_sec ) =
+       ( $rdf_stamp =~ /(.*)-(.*)-(.*):(.*):(.*):(.*)/ );
 
 # if more than 30 mn since the last RDF update, rebuild the RDF. Otherwise, just return it
     unless ( ( $year - $stamp_year > 0 )
@@ -108,24 +106,25 @@ if ( -e "rss/$filename" ) {
 if ($RDF_update_needed) {
 
     #     warn "RDF update in progress";
+    utf8::decode($query);
+    my $libname = C4::Context->preference("LibraryName");
     $rss->channel(
-        title       => "Koha : $query",
-        description => C4::Context->preference("LibraryName"),
+        title       => "Koha: $query",
+        description => $libname,
         link        => $short_url,
         dc          => {
             date     => "$year-$month-$day:$hour:$min:$sec",
             subject  => "Koha",
-            creator  => C4::Context->preference("LibraryName"),
+            creator  => $libname,
             rights   => "Copyright $year",
             language => C4::Context->preference("opaclanguages"),
         },
     );
 
-    my $total;    # the total results for the whole set
-    my ( $error, $marcresults ) = SimpleSearch($query);
+    warn "fetching $size results for $query";
+    my ( $error, $marcresults ) = SimpleSearch( $query, 0, $size );
 
     my $hits = scalar @$marcresults;
-    $hits = $size if $hits > $size;
     my @results;
     for ( my $i = 0 ; $i < $hits ; $i++ ) {
         my %resultsloop;
@@ -141,6 +140,8 @@ if ($RDF_update_needed) {
         }
         unless ($already_in_feed) {
             pop( @{ $rss->{'items'} } ) if ( @{ $rss->{'items'} } >= $size );
+            utf8::decode($biblio->{'title'});
+            utf8::decode($biblio->{'author'});
             $rss->add_item(
                 title       => $biblio->{'title'},
                 description => $biblio->{'author'},