Annotation of loncom/interface/lonrss.pm, revision 1.29

1.1       www         1: # The LearningOnline Network
                      2: # RSS Feeder
                      3: #
1.29    ! raeburn     4: # $Id: lonrss.pm,v 1.28 2006/10/02 16:47:57 albertel Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonrss;
                     30: 
                     31: use strict;
1.22      albertel   32: use LONCAPA;
1.1       www        33: use Apache::Constants qw(:common);
                     34: use Apache::loncommon;
                     35: use Apache::lonnet;
                     36: use Apache::lontexconvert;
                     37: use Apache::lonlocal;
                     38: use Apache::lonhtmlcommon;
                     39: 
1.15      www        40: 
1.1       www        41: sub filterfeedname {
                     42:     my $filename=shift;
1.5       www        43:     $filename=~s/(\_rss\.html|\.rss)$//;
1.1       www        44:     $filename=~s/\W//g;
1.15      www        45:     $filename=~s/\_rssfeed$//;
                     46:     $filename=~s/^nohist\_//;
1.1       www        47:     return $filename;
                     48: }
                     49: 
                     50: sub feedname {
                     51:     return 'nohist_'.&filterfeedname(shift).'_rssfeed';
                     52: }
                     53: 
                     54: sub displayfeedname {
1.2       www        55:     my ($rawname,$uname,$udom)=@_;
                     56:     my $filterfilename=&filterfeedname($rawname);
                     57: # do we have a stored name?
1.20      www        58:     my %stored=&Apache::lonnet::get('nohist_all_rss_feeds',[$filterfilename,'feed_display_option_'.$filterfilename],$udom,$uname);
                     59:     if ($stored{$filterfilename}) { return ($stored{$filterfilename},$stored{'feed_display_option_'.$filterfilename}); }
1.2       www        60: # no, construct a name
                     61:     my $name=$filterfilename; 
                     62:     if ($name=~/^CourseBlog/) {
                     63:         $name=&mt('Course Blog');
                     64: 	if ($env{'course.'.$env{'request.course.id'}.'.description'}) {
                     65: 	    $name.=' '.$env{'course.'.$env{'request.course.id'}.'.description'};
                     66: 	}
                     67:     } else {
                     68: 	$name=~s/\_/ /g;
                     69:     }
1.20      www        70:     return ($name,$stored{'feed_display_option_'.$filterfilename});
1.2       www        71: }
                     72: 
1.19      www        73: sub namefeed {
1.2       www        74:     my ($rawname,$uname,$udom,$newname)=@_;
                     75:     return &Apache::lonnet::put('nohist_all_rss_feeds',
                     76: 				{ &filterfeedname($rawname) => $newname },
                     77: 				$udom,$uname);
                     78: }
                     79: 
1.20      www        80: sub changefeeddisplay {
                     81:     my ($rawname,$uname,$udom,$newstatus)=@_;
                     82:     return &Apache::lonnet::put('nohist_all_rss_feeds',
                     83: 				{ 'feed_display_option_'.&filterfeedname($rawname) => $newstatus },
                     84: 				$udom,$uname);
                     85: }
                     86: 
1.2       www        87: sub advertisefeeds {
1.6       www        88:     my ($uname,$udom,$edit)=@_;
1.2       www        89:     my $feeds='';
                     90:     my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname);
1.6       www        91:     my $mode='public';
                     92:     if ($edit) {
                     93: 	$mode='adm';
                     94:     }
1.29    ! raeburn    95:     my $server = &Apache::lonnet::absolute_url();
1.3       albertel   96:     foreach my $feed (sort(keys(%feednames))) {
1.24      www        97: 	if (($feed!~/^error\:/) && ($feed!~/^feed\_display\_option\_/)) {
1.29    ! raeburn    98: 	    my $feedurl= $server.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
        !            99: 	    my $htmlurl= $server.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
1.20      www       100: 	    if ($feednames{'feed_display_option_'.$feed} eq 'hidden') {
                    101: 		if ($edit) {
                    102: 		    $feeds.='<li><i>'.$feednames{$feed}.'</i><br />'.&mt('Hidden').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a></li>';
                    103: 		}
                    104: 	    } else {
                    105: 		$feeds.='<li><b>'.$feednames{$feed}.
                    106: 		    '</b><br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
                    107: 		    '<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></li>';
                    108: 	    }
1.2       www       109: 	}
                    110:     }
                    111:     if ($feeds) {
                    112: 	return '<h4>'.&mt('Available RSS Feeds and Blogs').'</h4><ul>'.$feeds.'</ul>';
                    113:     } else {
                    114:         return '';
                    115:     }
