Diff for /loncom/interface/lonrss.pm between versions 1.17 and 1.18

version 1.17, 2006/04/22 20:58:32 version 1.18, 2006/05/10 15:52:11
Line 90  sub advertisefeeds { Line 90  sub advertisefeeds {
     my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';      my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
     $feeds.='<li>'.$feednames{$feed}.      $feeds.='<li>'.$feednames{$feed}.
  '<br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.   '<br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
  ($edit?'':'<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a>').'</li>';   '<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></li>';
  }   }
     }      }
     if ($feeds) {      if ($feeds) {
Line 199  sub handler { Line 199  sub handler {
   'force_register' =>    'force_register' =>
       $env{'form.register'}}).        $env{'form.register'}}).
   &changed_js());    &changed_js());
     } else {      } else { # render RSS
  $r->print("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1'>\n<channel>".   $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.'/'.    "\n<link>http://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.
   $filterfeedname.'_rss.html</link>'.    $filterfeedname.'_rss.html</link>'.
Line 208  sub handler { Line 208  sub handler {
   '</description>');    '</description>');
     }      }
 # Do we have stuff to store?  # 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();      my $newid = &get_new_feed_id();
 # Is this user for real?  # Is this user for real?
     my $homeserver=&Apache::lonnet::homeserver($uname,$udom);      my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
