3 # This script can be used to generate rss 0.91 files for syndication.
5 # it should be run from cron like:
10 # Copyright 2003 Katipo Communications
11 # Copyright 2014 ByWater Solutions
13 # This file is part of Koha.
15 # Koha is free software; you can redistribute it and/or modify it under the
16 # terms of the GNU General Public License as published by the Free Software
17 # Foundation; either version 3 of the License, or (at your option) any later
20 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
21 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
22 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License along
25 # with Koha; if not, write to the Free Software Foundation, Inc.,
26 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 my $dbh = C4::Context->dbh;
37 my %config = getConf("config");
38 my $outFile = $config{"output"};
39 my $feed = Template->new();
41 my %channel = getConf("channel");
42 my %image = getConf("image");
44 CHANNELTITLE => $channel{'title'},
45 CHANNELLINK => $channel{'link'},
46 CHANNELDESC => $channel{'desc'},
47 CHANNELLANG => $channel{'lang'},
48 CHANNELLASTBUILD => getDate(),
50 IMAGETITLE => $image{'title'},
51 IMAGEURL => $image{'url'},
52 IMAGELINK => $image{'link'},
53 IMAGEDESCRIPTION => $image{'description'},
54 IMAGEWIDTH => $image{'width'},
55 IMAGEHEIGHT => $image{'height'},
57 ITEMS => getItems( $config{'query'} )
60 my $template_path = $config{"template"};
61 open( my $fh, "<", $template_path ) or die "cannot open $template_path : $!";
62 $feed->process( $fh, $vars, $outFile );
65 my $date = strftime( "%a, %d %b %Y %T %Z", localtime );
74 open( FILE, $file ) or die "can't open $file";
77 my @line = split( /=/, $_, 2 );
82 my ( $key, $value ) = @line;
84 $return{$key} = $value;
88 if ( $_ eq "$section\n" ) { $inSection = 1 }
97 $query .= " limit 15";
98 my $sth = $dbh->prepare($query);
101 while ( my $data = $sth->fetchrow_hashref ) {
102 foreach my $key ( keys %$data ) {
103 my $value = $data->{$key};
104 $value = '' unless defined $value;
105 $value =~ s/\&/\&/g and $data->{$key} = $value;