[LON-CAPA-cvs] cvs: loncom /interface lonrss.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 18 Jan 2007 19:02:05 -0000
www Thu Jan 18 14:02:05 2007 EDT
Modified files:
/loncom/interface lonrss.pm
Log:
Podcasting works with iTunes
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.32 loncom/interface/lonrss.pm:1.33
--- loncom/interface/lonrss.pm:1.32 Sat Dec 9 18:33:55 2006
+++ loncom/interface/lonrss.pm Thu Jan 18 14:02:00 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# RSS Feeder
#
-# $Id: lonrss.pm,v 1.32 2006/12/09 23:33:55 albertel Exp $
+# $Id: lonrss.pm,v 1.33 2007/01/18 19:02:00 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,7 @@
use Apache::lontexconvert;
use Apache::lonlocal;
use Apache::lonhtmlcommon;
-
+use Apache::inputtags();
sub filterfeedname {
my $filename=shift;
@@ -355,7 +355,7 @@
}
# Add a new feed
if (($html) && ($edit)) {
- $r->print('<form method="post">');
+ $r->print('<form method="post" name="makenewfeed">');
$r->print(&mt('Name for New Feed').": <input type='text' size='40' name='namenewblog' />");
$r->print('<input type="submit" value="'.&mt('Start a New Feed').'" />');
$r->print('</form>');
@@ -374,8 +374,10 @@
'status',
'enclosureurl',
'enclosuretype']);
+
# my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype)=@_;
+
&editentry($env{'form.queryid'},
$uname,$udom,$filename,
$env{'form.title'},
@@ -386,6 +388,8 @@
$env{'form.enctype'}
);
}
+
+# store away the fields modified in the online form
my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
if ($entry=~/^(\d+)\_status$/) {
@@ -402,6 +406,49 @@
}
}
}
+
+# see if we have any uploaded or portfolio files
+ my @uploadeditems=();
+
+ if ($env{'form.HWFILE0_0'}) {
+# We have an uploaded file - store it away.
+ $uploadeditems[0]=&Apache::lonnet::userfileupload('HWFILE0_0',undef,'portfolio/podcasts');
+ }
+ if ($env{'form.HWPORT0_0'}) {
+# Selected portfolio files
+ foreach my $filename (split(/\,/,$env{'form.HWPORT0_0'})) {
+ if ($filename) {
+# construct full path and remember
+ push(@uploadeditems,'/uploaded/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/portfolio'.$filename);
+ }
+ }
+ }
+# the zeroth item should be stored together with the last displayed (newid) field
+ if ($uploadeditems[0]) {
+ my $id=$env{'form.newid'};
+ &editentry($id,$uname,$udom,$feedname,
+ $env{'form.'.$id.'_title'},
+ $env{'form.'.$id.'_description'},
+ $env{'form.'.$id.'_link'},
+ $env{'form.'.$id.'_status'},
+ $uploadeditems[0],
+ &Apache::loncommon::filemimetype(($uploadeditems[0]=~/\.(\w+)$/)[0]),
+ );
+ &Apache::lonnet::make_public_indefinitely($uploadeditems[0]);
+ }
+# if there are more files, they need new entries, since each can only have one enclosure
+ for (my $i=1; $i<=$#uploadeditems; $i++) {
+ my $id = &get_new_feed_id().$i;
+ &editentry($id,$uname,$udom,$feedname,
+ 'New Entry',
+ '',
+ '',
+ 'public',
+ $uploadeditems[$i],
+ &Apache::loncommon::filemimetype(($uploadeditems[$i]=~/\.(\w+)$/)[0]),
+ );
+ &Apache::lonnet::make_public_indefinitely($uploadeditems[$i]);
+ }
} #done storing
# Render private items?
@@ -410,7 +457,7 @@
($html?'<hr /><h3>':'<title>').
&mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
($displayoption eq 'hidden'?' ('.&mt('Hidden').')':'').
- ($html?'</h3>'.($edit?'<form method="post"><br />'.
+ ($html?'</h3>'.($edit?'<form method="post" name="lonhomework" enctype="multipart/form-data"><br />'.
&mt('Name of this Feed').
': <input type="text" size="50" name="newblogname" value="'.
$displayfeedname.'" />':'').'<ul>':'</title>'));
@@ -430,7 +477,18 @@
'store' => 'Store changes',
'title' => 'Title',
'link' => 'Link',
- 'description' => 'Description');
+ 'description' => 'Description',
+ 'enc' => 'Podcasted enclosure');
+ my $uploadlink;
+ if ($entry==$newid) {
+# Generate upload link only for last (new) entry
+ $uploadlink=&Apache::inputtags::file_selector(0,0,'*','both');
+ } else {
+# Otherwise, display
+ $uploadlink='<tt>'.$newsfeed{$id.'_enclosureurl'}.'</tt>'.
+ "<input type='hidden' name='$id\_enclosureurl' value='$newsfeed{$id.'_enclosureurl'}' />".
+ "<input type='hidden' name='$id\_enclosuretype' value='$newsfeed{$id.'_enclosuretype'}' />";
+ }
my %status=();
unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }
$status{$newsfeed{$id.'_status'}}='checked="checked"';
@@ -451,7 +509,9 @@
$lt{'description'}:<br />
<textarea name='$id\_description' rows="6" cols="80" onChange="changed(this.form,'$id');">$newsfeed{$id.'_description'}</textarea><br />
$lt{'link'}:
-<input name='$id\_link' type='text' size='60' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" />
+<input name='$id\_link' type='text' size='60' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" /><br />
+$lt{'enc'} -
+$uploadlink
<hr /></li>
ENDEDIT
} else { # not in edit mode, just displaying
@@ -464,18 +524,22 @@
$r->print("\n".($html?"\n<li><b>":"<item>\n<title>").$newsfeed{$id.'_title'}.
($html?"</b><br />\n":"</title>\n<description>").
$newsfeed{$id.'_description'}.
- ($html?"<br />\n<a href='":"</description>\n<link>").
-
+ ($html?"<br />":"</description>\n").
+ ($link?($html?"\n<a href='":"<link>").
$link.
- ($html?("'>".&mt('Read more')."</a><br />\n"):"</link>\n"));
+ ($html?("'>".&mt('Read more')."</a><br />\n"):"</link>\n"):''));
+ my $enclosure=$newsfeed{$id.'_enclosureurl'};
# Enclosure? Get stats
- if ($newsfeed{$id.'_enclosureurl'}) {
- my @stat=&Apache::lonnet::stat_file($newsfeed{$id.'_enclosureurl'});
+ if ($enclosure) {
+ my @stat=&Apache::lonnet::stat_file($enclosure);
if ($stat[7]) {
# Has non-zero length (and exists)
- my $enclosuretype=$newsfeed{$id.'_enclosetype'};
+ my $enclosuretype=$newsfeed{$id.'_enclosuretype'};
+ if ($enclosure =~ m|^/| ) {
+ $enclosure = "http://".$ENV{'HTTP_HOST'}.$enclosure;
+ }
$r->print(($html?"<a href='":"\n<enclosure url='").
- $newsfeed{$id.'_enclosureurl'}."' length='".$stat[7].
+ $enclosure."' length='".$stat[7].
"' type='".$enclosuretype.($html?"'>".&mt('Enclosure')."</a>":"' />"));
}
}