Line 231  sub handler { Line 216  sub handler {
     }       } 
     if ($homeserver eq 'no_host') {      if ($homeserver eq 'no_host') {
  $r->print(($html?'<h3>':'<title>').&mt('No feed available').($html?'</h3>':'</title>'));   $r->print(($html?'<h3>':'<title>').&mt('No feed available').($html?'</h3>':'</title>'));
     } else {      } else { # is indeed a user
 # Course or user?  # Course or user?
  my $name='';   my $name='';
  if ($uname=~/^\d/) {   if ($uname=~/^\d/) {
Line 240  sub handler { Line 225  sub handler {
  } else {   } else {
     $name=&Apache::loncommon::nickname($uname,$udom);      $name=&Apache::loncommon::nickname($uname,$udom);
  }   }
         $r->print("\n".          if ($displayfeedname) { # this is an existing feed
   ($html?'<h3>':'<title>').  # Anything to store?
   &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).      if ($edit) {
   ($html?'</h3>'.($edit?'<form method="post"><br />'.   my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
   &mt('Name of blog/journal').   foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
   ': <input type="text" size="50" name="newblogname" value="'.      if ($entry=~/^(\d+)\_status$/) {
   $displayfeedname.'" />':'').'<ul>':'</title>'));   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'});
    }
       }
    }
    if ($env{'form.newblogname'} ne $displayfeedname) {
       &Apache::lonnet::put('nohist_all_rss_feeds',{ $filterfeedname => $env{'form.newblogname'} },$udom,$uname);
       $displayfeedname=&displayfeedname($filename,$uname,$udom);
    }
       } #done storing
   
       $r->print("\n".
         ($html?'<h3>':'<title>').
         &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
         ($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?  # Render private items?
         my $viewpubliconly=1;      my $viewpubliconly=1;
         if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {      if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
     $viewpubliconly=0;   $viewpubliconly=0;
  }      }
 # Get feed items  # Get feed items
         my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);      my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
  foreach my $entry (sort(keys(%newsfeed)),$newid.'_status') {      foreach my $entry (sort(keys(%newsfeed)),$newid.'_status') {
     if ($entry=~/^(\d+)\_status$/) {   if ($entry=~/^(\d+)\_status$/) { # is an entry
  my $id=$1;      my $id=$1;
  if ($edit) {      if ($edit) {
     my %lt=&Apache::lonlocal::texthash('public' => 'public',   my %lt=&Apache::lonlocal::texthash('public' => 'public',
        'private' => 'private',     'private' => 'private',
        'hidden' => 'hidden',     'hidden' => 'hidden',
        'delete' => 'delete',     'delete' => 'delete',
        'store' => 'Store changes');     'store' => 'Store changes',
     my %status=();     'title' => 'Title',
                     unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }     'link' => 'Link',
     $status{$newsfeed{$id.'_status'}}='checked="checked"';     'description' => 'Description');
     $r->print(<<ENDEDIT);   my %status=();
    unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }
    $status{$newsfeed{$id.'_status'}}='checked="checked"';
    $r->print(<<ENDEDIT);
 <li>  <li>
 <label><input name='$id\_modified' type='checkbox' value="modified" /> $lt{'store'}</label>  <label><input name='$id\_modified' type='checkbox' value="modified" /> $lt{'store'}</label>
 &nbsp;&nbsp;  &nbsp;&nbsp;
Line 278  sub handler { Line 288  sub handler {
 &nbsp;&nbsp;  &nbsp;&nbsp;
 <label><input name='$id\_status' type="radio" value="deleted" onClick="changed(this.form,'$id');" /> $lt{'delete'}</label>  <label><input name='$id\_status' type="radio" value="deleted" onClick="changed(this.form,'$id');" /> $lt{'delete'}</label>
 <br />  <br />
 <input name='$id\_title' type='text' size='80' value='$newsfeed{$id.'_title'}' onChange="changed(this.form,'$id');" /><br />  $lt{'title'}:
   <input name='$id\_title' type='text' size='60' value='$newsfeed{$id.'_title'}' onChange="changed(this.form,'$id');" /><br />
   $lt{'description'}:<br />
 <textarea name='$id\_description' rows="6" cols="80" onChange="changed(this.form,'$id');">$newsfeed{$id.'_description'}</textarea><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');" />  $lt{'link'}:
   <input name='$id\_link' type='text' size='60' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" />
 <hr /></li>  <hr /></li>
 ENDEDIT  ENDEDIT
  } else {      } else { # not in edit mode, just displaying
     if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }   if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
     if ($newsfeed{$id.'_status'} eq 'hidden') { next; }   if ($newsfeed{$id.'_status'} eq 'hidden') { next; }
     $r->print("\n".($html?"\n<li><b>":"<item>\n<title>").$newsfeed{$id.'_title'}.   $r->print("\n".($html?"\n<li><b>":"<item>\n<title>").$newsfeed{$id.'_title'}.
       ($html?"</b><br />\n":"</title>\n<description>").    ($html?"</b><br />\n":"</title>\n<description>").
       $newsfeed{$id.'_description'}.    $newsfeed{$id.'_description'}.
       ($html?"<br />\n<a href='":"</description>\n<link>").    ($html?"<br />\n<a href='":"</description>\n<link>").
       "http://".$ENV{'HTTP_HOST'}.    "http://".$ENV{'HTTP_HOST'}.
       $newsfeed{$id.'_link'}.    $newsfeed{$id.'_link'}.
       ($html?("'>".&mt('Read more')."</a><br />\n"):"</link>\n"));    ($html?("'>".&mt('Read more')."</a><br />\n"):"</link>\n"));
 # Enclosure? Get stats  # Enclosure? Get stats
     if ($newsfeed{$id.'_enclosureurl'}) {   if ($newsfeed{$id.'_enclosureurl'}) {
  my @stat=&Apache::lonnet::stat_file($newsfeed{$id.'_enclosureurl'});      my @stat=&Apache::lonnet::stat_file($newsfeed{$id.'_enclosureurl'});
  if ($stat[7]) {      if ($stat[7]) {
 # Has non-zero length (and exists)  # Has non-zero length (and exists)
     my $enclosuretype=$newsfeed{$id.'_enclosetype'};   my $enclosuretype=$newsfeed{$id.'_enclosetype'};
     $r->print(($html?"<a href='":"\n<enclosure url='").   $r->print(($html?"<a href='":"\n<enclosure url='").
       $newsfeed{$id.'_enclosureurl'}."' length='".$stat[7].    $newsfeed{$id.'_enclosureurl'}."' length='".$stat[7].
       "' type='".$enclosuretype.($html?"'>".&mt('Enclosure')."</a>":"' />"));    "' type='".$enclosuretype.($html?"'>".&mt('Enclosure')."</a>":"' />"));
       }
  }   }
     }   if ($html) { # is HTML
     if ($html) {      $r->print("\n<hr /></li>\n");
  $r->print("\n<hr /></li>\n");   } else { # is RSS
     } else {      $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
  $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");   }
     }      } # end of "in edit mode"
    } # end of rendering a real entry
       } # end of loop through all keys
       if ($html) {
    $r->print('</ul>');
    if ($edit) {
       $r->print('<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Store Marked Changes').'" />');
  }   }
     }      }
  }   } # was a real display feedname
     }   $r->print(($html?'</form>'.&Apache::loncommon::end_page():'</channel></rss>'."\n"));
     $r->print("\n".($html?'</ul>'.($edit?'<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Store Marked Changes').'" /></form>':'').&Apache::loncommon::end_page():'</channel></rss>'."\n"));      } # a real user
     return OK;      return OK;
 }   } # end handler
 1;  1;
 __END__  __END__

Removed from v.1.17  
changed lines
  Added in v.1.18


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>