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;
37 my $dbh = C4::Context->dbh;
39 my %config = getConf("config");
40 my $outFile = $config{"output"};
41 my $feed = Template->new();
43 my %channel = getConf("channel");
44 my %image = getConf("image");
46 OPACBaseURL => C4::Context->preference('OPACBaseURL'),
47 CHANNELTITLE => $channel{'title'},
48 CHANNELLINK => $channel{'link'},
49 CHANNELDESC => $channel{'desc'},
50 CHANNELLANG => $channel{'lang'},
51 CHANNELLASTBUILD => getDate(),
53 IMAGETITLE => $image{'title'},
54 IMAGEURL => $image{'url'},
55 IMAGELINK => $image{'link'},
56 IMAGEDESCRIPTION => $image{'description'},
57 IMAGEWIDTH => $image{'width'},
58 IMAGEHEIGHT => $image{'height'},
60 ITEMS => getItems( $config{'query'} )
63 my $template_path = $config{"template"};
64 open( my $fh, "<", $template_path ) or die "cannot open $template_path : $!";
65 $feed->process( $fh, $vars, $outFile );
68 my $date = strftime( "%a, %d %b %Y %T %Z", localtime );
77 open( my $fh, '<', $file ) or die "can't open $file";
80 my @line = split( /=/, $_, 2 );
85 my ( $key, $value ) = @line;
87 $return{$key} = $value;
91 if ( $_ eq "$section\n" ) { $inSection = 1 }
100 $query .= " limit 15";
101 my $sth = $dbh->prepare($query);
104 while ( my $data = $sth->fetchrow_hashref ) {
105 foreach my $key ( keys %$data ) {
106 my $value = $data->{$key};
107 $value = '' unless defined $value;
108 $value =~ s/\&/\&/g and $data->{$key} = $value;