1.1       www       116: }
                    117: 
1.12      albertel  118: sub rss_link {
                    119:     my ($url) = @_;
                    120:     return qq|<link rel="alternate" type="application/rss+xml" title="Course Announcements" href="$url" />|;
                    121: }
                    122: 
1.16      albertel  123: {
                    124:     my $feedcounter;
                    125:     sub get_new_feed_id {
                    126: 	$feedcounter++;
                    127: 	return time().'00000'.$$.'00000'.$feedcounter;
                    128:     }
                    129: }
                    130: 
1.15      www       131: sub addentry {
1.16      albertel  132:     my $id=&get_new_feed_id();
1.15      www       133:     return &editentry($id,@_);
1.2       www       134: }
                    135: 
                    136: sub editentry {
1.17      www       137:     my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype)=@_;
1.15      www       138:     if ($status eq 'deleted') {
                    139: 	return &changestatus($id,$uname,$udom,$filename,$status);
                    140:     }
1.2       www       141:     my $feedname=&feedname($filename);
                    142:     &Apache::lonnet::put('nohist_all_rss_feeds',
1.24      www       143: 			 { &filterfeedname($filename) => 
                    144: 			       (&displayfeedname($filename,$uname,$udom))[0] },
1.2       www       145: 			 $udom,$uname);
1.1       www       146:     return &Apache::lonnet::put($feedname,{
                    147: 	$id.'_title' => $title,
                    148: 	$id.'_description' => $description,
                    149: 	$id.'_link' => $url,
                    150: 	$id.'_enclosureurl' => $encurl,
                    151: 	$id.'_enclosuretype' => $enctype,
                    152: 	$id.'_status' => $status},$udom,$uname);
                    153: }
                    154: 
1.2       www       155: sub changestatus {
                    156:     my ($id,$uname,$udom,$filename,$status)=@_;
                    157:     my $feedname=&feedname($filename);
                    158:     if ($status eq 'deleted') {
                    159: 	return &Apache::lonnet::del($feedname,[$id.'_title',
                    160: 					       $id.'_description',
                    161: 					       $id.'_link',
                    162: 					       $id.'_enclosureurl',
                    163: 					       $id.'_enclosuretype',
                    164: 					       $id.'_status'],$udom,$uname);
                    165:     } else {
                    166: 	return &Apache::lonnet::put($feedname,{$id.'_status' => $status},$udom,$uname);
                    167:     }
                    168: }
                    169: 
1.8       albertel  170: sub changed_js {
                    171:     return <<ENDSCRIPT;
                    172: <script type="text/javascript">
                    173:     function changed(tform,id) {
                    174:         tform.elements[id+"_modified"].checked=true;
                    175:     }
                    176: </script>
1.11      albertel  177: ENDSCRIPT
1.8       albertel  178: }
                    179: 
1.17      www       180: sub determine_enclosure_types {
                    181:     my ($url)=@_;
                    182:     my ($ending)=($url=~/\.(\w+)$/);
                    183:     return &Apache::loncommon::filemimetype($ending);
                    184: }
                    185: 
1.21      www       186: sub course_blog_link {
                    187:     my ($id,$title,$description,$url,$encurl,$enctype)=@_;
                    188:     if ($env{'request.course.id'}) {
                    189: 	return &add_blog_entry_link($id,
                    190: 				    $env{'course.'.$env{'request.course.id'}.'.num'},
                    191: 				    $env{'course.'.$env{'request.course.id'}.'.domain'},
                    192: 				    'Course_Announcements',
                    193: 				    $title,$description,$url,'public',$encurl,$enctype,
                    194: 				    &mt('Add to Course Announcements'));
                    195:     } else {
                    196: 	return '';
                    197:     }
                    198: }
                    199: 
                    200: sub add_blog_entry_link {
                    201:     my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype,$linktext)=@_;
                    202:     return "<a href='/adm/$udom/$uname/".&filterfeedname($filename).'_rss.html?queryid='.
