--- loncom/interface/lonrss.pm 2006/03/23 22:32:11 1.13
+++ loncom/interface/lonrss.pm 2006/04/13 18:12:49 1.16
@@ -1,7 +1,7 @@
# The LearningOnline Network
# RSS Feeder
#
-# $Id: lonrss.pm,v 1.13 2006/03/23 22:32:11 albertel Exp $
+# $Id: lonrss.pm,v 1.16 2006/04/13 18:12:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,10 +36,13 @@ use Apache::lontexconvert;
use Apache::lonlocal;
use Apache::lonhtmlcommon;
+
sub filterfeedname {
my $filename=shift;
$filename=~s/(\_rss\.html|\.rss)$//;
$filename=~s/\W//g;
+ $filename=~s/\_rssfeed$//;
+ $filename=~s/^nohist\_//;
return $filename;
}
@@ -83,7 +86,7 @@ sub advertisefeeds {
}
foreach my $feed (sort(keys(%feednames))) {
if ($feed!~/^error\:/) {
- my $feedurl='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
+ my $feedurl='http://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
$feeds.='
'.$feednames{$feed}.
'
'.($edit?&mt('Edit'):'HTML').': '.$htmlurl.''.
@@ -100,20 +103,26 @@ sub advertisefeeds {
sub rss_link {
my ($url) = @_;
return qq||;
-
}
{
my $feedcounter;
- sub addentry {
+ sub get_new_feed_id {
$feedcounter++;
- my $id=time.'00000'.$$.'00000'.$feedcounter;
- return &editentry($id,@_);
+ return time().'00000'.$$.'00000'.$feedcounter;
}
}
+sub addentry {
+ my $id=&get_new_feed_id();
+ return &editentry($id,@_);
+}
+
sub editentry {
my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enclength,$enctype)=@_;
+ if ($status eq 'deleted') {
+ return &changestatus($id,$uname,$udom,$filename,$status);
+ }
my $feedname=&feedname($filename);
&Apache::lonnet::put('nohist_all_rss_feeds',
{ &filterfeedname($filename) => &displayfeedname($filename,$uname,$udom) },
@@ -186,7 +195,6 @@ sub handler {
'force_register' =>
$env{'form.register'}}).
&changed_js());
-
} else {
$r->print("\n".
"\nhttp://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.
@@ -195,6 +203,23 @@ sub handler {
&mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').
'');
}
+# Do we have stuff to store?
+ if ($edit) {
+ my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
+ foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
+ if ($entry=~/^(\d+)\_status$/) {
+ my $id=$1;
+ if ($env{'form.'.$id.'_modified'}) {
+ &editentry($id,$uname,$udom,$feedname,
+ $env{'form.'.$id.'_title'},
+ $env{'form.'.$id.'_description'},
+ $env{'form.'.$id.'_url'},
+ $env{'form.'.$id.'_status'});
+ }
+ }
+ }
+ }
+ my $newid = &get_new_feed_id();
# Is this user for real?
my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
if ($html) {
@@ -225,7 +250,7 @@ sub handler {
}
# Get feed items
my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
- foreach my $entry (sort(keys(%newsfeed))) {
+ foreach my $entry (sort(keys(%newsfeed)),$newid.'_status') {
if ($entry=~/^(\d+)\_status$/) {
my $id=$1;
if ($edit) {
@@ -235,10 +260,11 @@ sub handler {
'delete' => 'delete',
'store' => 'Store changes');
my %status=();
+ unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }
$status{$newsfeed{$id.'_status'}}='checked="checked"';
$r->print(<
-
+
@@ -246,7 +272,7 @@ sub handler {
-
+
@@ -277,7 +303,7 @@ ENDEDIT
}
}
}
- $r->print("\n".($html?''.($edit?'':'').&Apache::loncommon::end_page():''."\n"));
+ $r->print("\n".($html?''.($edit?'':'').&Apache::loncommon::end_page():''."\n"));
return OK;
}
1;