--- loncom/interface/lonrss.pm 2006/03/15 21:43:20 1.8 +++ loncom/interface/lonrss.pm 2006/04/13 17:57:17 1.15 @@ -1,7 +1,7 @@ # The LearningOnline Network # RSS Feeder # -# $Id: lonrss.pm,v 1.8 2006/03/15 21:43:20 albertel Exp $ +# $Id: lonrss.pm,v 1.15 2006/04/13 17:57:17 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,10 +36,14 @@ use Apache::lontexconvert; use Apache::lonlocal; use Apache::lonhtmlcommon; +my $feedcounter; + sub filterfeedname { my $filename=shift; $filename=~s/(\_rss\.html|\.rss)$//; $filename=~s/\W//g; + $filename=~s/\_rssfeed$//; + $filename=~s/^nohist\_//; return $filename; } @@ -74,7 +78,6 @@ sub renamefeed { } sub advertisefeeds { - return; my ($uname,$udom,$edit)=@_; my $feeds=''; my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname); @@ -84,7 +87,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.''. @@ -98,17 +101,22 @@ sub advertisefeeds { } } -{ - my $feedcounter; - sub addentry { - $feedcounter++; - my $id=time.'00000'.$$.'00000'.$feedcounter; - return &editentry($id,@_); - } +sub rss_link { + my ($url) = @_; + return qq||; +} + +sub addentry { + $feedcounter++; + my $id=time.'00000'.$$.'00000'.$feedcounter; + 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) }, @@ -140,14 +148,13 @@ sub changestatus { } sub changed_js { - return < function changed(tform,id) { tform.elements[id+"_modified"].checked=true; } -ENDSCRIPT +ENDSCRIPT } sub handler { @@ -177,12 +184,11 @@ sub handler { my $feedname=&feedname($filename); my $displayfeedname=&displayfeedname($filename,$uname,$udom); if ($html) { - $r->print(&Apache::lonxml::xmlbegin(). - &Apache::loncommon::head($displayfeedname). - &Apache::loncommon::bodytag($displayfeedname,'','','',$udom, - $env{'form.register'}). + $r->print(&Apache::loncommon::start_page($displayfeedname,undef, + {'domain' => $udom, + 'force_register' => + $env{'form.register'}}). &changed_js()); - } else { $r->print("\n". "\nhttp://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'. @@ -191,6 +197,24 @@ 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'}); + } + } + } + } + $feedcounter++; + my $newid=time.'00000'.$$.'00000'.$feedcounter; # Is this user for real? my $homeserver=&Apache::lonnet::homeserver($uname,$udom); if ($html) { @@ -221,7 +245,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) { @@ -231,10 +255,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(< - +       @@ -242,7 +267,7 @@ sub handler {       - +


    @@ -273,7 +298,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;