1.22      albertel  203: 	&escape($id).
1.27      albertel  204: 	'&amp;title='.&escape($title).
                    205: 	'&amp;description='.&escape($description).
                    206: 	'&amp;url='.&escape($url).
                    207: 	'&amp;status='.&escape($status).
                    208: 	'&amp;encurl='.&escape($encurl).
                    209: 	'&amp;enctype='.&escape($enctype).
1.21      www       210: 	"'>".$linktext.'</a>';
                    211: 
                    212: }
                    213: 
1.29    ! raeburn   214: sub blocking_blogdisplay {
        !           215:     my ($uname,$udom,$html,$filterfeedname) = @_;
        !           216:     my $user = &Apache::loncommon::plainname($uname,$udom);
        !           217:     if ($html) {
        !           218:         $user = &Apache::loncommon::aboutmewrapper($user,$uname,$udom);
        !           219:     } else {
        !           220:         $user = $user.' ('.$uname.':'.$udom.')';
        !           221:     }
        !           222:     my %setters;
        !           223:     my ($blocked,$output,$blockcause);
        !           224:     my ($startblock,$endblock) =
        !           225:              &Apache::loncommon::blockcheck(\%setters,'blogs');
        !           226:     if ($startblock && $endblock) {
        !           227:         $blockcause = 'user';
        !           228:     } else { 
        !           229:         if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
        !           230:             ($startblock,$endblock) =
        !           231:                  &Apache::loncommon::blockcheck(\%setters,'blogs',
        !           232:                                                 $uname,$udom);
        !           233:             $blockcause = 'blogowner';
        !           234:         }
        !           235:     }
        !           236:     if ($startblock && $endblock) {
        !           237:         $blocked = 1;
        !           238:         my $showstart = &Apache::lonlocal::locallocaltime($startblock);
        !           239:         my $showend = &Apache::lonlocal::locallocaltime($endblock);
        !           240:         $output = &mt('Blogs belonging to [_1] are unavailable from [_2] to [_3].',$user,$showstart,$showend);
        !           241:         if ($html) {$output.='<br />';}
        !           242:         if ($blockcause eq 'user') {
        !           243:             $output .= &mt('This is because you are a student in one or more courses in which communication is being blocked.');
        !           244:             if ($html) {
        !           245:                 $output .= '<br />'.
        !           246:                        &Apache::loncommon::build_block_table($startblock,
        !           247:                                                         $endblock,\%setters);
        !           248:             }
        !           249:         } else {
        !           250:             $output .= &mt('This is because the blog owner is a student in one or more courses in which communication is being blocked.');
        !           251:         }
        !           252:         if (!$html) {
        !           253:             my $id = &get_new_feed_id();
        !           254:             $output = '<title/><item><title/><description>'.$output."</description><link/><guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname.'</guid></item>';
        !           255:         }
        !           256:     }
        !           257:     return ($blocked,$output);
        !           258: }
        !           259: 
