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 OPACBaseURL => C4::Context->preference('OPACBaseURL'),
45 CHANNELTITLE => $channel{'title'},
46 CHANNELLINK => $channel{'link'},
47 CHANNELDESC => $channel{'desc'},
48 CHANNELLANG => $channel{'lang'},
49 CHANNELLASTBUILD => getDate(),
51 IMAGETITLE => $image{'title'},
52 IMAGEURL => $image{'url'},
53 IMAGELINK => $image{'link'},
54 IMAGEDESCRIPTION => $image{'description'},
55 IMAGEWIDTH => $image{'width'},
56 IMAGEHEIGHT => $image{'height'},
58 ITEMS => getItems( $config{'query'} )
61 my $template_path = $config{"template"};
62 open( my $fh, "<", $template_path ) or die "cannot open $template_path : $!";
63 $feed->process( $fh, $vars, $outFile );
66 my $date = strftime( "%a, %d %b %Y %T %Z", localtime );
75 open( FILE, $file ) or die "can't open $file";
78 my @line = split( /=/, $_, 2 );
83 my ( $key, $value ) = @line;
85 $return{$key} = $value;
89 if ( $_ eq "$section\n" ) { $inSection = 1 }
98 $query .= " limit 15";
99 my $sth = $dbh->prepare($query);
102 while ( my $data = $sth->fetchrow_hashref ) {
103 foreach my $key ( keys %$data ) {
104 my $value = $data->{$key};
105 $value = '' unless defined $value;
106 $value =~ s/\&/\&/g and $data->{$key} = $value;