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
12 # This file is part of Koha.
14 # Koha is free software; you can redistribute it and/or modify it under the
15 # terms of the GNU General Public License as published by the Free Software
16 # Foundation; either version 2 of the License, or (at your option) any later
19 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License along
24 # with Koha; if not, write to the Free Software Foundation, Inc.,
25 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 use HTML::Template::Pro;
35 my $dbh = C4::Context->dbh;
37 my %config = getConf("config");
38 my $outFile = $config{"output"};
39 my $feed = HTML::Template::Pro->new( filename => $config{"tmpl"} );
41 my %channel = getConf("channel");
42 $feed->param( CHANNELTITLE => $channel{'title'} );
43 $feed->param( CHANNELLINK => $channel{'link'} );
44 $feed->param( CHANNELDESC => $channel{'desc'} );
45 $feed->param( CHANNELLANG => $channel{'lang'} );
46 $feed->param( CHANNELLASTBUILD => getDate() );
48 my %image = getConf("image");
49 $feed->param( IMAGETITLE => $image{'title'} );
50 $feed->param( IMAGEURL => $image{'url'} );
51 $feed->param( IMAGELINK => $image{'link'} );
52 $feed->param( IMAGEDESCRIPTION => $image{'description'} );
53 $feed->param( IMAGEWIDTH => $image{'width'} );
54 $feed->param( IMAGEHEIGHT => $image{'height'} );
59 $feed->param( ITEMS => getItems( $config{'query'} ) );
61 open( FILE, ">$outFile" ) or die "can't open $outFile";
62 print FILE $feed->output();
67 # my $date = localtime(timelocal(localtime));
68 my $date = strftime( "%a, %d %b %Y %T %Z", localtime );
77 open( FILE, $file ) or die "can't open $file";
80 my @line = split( /=/, $_, 2 );
84 my ( $key, $value ) = @line;
86 $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;