1.1       www       260: sub handler {
1.8       albertel  261:     my ($r) = @_;
1.5       www       262: 
                    263:     my $edit=0;
                    264:     my $html=0;
                    265:     my (undef,$mode,$udom,$uname,$filename)=split(/\//,$r->uri);
                    266:     if (($mode eq 'adm') && ($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
                    267: 	$edit=1;
                    268: 	$html=1;
                    269:     }
1.21      www       270:     if  (($mode eq 'adm') && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
                    271: 	$edit=1;
                    272: 	$html=1;
                    273:     }
1.5       www       274:     if ($filename=~/\.html$/) {
                    275: 	$html=1;
                    276:     }
                    277:     if ($html) {
                    278: 	&Apache::loncommon::content_type($r,'text/html');
                    279:     } else {
                    280: # Workaround Mozilla/Firefox
                    281: #	&Apache::loncommon::content_type($r,'application/rss+xml');
                    282: 	&Apache::loncommon::content_type($r,'text/xml');
                    283:     }
1.1       www       284:     $r->send_http_header;
                    285:     return OK if $r->header_only;
                    286: 
                    287:     my $filterfeedname=&filterfeedname($filename);
                    288:     my $feedname=&feedname($filename);
1.20      www       289:     my ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
1.29    ! raeburn   290:     my ($blocked,$blocktext);
        !           291:     if ($uname !~ /^\d\w\d[\w\-.]+$/) {
        !           292:         ($blocked,$blocktext) = &blocking_blogdisplay($uname,$udom,$html,$filterfeedname);
        !           293:     }
1.5       www       294:     if ($html) {
1.25      albertel  295: 	my $title = $displayfeedname?$displayfeedname
                    296:                                     :"Available RSS Feeds and Blogs";
1.26      albertel  297: 	$r->print(&Apache::loncommon::start_page($title,undef,
1.13      albertel  298: 						 {'domain'         => $udom,
                    299: 						  'force_register' =>
                    300: 						      $env{'form.register'}}).
1.8       albertel  301: 		  &changed_js());
1.18      www       302:     } else { # render RSS
1.29    ! raeburn   303:         my $server = &Apache::lonnet::absolute_url();
1.5       www       304: 	$r->print("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1'>\n<channel>".
1.29    ! raeburn   305: 		  "\n".'<link>'.$server.'/public/'.$udom.'/'.$uname.'/'.
1.5       www       306: 		  $filterfeedname.'_rss.html</link>'.
                    307: 		  "\n<description>".
                    308: 		  &mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').
                    309: 		  '</description>');
                    310:     }
1.21      www       311: # This will be the entry id for new additions to the blog
1.16      albertel  312:     my $newid = &get_new_feed_id();
1.1       www       313: # Is this user for real?
1.6       www       314:     my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
1.29    ! raeburn   315:     if ($html && !$blocked) {
1.19      www       316: # Any new feeds or renaming of feeds?
                    317: 	if ($edit) {
1.20      www       318: # Hide a feed?
                    319: 	    if ($env{'form.hidethisblog'}) {
                    320: 		&changefeeddisplay($feedname,$uname,$udom,'hidden');
                    321: 		($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
                    322: 	    }
                    323: # Advertise a feed?
                    324: 	    if ($env{'form.advertisethisblog'}) {
                    325: 		&changefeeddisplay($feedname,$uname,$udom,'public');
                    326: 		($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
                    327: 	    }
1.19      www       328: # New feed?
                    329: 	    if ($env{'form.namenewblog'}=~/\w/) {
                    330: 		&namefeed($env{'form.namenewblog'},$uname,$udom,$env{'form.namenewblog'});
                    331: 	    }
                    332: # Old feed that is being renamed?
                    333: 	    if (($displayfeedname) && ($env{'form.newblogname'}=~/\w/)) {
                    334: 		if ($env{'form.newblogname'} ne $displayfeedname) {
                    335: 		    &namefeed($feedname,$uname,$udom,$env{'form.newblogname'});
1.20      www       336: 		    ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
1.19      www       337: 		}
                    338: 	    }
                    339: 	}
1.6       www       340: 	$r->print(&advertisefeeds($uname,$udom,$edit));
                    341:     } 
1.1       www       342:     if ($homeserver eq 'no_host') {
1.5       www       343: 	$r->print(($html?'<h3>':'<title>').&mt('No feed available').($html?'</h3>':'</title>'));
1.29    ! raeburn   344:     } elsif ($blocked) {
        !           345:         $r->print($blocktext);
        !           346:         $r->print(($html?&Apache::loncommon::end_page():'</channel></rss>'."\n"));
1.18      www       347:     } else { # is indeed a user
1.1       www       348: # Course or user?
                    349: 	my $name='';
1.29    ! raeburn   350: 	if ($uname =~ /^\d\w\d[\w\-.]+$/) {
1.1       www       351: 	    my %cenv=&Apache::lonnet::dump('environment',$udom,$uname);
                    352: 	    $name=$cenv{'description'};
                    353: 	} else {
                    354: 	    $name=&Apache::loncommon::nickname($uname,$udom);
                    355: 	}
1.19      www       356: # Add a new feed
                    357:         if (($html) && ($edit)) {
                    358: 	    $r->print('<form method="post">');
1.21      www       359:             $r->print(&mt('Name for New Feed').": <input type='text' size='40' name='namenewblog' />");
                    360: 	    $r->print('<input type="submit" value="'.&mt('Start a New Feed').'" />');
1.19      www       361: 	    $r->print('</form>');
                    362: 	}
1.18      www       363:         if ($displayfeedname) { # this is an existing feed
                    364: # Anything to store?
                    365: 	    if ($edit) {
1.21      www       366: # check if this was called with a query string
                    367: 		&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['queryid']);
                    368: 		if ($env{'form.queryid'}) {
                    369: # yes, collect the remainder
                    370: 		    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    371: 							    ['title',
                    372: 							     'description',
                    373: 							     'url',
                    374: 							     'status',
                    375: 							     'enclosureurl',
                    376: 							     'enclosuretype']);
                    377: #    my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype)=@_;
                    378: 
                    379: 		    &editentry($env{'form.queryid'},
                    380: 			       $uname,$udom,$filename,
                    381: 			       $env{'form.title'},
                    382: 			       $env{'form.description'},
                    383: 			       $env{'form.url'},
                    384: 			       $env{'form.status'},
                    385: 			       $env{'form.encurl'},
                    386: 			       $env{'form.enctype'}
                    387: 			       );
                    388: 		}
1.18      www       389: 		my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
                    390: 		foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
                    391: 		    if ($entry=~/^(\d+)\_status$/) {
                    392: 			my $id=$1;
                    393: 			if ($env{'form.'.$id.'_modified'}) {
                    394: 			    &editentry($id,$uname,$udom,$feedname,
                    395: 				       $env{'form.'.$id.'_title'},
                    396: 				       $env{'form.'.$id.'_description'},
1.28      albertel  397: 				       $env{'form.'.$id.'_link'},
1.21      www       398: 				       $env{'form.'.$id.'_status'},
                    399: 				       $env{'form.'.$id.'_enclosureurl'},
                    400: 				       $env{'form.'.$id.'_enclosuretype'},
                    401: 				       );
1.18      www       402: 			}
                    403: 		    }
                    404: 		}
                    405: 	    } #done storing
                    406: 
1.29    ! raeburn   407: # Render private items?
        !           408:             my $viewpubliconly=1;
1.18      www       409: 	    $r->print("\n".
1.19      www       410: 		      ($html?'<hr /><h3>':'<title>').
1.18      www       411: 		      &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
1.20      www       412: 		      ($displayoption eq 'hidden'?' ('.&mt('Hidden').')':'').
1.18      www       413: 		      ($html?'</h3>'.($edit?'<form method="post"><br />'.
1.21      www       414: 				      &mt('Name of this Feed').
1.18      www       415: 				      ': <input type="text" size="50" name="newblogname" value="'.
                    416: 				      $displayfeedname.'" />':'').'<ul>':'</title>'));
                    417: 	    if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
                    418: 		$viewpubliconly=0;
1.29    ! raeburn   419:             }
1.1       www       420: # Get feed items
1.18      www       421: 	    my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
                    422: 	    foreach my $entry (sort(keys(%newsfeed)),$newid.'_status') {
                    423: 		if ($entry=~/^(\d+)\_status$/) { # is an entry
                    424: 		    my $id=$1;
                    425: 		    if ($edit) {
                    426: 			my %lt=&Apache::lonlocal::texthash('public' => 'public',
                    427: 							   'private' => 'private',
                    428: 							   'hidden' => 'hidden',
                    429: 							   'delete' => 'delete',
                    430: 							   'store' => 'Store changes',
                    431: 							   'title' => 'Title',
                    432: 							   'link' => 'Link',
                    433: 							   'description' => 'Description');
                    434: 			my %status=();
                    435: 			unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }
                    436: 			$status{$newsfeed{$id.'_status'}}='checked="checked"';
                    437: 			$r->print(<<ENDEDIT);
1.5       www       438: <li>
1.15      www       439: <label><input name='$id\_modified' type='checkbox' value="modified" /> $lt{'store'}</label>
1.6       www       440: &nbsp;&nbsp;
                    441: <label><input name='$id\_status' type="radio" value="public" $status{'public'} onClick="changed(this.form,'$id');" /> $lt{'public'}</label>
1.5       www       442: &nbsp;&nbsp;
1.6       www       443: <label><input name='$id\_status' type="radio" value="private" $status{'private'} onClick="changed(this.form,'$id');" /> $lt{'private'}</label>
1.5       www       444: &nbsp;&nbsp;
1.6       www       445: <label><input name='$id\_status' type="radio" value="hidden" $status{'hidden'} onClick="changed(this.form,'$id');" /> $lt{'hidden'}</label>
1.5       www       446: &nbsp;&nbsp;
1.15      www       447: <label><input name='$id\_status' type="radio" value="deleted" onClick="changed(this.form,'$id');" /> $lt{'delete'}</label>
1.5       www       448: <br />
1.18      www       449: $lt{'title'}:
                    450: <input name='$id\_title' type='text' size='60' value='$newsfeed{$id.'_title'}' onChange="changed(this.form,'$id');" /><br />
                    451: $lt{'description'}:<br />
1.6       www       452: <textarea name='$id\_description' rows="6" cols="80" onChange="changed(this.form,'$id');">$newsfeed{$id.'_description'}</textarea><br />
1.18      www       453: $lt{'link'}:
                    454: <input name='$id\_link' type='text' size='60' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" />
1.6       www       455: <hr /></li>
1.5       www       456: ENDEDIT
1.18      www       457: 		    } else { # not in edit mode, just displaying
                    458: 			if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
                    459: 			if ($newsfeed{$id.'_status'} eq 'hidden') { next; }
1.28      albertel  460: 			my $link =  $newsfeed{$id.'_link'};
                    461: 			if ($link =~ m|^/| ) {
                    462: 			    $link = "http://".$ENV{'HTTP_HOST'}.$link;
                    463: 			}
1.18      www       464: 			$r->print("\n".($html?"\n<li><b>":"<item>\n<title>").$newsfeed{$id.'_title'}.
                    465: 				  ($html?"</b><br />\n":"</title>\n<description>").
                    466: 				  $newsfeed{$id.'_description'}.
                    467: 				  ($html?"<br />\n<a href='":"</description>\n<link>").
1.28      albertel  468: 				  
                    469: 				  $link.
1.18      www       470: 				  ($html?("'>".&mt('Read more')."</a><br />\n"):"</link>\n"));
1.17      www       471: # Enclosure? Get stats
1.18      www       472: 			if ($newsfeed{$id.'_enclosureurl'}) {
                    473: 			    my @stat=&Apache::lonnet::stat_file($newsfeed{$id.'_enclosureurl'});
                    474: 			    if ($stat[7]) {
1.17      www       475: # Has non-zero length (and exists)
1.18      www       476: 				my $enclosuretype=$newsfeed{$id.'_enclosetype'};
                    477: 				$r->print(($html?"<a href='":"\n<enclosure url='").
                    478: 					  $newsfeed{$id.'_enclosureurl'}."' length='".$stat[7].
                    479: 					  "' type='".$enclosuretype.($html?"'>".&mt('Enclosure')."</a>":"' />"));
                    480: 			    }
                    481: 			}
                    482: 			if ($html) { # is HTML
                    483: 			    $r->print("\n<hr /></li>\n");
                    484: 			} else { # is RSS
                    485: 			    $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
1.17      www       486: 			}
1.18      www       487: 		    } # end of "in edit mode"
                    488: 		} # end of rendering a real entry
                    489: 	    } # end of loop through all keys
                    490: 	    if ($html) {
                    491: 		$r->print('</ul>');
                    492: 		if ($edit) {
1.20      www       493: 		    $r->print('<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Store Marked Changes').'" />'.
                    494: 			      ($displayoption eq 'hidden'?'<input type="submit" name="advertisethisblog" value="'.&mt('Advertise this Feed').'" />':
                    495: 			       '<input type="submit" name="hidethisblog" value="'.&mt('Hide this Feed').'" />'));
1.1       www       496: 		}
                    497: 	    }
1.18      www       498: 	} # was a real display feedname
                    499: 	$r->print(($html?'</form>'.&Apache::loncommon::end_page():'</channel></rss>'."\n"));
                    500:     } # a real user
1.1       www       501:     return OK;
1.18      www       502: } # end handler
1.1       www       503: 1;
                    504: __END__

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