version 1.77, 2003/09/09 19:39:04
|
version 1.80, 2003/09/17 21:20:15
|
Line 136 sub dumpcourse {
|
Line 136 sub dumpcourse {
|
# Do the dumping |
# Do the dumping |
unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; } |
unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; } |
my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'}); |
my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'}); |
|
$r->print('<h3>Copying Files</h3>'); |
my $title=$ENV{'form.authorfolder'}; |
my $title=$ENV{'form.authorfolder'}; |
|
$title=~s/[^\w\/]+/\_/g; |
|
my %replacehash=(); |
|
foreach (keys %ENV) { |
|
if ($_=~/^form\.namefor\_(.+)/) { |
|
$replacehash{$1}=$ENV{$_}; |
|
} |
|
} |
|
my $crs='/uploaded/'.$ENV{'request.course.id'}.'/'; |
|
$crs=~s/\_/\//g; |
|
foreach (keys %replacehash) { |
|
my $newfilename=$title.'/'.$replacehash{$_}; |
|
$newfilename=~s/[^\w\/\.]+/\_/g; |
|
my @dirs=split(/\//,$newfilename); |
|
my $path='/home/'.$ca.'/public_html'; |
|
my $makepath=$path; |
|
my $fail=0; |
|
for (my $i=0;$i<$#dirs;$i++) { |
|
$makepath.='/'.$dirs[$i]; |
|
unless (-e $makepath) { |
|
unless(mkdir($makepath,0777)) { $fail=1; } |
|
} |
|
} |
|
$r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: '); |
|
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
|
if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) { |
|
print $fh &Apache::loncreatecourse::rewritefile( |
|
&Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_), |
|
(%replacehash,$crs => '') |
|
); |
|
} else { |
|
print $fh |
|
&Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_); |
|
} |
|
$fh->close(); |
|
} else { |
|
$fail=1; |
|
} |
|
if ($fail) { |
|
$r->print('<font color="red">fail</font>'); |
|
} else { |
|
$r->print('<font color="green">ok</font>'); |
|
} |
|
} |
} else { |
} else { |
# Input form |
# Input form |
unless ($home==1) { |
unless ($home==1) { |
Line 162 sub dumpcourse {
|
Line 205 sub dumpcourse {
|
$title=~s/\W//gs; |
$title=~s/\W//gs; |
$r->print('<h3>Folder in Construction Space</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />'); |
$r->print('<h3>Folder in Construction Space</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />'); |
&tiehash(); |
&tiehash(); |
|
$r->print('<h3>Filenames in Construction Space</h3><table border="2"><tr><th>Internal Filename</th><th>Title</th><th>Save as ...</th></tr>'); |
foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) { |
foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) { |
$r->print("\n<br />".$_.' '. |
$r->print('<tr><td>'.$_.'</td>'); |
$hash{'title_'.$hash{ |
my ($ext)=($_=~/\.(\w+)$/); |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}} |
my $title=$hash{'title_'.$hash{ |
); |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}}; |
|
$r->print('<td>'.($title?$title:' ').'</td>'); |
|
unless ($title) { |
|
$title=$_; |
|
} |
|
$title=~s/\.(\w+)$//; |
|
$title=~s/\W+/\_/gs; |
|
$title.='.'.$ext; |
|
$r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n"); |
} |
} |
|
$r->print("</table>\n"); |
&untiehash(); |
&untiehash(); |
$r->print( |
$r->print( |
'<input type="submit" name="dumpcourse" value="Dump Course DOCS" /></form>'); |
'<p><input type="submit" name="dumpcourse" value="Dump Course DOCS" /></p></form>'); |
} |
} |
} |
} |
|
|
Line 195 sub group_import {
|
Line 248 sub group_import {
|
join ':', ($name, $url, $ext, 'normal', 'res'); |
join ':', ($name, $url, $ext, 'normal', 'res'); |
} |
} |
} |
} |
&storemap($coursenum, $coursedom, $folder); |
&storemap($coursenum, $coursedom, $folder.'.sequence'); |
} |
} |
|
|
sub editor { |
sub editor { |