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
16 # under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 3 of the License, or
18 # (at your option) any later version.
20 # Koha is distributed in the hope that it will be useful, but
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with Koha; if not, see <http://www.gnu.org/licenses>.
32 use Koha::Script -cron;
34 use POSIX qw( close localtime open strftime );
36 my $dbh = C4::Context->dbh;
38 my %config = getConf("config");
39 my $outFile = $config{"output"};
40 my $feed = Template->new();
42 my %channel = getConf("channel");
43 my %image = getConf("image");
45 OPACBaseURL => C4::Context->preference('OPACBaseURL'),
46 CHANNELTITLE => $channel{'title'},
47 CHANNELLINK => $channel{'link'},
48 CHANNELDESC => $channel{'desc'},
49 CHANNELLANG => $channel{'lang'},
50 CHANNELLASTBUILD => getDate(),
52 IMAGETITLE => $image{'title'},
53 IMAGEURL => $image{'url'},
54 IMAGELINK => $image{'link'},
55 IMAGEDESCRIPTION => $image{'description'},
56 IMAGEWIDTH => $image{'width'},
57 IMAGEHEIGHT => $image{'height'},
59 ITEMS => getItems( $config{'query'} )
62 my $template_path = $config{"template"};
63 open( my $fh, "<", $template_path ) or die "cannot open $template_path : $!";
64 $feed->process( $fh, $vars, $outFile );
67 my $date = strftime( "%a, %d %b %Y %T %Z", localtime );
76 open( my $fh, '<', $file ) or die "can't open $file";
79 my @line = split( /=/, $_, 2 );
84 my ( $key, $value ) = @line;
86 $return{$key} = $value;
90 if ( $_ eq "$section\n" ) { $inSection = 1 }
99 $query .= " limit 15";
100 my $sth = $dbh->prepare($query);
103 while ( my $data = $sth->fetchrow_hashref ) {
104 foreach my $key ( keys %$data ) {
105 my $value = $data->{$key};
106 $value = '' unless defined $value;
107 $value =~ s/\&/\&/g and $data->{$key} = $value;