--- loncom/interface/lonrss.pm	2005/11/20 02:12:35	1.5
+++ loncom/interface/lonrss.pm	2006/03/16 20:03:11	1.11
@@ -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.11 2006/03/16 20:03:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -74,16 +74,20 @@ sub renamefeed {
 }
 
 sub advertisefeeds {
-    my ($uname,$udom)=@_;
+    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.='<li>'.$feednames{$feed}.
-		'<br />HTML: <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
-		'<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></li>';
+		'<br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
+		($edit?'':'<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a>').'</li>';
 	}
     }
     if ($feeds) {
@@ -134,8 +138,18 @@ sub changestatus {
     }
 }
 
+sub changed_js {
+    return <<ENDSCRIPT;
+<script type="text/javascript">
+    function changed(tform,id) {
+        tform.elements[id+"_modified"].checked=true;
+    }
+</script>
+ENDSCRIPT
+}
+
 sub handler {
-    my $r = shift;
+    my ($r) = @_;
 
     my $edit=0;
     my $html=0;
@@ -161,9 +175,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("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1'>\n<channel>".
 		  "\n<link>http://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.
@@ -173,7 +190,10 @@ sub handler {
 		  '</description>');
     }
 # 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?'<h3>':'<title>').&mt('No feed available').($html?'</h3>':'</title>'));
     } else {
@@ -188,7 +208,10 @@ sub handler {
         $r->print("\n".
 		  ($html?'<h3>':'<title>').
 		  &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
-		  ($html?'</h3>'.($edit?'<form method="post">':'').'<ul>':'</title>'));
+		  ($html?'</h3>'.($edit?'<form method="post"><br />'.
+				  &mt('Name of blog/journal').
+				  ': <input type="text" size="50" name="newblogname" value="'.
+				  $displayfeedname.'" />':'').'<ul>':'</title>'));
 # Render private items?
         my $viewpubliconly=1;
         if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
@@ -203,23 +226,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);
 <li>
-<input name='$id\_modified' type='hidden' value='0' />
-<label><input name='$id\_status' type="radio" value="public" $status{'public'}> $lt{'public'}</label>
+<label><input name='$id\_modified' type='checkbox' /> $lt{'store'}</label>
+&nbsp;&nbsp;
+<label><input name='$id\_status' type="radio" value="public" $status{'public'} onClick="changed(this.form,'$id');" /> $lt{'public'}</label>
 &nbsp;&nbsp;
-<label><input name='$id\_status' type="radio" value="private" $status{'private'}> $lt{'private'}</label>
+<label><input name='$id\_status' type="radio" value="private" $status{'private'} onClick="changed(this.form,'$id');" /> $lt{'private'}</label>
 &nbsp;&nbsp;
-<label><input name='$id\_status' type="radio" value="hidden" $status{'hidden'}> $lt{'hidden'}</label>
+<label><input name='$id\_status' type="radio" value="hidden" $status{'hidden'} onClick="changed(this.form,'$id');" /> $lt{'hidden'}</label>
 &nbsp;&nbsp;
-<label><input name='$id\_status' type="radio" value="delete"> $lt{'delete'}</label>
+<label><input name='$id\_status' type="radio" value="delete" onClick="changed(this.form,'$id');" /> $lt{'delete'}</label>
 <br />
-<input name='$id\_title' type='text' size='80' value='$newsfeed{$id.'_title'}' /><br />
-<textarea name='$id\_description' rows="6" cols="80">$newsfeed{$id.'_description'}</textarea>
-</li>
+<input name='$id\_title' type='text' size='80' value='$newsfeed{$id.'_title'}' onChange="changed(this.form,'$id');" /><br />
+<textarea name='$id\_description' rows="6" cols="80" onChange="changed(this.form,'$id');">$newsfeed{$id.'_description'}</textarea><br />
+<input name='$id\_link' type='text' size='80' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" />
+<hr /></li>
 ENDEDIT
 		} else {
 		    if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
@@ -245,7 +271,7 @@ ENDEDIT
 	    }
 	}
     }
-    $r->print("\n".($html?'</ul>'.($edit?'</form>':'').'</body></html>':'</channel></rss>'."\n"));
+    $r->print("\n".($html?'</ul>'.($edit?'<input type="submit" value="'.&mt('Store Marked Changes').'" /></form>':'').&Apache::loncommon::end_page():'</channel></rss>'."\n"));
     return OK;
 } 
 1;