--- loncom/interface/lonrss.pm 2005/11/20 02:12:35 1.5 +++ loncom/interface/lonrss.pm 2006/03/15 21:43:20 1.8 @@ -1,7 +1,7 @@ # The LearningOnline Network # RSS Feeder # -# $Id: lonrss.pm,v 1.5 2005/11/20 02:12:35 www Exp $ +# $Id: lonrss.pm,v 1.8 2006/03/15 21:43:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -74,16 +74,21 @@ sub renamefeed { } sub advertisefeeds { - my ($uname,$udom)=@_; + return; + my ($uname,$udom,$edit)=@_; my $feeds=''; my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname); + my $mode='public'; + if ($edit) { + $mode='adm'; + } foreach my $feed (sort(keys(%feednames))) { if ($feed!~/^error\:/) { my $feedurl='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss'; - my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'_rss.html'; + my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html'; $feeds.='
  • '.$feednames{$feed}. - '
    HTML: '.$htmlurl.''. - '
    RSS: '.$feedurl.'
  • '; + '
    '.($edit?&mt('Edit'):'HTML').': '.$htmlurl.''. + ($edit?'':'
    RSS: '.$feedurl.'').''; } } if ($feeds) { @@ -134,8 +139,19 @@ sub changestatus { } } +sub changed_js { + + return < + function changed(tform,id) { + tform.elements[id+"_modified"].checked=true; + } + +ENDSCRIPT +} + sub handler { - my $r = shift; + my ($r) = @_; my $edit=0; my $html=0; @@ -161,9 +177,12 @@ sub handler { my $feedname=&feedname($filename); my $displayfeedname=&displayfeedname($filename,$uname,$udom); if ($html) { - $r->print(&Apache::lonxml::xmlbegin().&Apache::loncommon::bodytag - ($displayfeedname,'','','',$udom, - $env{'form.register'})); + $r->print(&Apache::lonxml::xmlbegin(). + &Apache::loncommon::head($displayfeedname). + &Apache::loncommon::bodytag($displayfeedname,'','','',$udom, + $env{'form.register'}). + &changed_js()); + } else { $r->print("\n". "\nhttp://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'. @@ -173,7 +192,10 @@ sub handler { ''); } # Is this user for real? - my $homeserver=&Apache::lonnet::homeserver($uname,$udom); + my $homeserver=&Apache::lonnet::homeserver($uname,$udom); + if ($html) { + $r->print(&advertisefeeds($uname,$udom,$edit)); + } if ($homeserver eq 'no_host') { $r->print(($html?'

    ':'').&mt('No feed available').($html?'</h3>':'')); } else { @@ -188,7 +210,10 @@ sub handler { $r->print("\n". ($html?'

    ':''). &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name). - ($html?'</h3>'.($edit?'<form method="post">':'').'<ul>':'')); + ($html?'

    '.($edit?'

    '. + &mt('Name of blog/journal'). + ': ':'').'
      ':'')); # Render private items? my $viewpubliconly=1; if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) { @@ -203,23 +228,26 @@ sub handler { my %lt=&Apache::lonlocal::texthash('public' => 'public', 'private' => 'private', 'hidden' => 'hidden', - 'delete' => 'delete'); + 'delete' => 'delete', + 'store' => 'Store changes'); my %status=(); $status{$newsfeed{$id.'_status'}}='checked="checked"'; $r->print(< - - + +   +    - +    - +    - +
      -
      - - +
      +
      + +
      ENDEDIT } else { if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; } @@ -245,7 +273,7 @@ ENDEDIT } } } - $r->print("\n".($html?'
    '.($edit?'
    ':'').'':'
    '."\n")); + $r->print("\n".($html?''.($edit?'':'').&Apache::loncommon::end_page():''."\n")); return OK; } 1;