File:
[LON-CAPA] /
loncom /
interface /
lonrss.pm
Revision
1.51:
download - view:
text,
annotated -
select for diffs
Mon May 6 16:15:59 2013 UTC (11 years, 3 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- lonrss::advertisefeeds() takes two additional, optional args:
$count, $hidden (refs to scalars to accumulate counts of visible feeds
- Set additional item in %env for a course:
$env{'course.<courseid>.feeds'} contains number of visible course RSS feeds.
- Added information in Syllabus template about availability of RSS Feeds and
Blogs item (editing mode).
1: # The LearningOnline Network
2: # RSS Feeder
3: #
4: # $Id: lonrss.pm,v 1.51 2013/05/06 16:15:59 raeburn Exp $
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;
32: use LONCAPA;
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: use Apache::inputtags();
40:
41: sub filterfeedname {
42: my $filename=shift;
43: $filename=~s/(\_rss\.html|\.rss)$//;
44: $filename=~s/\W//g;
45: $filename=~s/\_rssfeed$//;
46: $filename=~s/^nohist\_//;
47: return $filename;
48: }
49:
50: sub feedname {
51: return 'nohist_'.&filterfeedname(shift).'_rssfeed';
52: }
53:
54: sub displayfeedname {
55: my ($rawname,$uname,$udom)=@_;
56: my $filterfilename=&filterfeedname($rawname);
57: # do we have a stored name?
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}); }
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'}.'.type'} eq 'Community') {
65: $name = &mt('Community Blog');
66: }
67: if ($env{'course.'.$env{'request.course.id'}.'.description'}) {
68: $name.=' '.$env{'course.'.$env{'request.course.id'}.'.description'};
69: }
70: } else {
71: $name=~s/\_/ /g;
72: }
73: return ($name,$stored{'feed_display_option_'.$filterfilename});
74: }
75:
76: sub namefeed {
77: my ($rawname,$uname,$udom,$newname)=@_;
78: return &Apache::lonnet::put('nohist_all_rss_feeds',
79: { &filterfeedname($rawname) => $newname },
80: $udom,$uname);
81: }
82:
83: sub changefeeddisplay {
84: my ($rawname,$uname,$udom,$newstatus)=@_;
85: return &Apache::lonnet::put('nohist_all_rss_feeds',
86: { 'feed_display_option_'.&filterfeedname($rawname) => $newstatus },
87: $udom,$uname);
88: }
89:
90: sub advertisefeeds {
91: my ($uname,$udom,$edit,$count,$hidden)=@_;
92: my $feeds='';
93: my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname);
94: my $mode='public';
95: if ($edit) {
96: $mode='adm';
97: }
98: my $server = &Apache::lonnet::absolute_url();
99: foreach my $feed (sort(keys(%feednames))) {
100: next if ($feed =~/^\s*$/ ||
101: $feed =~ /^error:/ ||
102: $feed =~ /^feed_display_option_/);
103: if ($feednames{'feed_display_option_'.$feed} eq 'hidden') {
104: if (ref($hidden)) {
105: $$hidden ++;
106: }
107: if (ref($count)) {
108: unless ($edit) {
109: next;
110: }
111: }
112: } else {
113: if (ref($count)) {
114: $$count ++;
115: }
116: }
117: my $feedurl= $server.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
118: my $htmlurl= $server.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
119: if ($feednames{'feed_display_option_'.$feed} eq 'hidden') {
120: if ($edit) {
121: $feeds.='<li><i>'.$feednames{$feed}.'</i><br />'.&mt('Hidden').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a></li>';
122: }
123: } else {
124: $feeds.='<li><b>'.$feednames{$feed}.
125: '</b><br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$feednames{$feed}.' HTML</tt></a>'.
126: '<br />'.&mt('Public RSS/podcast (subscribe to)').': <a href="'.$feedurl.'"><tt>'.$feednames{$feed}.' RSS/Podcast</tt></a></li>';
127: }
128: }
129: if ($feeds) {
130: return '<h4>'.&mt('Available RSS Feeds and Blogs').'</h4><ul>'.$feeds.'</ul>';
131: } else {
132: return '';
133: }
134: }
135:
136: sub rss_link {
137: my ($uname,$udom)=@_;
138: my $result;
139: my $server = &Apache::lonnet::absolute_url();
140: my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname);
141: foreach my $feed (sort(keys(%feednames))) {
142: next if ($feed =~/^\s*$/ ||
143: $feed =~ /^error:/ ||
144: $feed =~/^feed_display_option_/ );
145: my $url= $server.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
146: my $title = $feed;
147: $title =~ s/_/ /g;
148: $result.=qq|
149: <link rel="alternate" type="application/rss+xml" title="$title" href="$url" />
150: |;
151: }
152: return $result;
153: }
154:
155: {
156: my $feedcounter;
157: sub get_new_feed_id {
158: $feedcounter++;
159: return time().'00000'.$$.'00000'.$feedcounter;
160: }
161: }
162:
163: sub addentry {
164: my $id=&get_new_feed_id();
165: return &editentry($id,@_);
166: }
167:
168: sub editentry {
169: my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype)=@_;
170: if ($status eq 'deleted') {
171: return &changestatus($id,$uname,$udom,$filename,$status);
172: }
173: my $feedname=&feedname($filename);
174: &Apache::lonnet::put('nohist_all_rss_feeds',
175: { &filterfeedname($filename) =>
176: (&displayfeedname($filename,$uname,$udom))[0] },
177: $udom,$uname);
178: return &Apache::lonnet::put($feedname,{
179: $id.'_title' => $title,
180: $id.'_description' => $description,
181: $id.'_link' => $url,
182: $id.'_enclosureurl' => $encurl,
183: $id.'_enclosuretype' => $enctype,
184: $id.'_status' => $status},$udom,$uname);
185: }
186:
187: sub changestatus {
188: my ($id,$uname,$udom,$filename,$status)=@_;
189: my $feedname=&feedname($filename);
190: if ($status eq 'deleted') {
191: return &Apache::lonnet::del($feedname,[$id.'_title',
192: $id.'_description',
193: $id.'_link',
194: $id.'_enclosureurl',
195: $id.'_enclosuretype',
196: $id.'_status'],$udom,$uname);
197: } else {
198: return &Apache::lonnet::put($feedname,{$id.'_status' => $status},$udom,$uname);
199: }
200: }
201:
202: sub changed_js {
203: return <<ENDSCRIPT;
204: <script type="text/javascript">
205: function changed(tform,id) {
206: tform.elements[id+"_modified"].checked=true;
207: }
208: </script>
209: ENDSCRIPT
210: }
211:
212: sub determine_enclosure_types {
213: my ($url)=@_;
214: my ($ending)=($url=~/\.(\w+)$/);
215: return &Apache::loncommon::filemimetype($ending);
216: }
217:
218: sub course_blog_link {
219: my ($id,$title,$description,$url,$encurl,$enctype)=@_;
220: if ($env{'request.course.id'}) {
221: return &add_blog_entry_link($id,
222: $env{'course.'.$env{'request.course.id'}.'.num'},
223: $env{'course.'.$env{'request.course.id'}.'.domain'},
224: 'Course_Announcements',
225: $title,$description,$url,'public',$encurl,$enctype,
226: &mt('Add to Course Announcements'));
227: } else {
228: return '';
229: }
230: }
231:
232: sub add_blog_entry_link {
233: my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype,$linktext)=@_;
234: return "<a href='/adm/$udom/$uname/".&filterfeedname($filename).'_rss.html?queryid='.
235: &escape($id).
236: '&title='.&escape($title).
237: '&description='.&escape($description).
238: '&url='.&escape($url).
239: '&status='.&escape($status).
240: '&encurl='.&escape($encurl).
241: '&enctype='.&escape($enctype).
242: "'>".$linktext.'</a>';
243:
244: }
245:
246: sub blocking_blogdisplay {
247: my ($uname,$udom,$html,$filterfeedname) = @_;
248: my $user = &Apache::loncommon::plainname($uname,$udom);
249: if ($html) {
250: $user = &Apache::loncommon::aboutmewrapper($user,$uname,$udom);
251: } else {
252: $user = $user.' ('.$uname.':'.$udom.')';
253: }
254: my %setters;
255: my ($blocked,$output,$blockcause);
256: my ($startblock,$endblock) =
257: &Apache::loncommon::blockcheck(\%setters,'blogs');
258: if ($startblock && $endblock) {
259: $blockcause = 'user';
260: } else {
261: if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
262: ($startblock,$endblock) =
263: &Apache::loncommon::blockcheck(\%setters,'blogs',
264: $uname,$udom);
265: $blockcause = 'blogowner';
266: }
267: }
268: if ($startblock && $endblock) {
269: $blocked = 1;
270: my $showstart = &Apache::lonlocal::locallocaltime($startblock);
271: my $showend = &Apache::lonlocal::locallocaltime($endblock);
272: $output = &mt('Blogs belonging to [_1] are unavailable from [_2] to [_3].',$user,$showstart,$showend);
273: if ($html) {$output.='<br />';}
274: if ($blockcause eq 'user') {
275: $output .= &mt('This is because you are a student in one or more courses in which communication is being blocked.');
276: if ($html) {
277: #$output .= '<br />'.
278: #&Apache::loncommon::build_block_table($startblock,
279: # $endblock,\%setters);
280: my ($blocked, $blocktext) = Apache::loncommon::blocking_status('blogs');
281: $output .= '<br /><br />'.$blocktext;
282: }
283: } else {
284: $output .= &mt('This is because the blog owner is a student in one or more courses in which communication is being blocked.');
285: }
286: if (!$html) {
287: my $id = &get_new_feed_id();
288: $output = '<title/><item><title/><description>'.$output."</description><link/><guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname.'</guid></item>';
289: }
290: }
291: return ($blocked,$output);
292: }
293:
294: sub handler {
295: my ($r) = @_;
296:
297: my $edit=0;
298: my $html=0;
299: my (undef,$mode,$udom,$uname,$filename)=split(/\//,$r->uri);
300: if (($mode eq 'adm') && ($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
301: $edit=1;
302: $html=1;
303: }
304: if (($mode eq 'adm') && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))
305: && ($uname eq $env{'course.'.$env{'request.course.id'}.'.num'} &&
306: $udom eq $env{'course.'.$env{'request.course.id'}.'.domain'})) {
307: $edit=1;
308: $html=1;
309: }
310: if ($filename=~/\.html$/) {
311: $html=1;
312: }
313: if ($html) {
314: &Apache::loncommon::content_type($r,'text/html');
315: } else {
316: # Workaround Mozilla/Firefox
317: # &Apache::loncommon::content_type($r,'application/rss+xml');
318: &Apache::loncommon::content_type($r,'text/xml');
319: }
320: $r->send_http_header;
321: return OK if $r->header_only;
322:
323: my $filterfeedname=&filterfeedname($filename);
324: my $feedname=&feedname($filename);
325: my ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
326: my ($blocked,$blocktext,$disabled,$disabletext);
327: if (!&Apache::lonnet::is_course($udom,$uname)) {
328: ($blocked,$blocktext) = &blocking_blogdisplay($uname,$udom,$html,$filterfeedname);
329: if (&Apache::lonnet::usertools_access($uname,$udom,'blog')) {
330: $disabled = 0;
331: } else {
332: $disabled = 1;
333: if ($html) {
334: $disabletext = '<h2>'.&mt('No user blog available') .'</h2>'.
335: &mt('This is a result of one of the following:').'<ul>'.
336: '<li>'.&mt('The administrator of this domain has disabled blog functionality for this specific user.').'</li>'.
337: '<li>'.&mt('The domain has been configured to disable, by default, blog functionality for all users in the domain.').'</li>'.
338: '</ul>';
339: } else {
340: $disabletext = &mt('No user blog available');
341: }
342: }
343: }
344: if ($html) {
345: # my $title = $displayfeedname?$displayfeedname:"Available RSS Feeds and Blogs";
346: my $title = "My Space";
347: my $rss_link = &Apache::lonrss::rss_link($uname,$udom);
348: my $brcrumb = [{href=>$rss_link,text=>"Available RSS Feeds and Blogs"}];
349: $r->print(&Apache::loncommon::start_page($title,$rss_link,
350: {'bread_crumbs' => $brcrumb,
351: 'domain' => $udom,
352: 'force_register' => $env{'form.register'}}).
353: &changed_js());
354: } else { # render RSS
355: my $server = &Apache::lonnet::absolute_url();
356: $r->print("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1'>\n<channel>".
357: "\n".'<link>'.$server.'/public/'.$udom.'/'.$uname.'/'.
358: $filterfeedname.'_rss.html</link>'.
359: "\n<description>".
360: &mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').
361: '</description>');
362: }
363: # This will be the entry id for new additions to the blog
364: my $newid = &get_new_feed_id();
365: # Is this user for real?
366: my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
367: if ($html && !$blocked && !$disabled) {
368: # Any new feeds or renaming of feeds?
369: if ($edit) {
370: # Hide a feed?
371: if ($env{'form.hidethisblog'}) {
372: &changefeeddisplay($feedname,$uname,$udom,'hidden');
373: ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
374: }
375: # Advertise a feed?
376: if ($env{'form.advertisethisblog'}) {
377: &changefeeddisplay($feedname,$uname,$udom,'public');
378: ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
379: }
380: # New feed?
381: if ($env{'form.namenewblog'}=~/\w/) {
382: &namefeed($env{'form.namenewblog'},$uname,$udom,$env{'form.namenewblog'});
383: }
384: # Old feed that is being renamed?
385: if (($displayfeedname) && ($env{'form.newblogname'}=~/\w/)) {
386: if ($env{'form.newblogname'} ne $displayfeedname) {
387: &namefeed($feedname,$uname,$udom,$env{'form.newblogname'});
388: ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
389: }
390: }
391: }
392: $r->print(&advertisefeeds($uname,$udom,$edit));
393: }
394: if ($homeserver eq 'no_host') {
395: $r->print(($html?'<h3>':'<title>').&mt('No feed available').($html?'</h3>':'</title>'));
396: } elsif ($blocked) {
397: $r->print($blocktext);
398: $r->print(($html?&Apache::loncommon::end_page():'</channel></rss>'."\n"));
399: } elsif ($disabled) {
400: $r->print($disabletext);
401: $r->print(($html?&Apache::loncommon::end_page():'</channel></rss>'."\n"));
402: } else { # is indeed a user
403: # Course or user?
404: my $name='';
405: if (&Apache::lonnet::is_course($udom,$uname)) {
406: my %cenv=&Apache::lonnet::dump('environment',$udom,$uname);
407: $name=$cenv{'description'};
408: } else {
409: $name=&Apache::loncommon::nickname($uname,$udom);
410: }
411: # Add a new feed
412: if (($html) && ($edit)) {
413: $r->print('<h4>' . &mt('New RSS Feed or Blog'). '</h4>');
414: $r->print('<form method="post" name="makenewfeed">');
415: $r->print(&mt('Name').": <input type='text' size='40' name='namenewblog' />");
416: $r->print('<input type="submit" value="'.&mt('New Feed').'" />');
417: $r->print('</form>');
418: }
419: if ($displayfeedname) { # this is an existing feed
420: # Anything to store?
421: if ($edit) {
422: # check if this was called with a query string
423: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['queryid']);
424: if ($env{'form.queryid'}) {
425: # yes, collect the remainder
426: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
427: ['title',
428: 'description',
429: 'url',
430: 'status',
431: 'enclosureurl',
432: 'enclosuretype']);
433:
434: # my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype)=@_;
435:
436:
437: &editentry($env{'form.queryid'},
438: $uname,$udom,$filename,
439: $env{'form.title'},
440: $env{'form.description'},
441: $env{'form.url'},
442: $env{'form.status'},
443: $env{'form.encurl'},
444: $env{'form.enctype'}
445: );
446: }
447:
448: # store away the fields modified in the online form
449: my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
450: foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
451: if ($entry=~/^(\d+)\_status$/) {
452: my $id=$1;
453: if ($env{'form.'.$id.'_modified'}) {
454: &editentry($id,$uname,$udom,$feedname,
455: $env{'form.'.$id.'_title'},
456: $env{'form.'.$id.'_description'},
457: $env{'form.'.$id.'_link'},
458: $env{'form.'.$id.'_status'},
459: $env{'form.'.$id.'_enclosureurl'},
460: $env{'form.'.$id.'_enclosuretype'},
461: );
462: }
463: }
464: }
465:
466: # see if we have any uploaded or portfolio files
467: my @uploadeditems=();
468:
469: if ($env{'form.HWFILE0_0'}) {
470: # We have an uploaded file - store it away.
471: $uploadeditems[0]=&Apache::lonnet::userfileupload('HWFILE0_0',undef,'portfolio/podcasts');
472: }
473: if ($env{'form.HWPORT0_0'}) {
474: # Selected portfolio files
475: foreach my $filename (split(/\,/,$env{'form.HWPORT0_0'})) {
476: if ($filename) {
477: # construct full path and remember
478: push(@uploadeditems,'/uploaded/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/portfolio'.$filename);
479: }
480: }
481: }
482: # the zeroth item should be stored together with the last displayed (newid) field
483: if ($uploadeditems[0]) {
484: my $id=$env{'form.newid'};
485: &editentry($id,$uname,$udom,$feedname,
486: $env{'form.'.$id.'_title'},
487: $env{'form.'.$id.'_description'},
488: $env{'form.'.$id.'_link'},
489: $env{'form.'.$id.'_status'},
490: $uploadeditems[0],
491: &Apache::loncommon::filemimetype(($uploadeditems[0]=~/\.(\w+)$/)[0]),
492: );
493: &Apache::lonnet::make_public_indefinitely($uploadeditems[0]);
494: }
495: # if there are more files, they need new entries, since each can only have one enclosure
496: for (my $i=1; $i<=$#uploadeditems; $i++) {
497: my $id = &get_new_feed_id().$i;
498: &editentry($id,$uname,$udom,$feedname,
499: 'New Entry',
500: '',
501: '',
502: 'public',
503: $uploadeditems[$i],
504: &Apache::loncommon::filemimetype(($uploadeditems[$i]=~/\.(\w+)$/)[0]),
505: );
506: &Apache::lonnet::make_public_indefinitely($uploadeditems[$i]);
507: }
508: } #done storing
509:
510: # Render private items?
511: my $viewpubliconly=1;
512: $r->print("\n".
513: ($html?'<hr /><h3>':'<title>').
514: &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
515: ($displayoption eq 'hidden'?' ('.&mt('Hidden').')':'').
516: ($html?'</h3>'.($edit?'<form method="post" name="lonhomework" enctype="multipart/form-data"><br />'.
517: &mt('Name of this Feed').
518: ': <input type="text" size="50" name="newblogname" value="'.
519: $displayfeedname.'" />':'').'<ul>':'</title>'));
520: if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
521: $viewpubliconly=0;
522: }
523: # Get feed items
524: my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
525: foreach my $entry (sort {$b cmp $a} (keys(%newsfeed)),$newid.'_status') {
526: if ($entry=~/^(\d+)\_status$/) { # is an entry
527: my $id=$1;
528: if ($edit) {
529: my %lt=&Apache::lonlocal::texthash('public' => 'public',
530: 'private' => 'private',
531: 'hidden' => 'hidden',
532: 'delete' => 'delete',
533: 'store' => 'Select',
534: 'title' => 'Title',
535: 'link' => 'Link',
536: 'description' => 'Description',
537: 'enc' => 'Podcasted enclosure');
538: my $uploadlink;
539: if ($entry==$newid) {
540: # Generate upload link only for last (new) entry
541: $uploadlink=&Apache::inputtags::file_selector(0,0,'*','both');
542: } else {
543: # Otherwise, display
544: $uploadlink='<tt>'.$newsfeed{$id.'_enclosureurl'}.'</tt>'.
545: "<input type='hidden' name='$id\_enclosureurl' value='$newsfeed{$id.'_enclosureurl'}' />".
546: "<input type='hidden' name='$id\_enclosuretype' value='$newsfeed{$id.'_enclosuretype'}' />";
547: }
548: my %status=();
549: unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }
550: $status{$newsfeed{$id.'_status'}}='checked="checked"';
551: $r->print(<<ENDEDIT);
552: <li>
553: <label><input name='$id\_modified' type='checkbox' value="modified" /> $lt{'store'}</label>
554:
555: <label><input name='$id\_status' type="radio" value="public" $status{'public'} onClick="changed(this.form,'$id');" /> $lt{'public'}</label>
556:
557: <label><input name='$id\_status' type="radio" value="private" $status{'private'} onClick="changed(this.form,'$id');" /> $lt{'private'}</label>
558:
559: <label><input name='$id\_status' type="radio" value="hidden" $status{'hidden'} onClick="changed(this.form,'$id');" /> $lt{'hidden'}</label>
560:
561: <label><input name='$id\_status' type="radio" value="deleted" onClick="changed(this.form,'$id');" /> $lt{'delete'}</label>
562: <br />
563: $lt{'title'}:
564: <input name='$id\_title' type='text' size='60' value='$newsfeed{$id.'_title'}' onChange="changed(this.form,'$id');" /><br />
565: $lt{'description'}:<br />
566: <textarea name='$id\_description' rows="6" cols="80" onChange="changed(this.form,'$id');">$newsfeed{$id.'_description'}</textarea><br />
567: $lt{'link'}:
568: <input name='$id\_link' type='text' size='60' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" /><br />
569: $lt{'enc'} -
570: $uploadlink
571: <hr /></li>
572: ENDEDIT
573: } else { # not in edit mode, just displaying
574: if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
575: if ($newsfeed{$id.'_status'} eq 'hidden') { next; }
576: my $link = $newsfeed{$id.'_link'};
577: if ($link =~ m|^/| ) {
578: $link = "http://".$ENV{'HTTP_HOST'}.$link;
579: }
580: $r->print("\n".($html?"\n<li><b>":"<item>\n<title>").$newsfeed{$id.'_title'}.
581: ($html?"</b><br />\n":"</title>\n<description>").
582: $newsfeed{$id.'_description'}.
583: ($html?"<br />":"</description>\n").
584: ($link?($html?"\n<a href='":"<link>").
585: $link.
586: ($html?("'>".&mt('Read more')."</a><br />\n"):"</link>\n"):''));
587: my $enclosure=$newsfeed{$id.'_enclosureurl'};
588: # Enclosure? Get stats
589: if ($enclosure) {
590: my @stat=&Apache::lonnet::stat_file($enclosure);
591: if ($stat[7]) {
592: # Has non-zero length (and exists)
593: my $enclosuretype=$newsfeed{$id.'_enclosuretype'};
594: if ($enclosure =~ m|^/| ) {
595: $enclosure = "http://".$ENV{'HTTP_HOST'}.$enclosure;
596: }
597: $r->print(($html?"<a href='":"\n<enclosure url='").
598: $enclosure."' length='".$stat[7].
599: "' type='".$enclosuretype.($html?"'>".&mt('Enclosure')."</a>":"' />"));
600: }
601: }
602: if ($html) { # is HTML
603: $r->print("\n<hr /></li>\n");
604: } else { # is RSS
605: $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
606: }
607: } # end of "in edit mode"
608: } # end of rendering a real entry
609: } # end of loop through all keys
610: if ($html) {
611: $r->print('</ul>');
612: if ($edit) {
613: $r->print('<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Save Selected').'" />'.
614: ($displayoption eq 'hidden'?'<input type="submit" name="advertisethisblog" value="'.&mt('Advertise this Feed').'" />':
615: '<input type="submit" name="hidethisblog" value="'.&mt('Hide this Feed').'" />'));
616: }
617: }
618: } # was a real display feedname
619: $r->print(($html?'</form>'.&Apache::loncommon::end_page():'</channel></rss>'."\n"));
620: } # a real user
621: return OK;
622: } # end handler
623: 1;
624: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>