version 1.484.2.50, 2014/02/24 17:10:37
|
version 1.604, 2016/06/06 17:40:48
|
Line 46 use Apache::lonsimplepage();
|
Line 46 use Apache::lonsimplepage();
|
use HTML::Entities; |
use HTML::Entities; |
use HTML::TokeParser; |
use HTML::TokeParser; |
use GDBM_File; |
use GDBM_File; |
|
use File::MMagic; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Cwd; |
use Cwd; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
Line 195 ENDJS
|
Line 196 ENDJS
|
} else { |
} else { |
&Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles, |
&Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles, |
'dumpdocs',$cdom,$cnum); |
'dumpdocs',$cdom,$cnum); |
} |
} |
my @todump = &Apache::loncommon::get_env_multiple('form.archive'); |
my @todump = &Apache::loncommon::get_env_multiple('form.archive'); |
my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages, |
my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages, |
%newcontent,%has_simpleprobs); |
%newcontent,%has_simpleprobs); |
Line 206 ENDJS
|
Line 207 ENDJS
|
if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) { |
if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) { |
$tocopy{$1} = $name; |
$tocopy{$1} = $name; |
$display{$item} = $1; |
$display{$item} = $1; |
$lookup{$1} = $item; |
$lookup{$1} = $item; |
} elsif ($res eq 'lib/templates/simpleproblem.problem') { |
} elsif ($res eq 'lib/templates/simpleproblem.problem') { |
$simpleproblems{$item} = { |
$simpleproblems{$item} = { |
symb => $resources{$item}, |
symb => $resources{$item}, |
Line 306 $contents{content}.'
|
Line 307 $contents{content}.'
|
</div>'; |
</div>'; |
} |
} |
if ($contents{webreferences}) { |
if ($contents{webreferences}) { |
$content .= ' |
$content .= ' |
<div class="LC_Box"> |
<div class="LC_Box"> |
<h4 class="LC_hcell">'.&mt('Web References').'</h4>'. |
<h4 class="LC_hcell">'.&mt('Web References').'</h4>'. |
$contents{webreferences}.' |
$contents{webreferences}.' |
Line 316 $contents{webreferences}.'
|
Line 317 $contents{webreferences}.'
|
</body> |
</body> |
</html> |
</html> |
'; |
'; |
$newcontent{'/'.$simplepages{$item}{res}} = $content; |
$newcontent{'/'.$simplepages{$item}{res}} = $content; |
} |
} |
} |
} |
foreach my $item (keys(%tocopy)) { |
foreach my $item (keys(%tocopy)) { |
unless ($item=~/\.(sequence|page)$/) { |
unless ($item=~/\.(sequence|page)$/) { |
my $currurlpath = $prefix.$item; |
my $currurlpath = $prefix.$item; |
my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath); |
my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath); |
Line 350 $contents{webreferences}.'
|
Line 351 $contents{webreferences}.'
|
if ($simpleproblems{$num}) { |
if ($simpleproblems{$num}) { |
$newfilename=$title.'/'.$simpleproblems{$num}{'name'}; |
$newfilename=$title.'/'.$simpleproblems{$num}{'name'}; |
} else { |
} else { |
$newfilename=$title.'/'.$replacehash{$item}; |
$newfilename=$title.'/'.$replacehash{$item}; |
} |
} |
$newfilename=~s/\.(\w+)$//; |
$newfilename=~s/\.(\w+)$//; |
my $ext=$1; |
my $ext=$1; |
$newfilename=&clean($newfilename); |
$newfilename=&clean($newfilename); |
$newfilename.='.'.$ext; |
$newfilename.='.'.$ext; |
my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); |
my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); |
if ($newrelpath ne $replacehash{$item}) { |
if ($newrelpath ne $replacehash{$item}) { |
$replacehash{$item} = $newrelpath; |
$replacehash{$item} = $newrelpath; |
} |
} |
my @dirs=split(/\//,$newfilename); |
my @dirs=split(/\//,$newfilename); |
my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; |
my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; |
my $makepath=$path; |
my $makepath=$path; |
my $fail; |
my $fail; |
my $origin; |
my $origin; |
for (my $i=0;$i<$#dirs;$i++) { |
for (my $i=0;$i<$#dirs;$i++) { |
$makepath.='/'.$dirs[$i]; |
$makepath.='/'.$dirs[$i]; |
unless (-e $makepath) { |
unless (-e $makepath) { |
unless(mkdir($makepath,0755)) { |
unless(mkdir($makepath,0755)) { |
$fail = &mt('Directory creation failed.'); |
$fail = &mt('Directory creation failed.'); |
} |
} |
} |
} |
} |
} |
if ($i == 0) { |
if ($i == 0) { |
$result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '; |
$result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '; |
} else { |
} else { |
$depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '. |
$depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '. |
'<span class="LC_fontsize_small" style="font-weight: bold;">'. |
'<span class="LC_fontsize_small" style="font-weight: bold;">'. |
&mt('(dependency)').'</span>: '; |
&mt('(dependency)').'</span>: '; |
} |
} |
if (-e $path.'/'.$newfilename) { |
if (-e $path.'/'.$newfilename) { |
$fail = &mt('Destination already exists -- not overwriting.'); |
$fail = &mt('Destination already exists -- not overwriting.'); |
} else { |
} else { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) || |
if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) || |
($item =~ /^simpleproblem_/)) { |
($item =~ /^simpleproblem_/)) { |
Line 404 $contents{webreferences}.'
|
Line 405 $contents{webreferences}.'
|
while (my $token = $parser->get_token) { |
while (my $token = $parser->get_token) { |
if ($token->[0] eq 'S') { |
if ($token->[0] eq 'S') { |
if (($token->[1] eq 'resource') && |
if (($token->[1] eq 'resource') && |
($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && |
($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && |
($changes{$token->[2]->{'id'}})) { |
($changes{$token->[2]->{'id'}})) { |
my $id = $token->[2]->{'id'}; |
my $id = $token->[2]->{'id'}; |
$updatedcontent .= '<'.$token->[1]; |
$updatedcontent .= '<'.$token->[1]; |
foreach my $attrib (@{$token->[3]}) { |
foreach my $attrib (@{$token->[3]}) { |
next unless ($attrib =~ /^(src|type|title|id)$/); |
next unless ($attrib =~ /^(src|type|title|id)$/); |
if ($attrib eq 'src') { |
if ($attrib eq 'src') { |
my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); |
my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); |
if ($file) { |
if ($file) { |
$updatedcontent .= ' '.$attrib.'="'.$file.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$file.'"'; |
} else { |
} else { |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
} |
} |
} else { |
} else { |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
Line 430 $contents{webreferences}.'
|
Line 431 $contents{webreferences}.'
|
} |
} |
} |
} |
print $fh $updatedcontent; |
print $fh $updatedcontent; |
} else { |
} else { |
print $fh &Apache::lonclonecourse::rewritefile( |
print $fh &Apache::lonclonecourse::rewritefile( |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
(%replacehash,$crs => '') |
(%replacehash,$crs => '') |
); |
); |
} |
} |
} else { |
} else { |
print $fh |
print $fh |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
} |
} |
} else { |
} else { |
$fail = &mt('Source does not exist.'); |
$fail = &mt('Source does not exist.'); |
} |
} |
} |
} |
$fh->close(); |
$fh->close(); |
} else { |
} else { |
$fail = &mt('Could not write to destination.'); |
$fail = &mt('Could not write to destination.'); |
} |
} |
} |
} |
my $text; |
my $text; |
if ($fail) { |
if ($fail) { |
$text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>'; |
$text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>'; |
} else { |
} else { |
$text = '<span class="LC_success">'.&mt('ok').'</span>'; |
$text = '<span class="LC_success">'.&mt('ok').'</span>'; |
} |
} |
if ($i == 0) { |
if ($i == 0) { |
$result .= $text; |
$result .= $text; |
} else { |
} else { |
$depresult .= $text.'</li>'; |
$depresult .= $text.'</li>'; |
} |
} |
} |
} |
$r->print($result); |
$r->print($result); |
if ($depresult) { |
if ($depresult) { |
Line 476 $contents{webreferences}.'
|
Line 477 $contents{webreferences}.'
|
$r->rflush(); |
$r->rflush(); |
my ($preamble,$formname); |
my ($preamble,$formname); |
$formname = 'dumpdoc'; |
$formname = 'dumpdoc'; |
unless ($home==1) { |
unless ($home==1) { |
$preamble = '<div class="LC_left_float">'. |
$preamble = '<div class="LC_left_float">'. |
'<fieldset><legend>'. |
'<fieldset><legend>'. |
&mt('Select the Authoring Space'). |
&mt('Select the Authoring Space'). |
'</legend><select name="authorspace">'; |
'</legend><select name="authorspace">'; |
} |
} |
my @orderspaces = (); |
my @orderspaces = (); |
foreach my $key (sort(keys(%outhash))) { |
foreach my $key (sort(keys(%outhash))) { |
if ($key=~/^home_(.+)$/) { |
if ($key=~/^home_(.+)$/) { |
if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) { |
if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) { |
unshift(@orderspaces,$1); |
unshift(@orderspaces,$1); |
} else { |
} else { |
push(@orderspaces,$1); |
push(@orderspaces,$1); |
} |
} |
} |
} |
} |
} |
if ($home>1) { |
if ($home>1) { |
$preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>'; |
$preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>'; |
} |
} |
foreach my $user (@orderspaces) { |
foreach my $user (@orderspaces) { |
if ($home==1) { |
if ($home==1) { |
$preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />'; |
$preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />'; |
} else { |
} else { |
$preamble .= '<option value="'.$user.'">'.$user.' - '. |
$preamble .= '<option value="'.$user.'">'.$user.' - '. |
&Apache::loncommon::plainname(split(/\:/,$user)).'</option>'; |
&Apache::loncommon::plainname(split(/\:/,$user)).'</option>'; |
} |
} |
} |
} |
unless ($home==1) { |
unless ($home==1) { |
$preamble .= '</select></fieldset></div>'."\n"; |
$preamble .= '</select></fieldset></div>'."\n"; |
} |
} |
my $title=$origcrsdata{'description'}; |
my $title=$origcrsdata{'description'}; |
$title=~s/[\/\s]+/\_/gs; |
$title=~s/[\/\s]+/\_/gs; |
$title=&clean($title); |
$title=&clean($title); |
$preamble .= '<div class="LC_left_float">'. |
$preamble .= '<div class="LC_left_float">'. |
'<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'. |
'<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'. |
'<input type="text" size="50" name="authorfolder" value="'. |
'<input type="text" size="50" name="authorfolder" value="'. |
$title.'" />'. |
$title.'" />'. |
'</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n"; |
'</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n"; |
my %uploadedfiles; |
my %uploadedfiles; |
&tiehash(); |
&tiehash(); |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
my ($ext)=($file=~/\.(\w+)$/); |
my ($ext)=($file=~/\.(\w+)$/); |
# FIXME Check supplemental here |
# FIXME Check supplemental here |
my $title=$hash{'title_'.$hash{ |
my $title=$hash{'title_'.$hash{ |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
if (!$title) { |
if (!$title) { |
$title=$file; |
$title=$file; |
} else { |
} else { |
$title=~s|/|_|g; |
$title=~s|/|_|g; |
} |
} |
$title=~s/\.(\w+)$//; |
$title=~s/\.(\w+)$//; |
$title=&clean($title); |
$title=&clean($title); |
$title.='.'.$ext; |
$title.='.'.$ext; |
# $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
# $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
$uploadedfiles{$file} = $title; |
$uploadedfiles{$file} = $title; |
} |
} |
&untiehash(); |
&untiehash(); |
$r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef, |
$r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef, |
undef,undef,$preamble,$home,\%uploadedfiles)); |
undef,undef,$preamble,$home,\%uploadedfiles)); |
} |
} |
Line 563 sub recurse_html {
|
Line 564 sub recurse_html {
|
} else { |
} else { |
$relfile = $dependency; |
$relfile = $dependency; |
$depurl = $currurlpath; |
$depurl = $currurlpath; |
$depurl =~ s{[^/]+$}{}; |
$depurl =~ s{[^/]+$}{}; |
$depurl .= $dependency; |
$depurl .= $dependency; |
($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); |
($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); |
} |
} |
next if ($relfile eq ''); |
next if ($relfile eq ''); |
my $newname = $replacehash->{$container}; |
my $newname = $replacehash->{$container}; |
$newname =~ s{[^/]+$}{}; |
$newname =~ s{[^/]+$}{}; |
$replacehash->{$newcontainer} = $newname.$relfile; |
$replacehash->{$newcontainer} = $newname.$relfile; |
$deps->{$item}{$newcontainer} = 1; |
$deps->{$item}{$newcontainer} = 1; |
my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); |
my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); |
my $depfile = &Apache::lonnet::filelocation('',$depurl); |
my $depfile = &Apache::lonnet::filelocation('',$depurl); |
my $type = $mm->checktype_filename($depfile); |
my $type = $mm->checktype_filename($depfile); |
if ($type eq 'text/html') { |
if ($type eq 'text/html') { |
Line 585 sub recurse_html {
|
Line 586 sub recurse_html {
|
} |
} |
|
|
sub group_import { |
sub group_import { |
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; |
my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_; |
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap, |
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap, |
%removeparam,$importuploaded,$fixuperrors); |
%removeparam,$importuploaded,$fixuperrors); |
$allmaps = {}; |
$allmaps = {}; |
Line 614 sub group_import {
|
Line 615 sub group_import {
|
} |
} |
} |
} |
if ($url) { |
if ($url) { |
|
if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/exttool)s?\:?(.*)$}) { |
|
$url = $1; |
|
my $marker = $2; |
|
my $info = $3; |
|
my ($toolid,%toolhash,%toolsettings); |
|
my @toolinfo = split(/:/,$info); |
|
if ($residx) { |
|
%toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); |
|
$toolid = $toolsettings{'id'}; |
|
} else { |
|
$toolid = shift(@toolinfo); |
|
} |
|
$toolid =~ s/\D//g; |
|
($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}, |
|
$toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo; |
|
$toolhash{'crslabel'} = &unescape($toolhash{'crslabel'}); |
|
$toolhash{'crstitle'} = &unescape($toolhash{'crstitle'}); |
|
if (ref($ltitoolsref) eq 'HASH') { |
|
my @deleted; |
|
if (ref($ltitoolsref->{$toolid}) eq 'HASH') { |
|
if ($ltitoolsref->{$toolid}->{'url'} =~ m{^https://}) { |
|
$url =~ s/exttool$/exttools/; |
|
} |
|
$toolhash{'id'} = $toolid; |
|
if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'window')) { |
|
if ($toolhash{'target'} eq 'window') { |
|
foreach my $item ('width','height') { |
|
$toolhash{$item} =~ s/^\s+//; |
|
$toolhash{$item} =~ s/\s+$//; |
|
} |
|
} |
|
} elsif ($residx) { |
|
$toolhash{'target'} = $toolsettings{'target'}; |
|
if ($toolhash{'target'} eq 'window') { |
|
$toolhash{'width'} = $toolsettings{'width'}; |
|
$toolhash{'height'} = $toolsettings{'height'}; |
|
} |
|
} elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') { |
|
$toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'}; |
|
if ($toolhash{'target'} eq 'window') { |
|
$toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'}; |
|
$toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'}; |
|
} |
|
} |
|
if ($toolhash{'target'} eq 'iframe') { |
|
delete($toolhash{'width'}); |
|
delete($toolhash{'height'}); |
|
if ($residx) { |
|
if ($toolsettings{'width'}) { |
|
push(@deleted,'width'); |
|
} |
|
if ($toolsettings{'height'}) { |
|
push(@deleted,'height'); |
|
} |
|
} |
|
} |
|
if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') { |
|
foreach my $item ('label','title') { |
|
if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) { |
|
$toolhash{'crs'.$item} =~ s/^\s+//; |
|
$toolhash{'crs'.$item} =~ s/\s+$//; |
|
if ($toolhash{'crs'.$item} eq '') { |
|
delete($toolhash{'crs'.$item}); |
|
} |
|
} else { |
|
delete($toolhash{'crs'.$item}); |
|
} |
|
if (($residx) && (exists($toolsettings{'crs'.$item}))) { |
|
unless (exists($toolhash{'crs'.$item})) { |
|
push(@deleted,'crs'.$item); |
|
} |
|
} |
|
} |
|
} |
|
my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum); |
|
if ($putres eq 'ok') { |
|
if (@deleted) { |
|
&Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum); |
|
} |
|
} |
|
} |
|
} |
|
} |
if (($caller eq 'londocs') && |
if (($caller eq 'londocs') && |
($folder =~ /^default/)) { |
($folder =~ /^default/)) { |
if (($url =~ /\.(page|sequence)$/) && (!$donechk)) { |
if (($url =~ /\.(page|sequence)$/) && (!$donechk)) { |
Line 651 sub group_import {
|
Line 735 sub group_import {
|
} else { |
} else { |
$fname =~ s/\W/_/g; |
$fname =~ s/\W/_/g; |
} |
} |
if (length($fname > 15)) { |
if (length($fname) > 15) { |
$fname = substr($fname,0,14); |
$fname = substr($fname,0,14); |
} |
} |
my $initialtext = &mt('Replace with your own content.'); |
my $initialtext = &mt('Replace with your own content.'); |
Line 666 $initialtext
|
Line 750 $initialtext
|
</html> |
</html> |
END |
END |
$env{'form.output'}=$newhtml; |
$env{'form.output'}=$newhtml; |
my $result = |
my $result = |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, |
'output', |
'output', |
"$filepath/$residx/$fname.html"); |
"$filepath/$residx/$fname.html"); |
Line 691 END
|
Line 775 END
|
removefrommap => \%removefrommap, |
removefrommap => \%removefrommap, |
removeparam => \%removeparam, |
removeparam => \%removeparam, |
); |
); |
my ($result,$msgsarray,$lockerror) = |
my ($result,$msgsarray,$lockerror) = |
&apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); |
&apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); |
if (keys(%import_errors) > 0) { |
if (keys(%import_errors) > 0) { |
$fixuperrors = |
$fixuperrors = |
Line 976 sub docs_change_log {
|
Line 1060 sub docs_change_log {
|
|
|
sub update_paste_buffer { |
sub update_paste_buffer { |
my ($coursenum,$coursedom,$folder) = @_; |
my ($coursenum,$coursedom,$folder) = @_; |
my (@possibles,%removals,%cuts); |
my (@possibles,%removals,%cuts,$output); |
if ($env{'form.multiremove'}) { |
if ($env{'form.multiremove'}) { |
$env{'form.multiremove'} =~ s/,$//; |
$env{'form.multiremove'} =~ s/,$//; |
map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'}); |
map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'}); |
Line 1021 sub update_paste_buffer {
|
Line 1105 sub update_paste_buffer {
|
foreach my $suffix (@currpaste) { |
foreach my $suffix (@currpaste) { |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
|
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && |
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && |
($url ne '')) { |
($url ne '')) { |
$pasteurls{$cid.'_'.$url} = 1; |
$pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1; |
} |
} |
} |
} |
} |
} |
|
|
# Mark items for copying (skip any items already in user's paste buffer) |
# Mark items for copying (skip any items already in user's paste buffer) |
my %addtoenv; |
my %addtoenv; |
|
|
|
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
|
my @folderconf = split(/\:/,$pathitems[-1]); |
|
my $ispage = $folderconf[4]; |
|
|
foreach my $item (@possibles) { |
foreach my $item (@possibles) { |
my ($orderidx,$cmd) = split(/:/,$item); |
my ($orderidx,$cmd) = split(/:/,$item); |
next if ($orderidx =~ /\D/); |
next if ($orderidx =~ /\D/); |
next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove')); |
next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove')); |
|
my $mapidx = $folder.':'.$orderidx.':'.$ispage; |
my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]); |
my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]); |
my %denied = &action_restrictions($coursenum,$coursedom, |
my %denied = &action_restrictions($coursenum,$coursedom, |
&LONCAPA::map::qtescape($url), |
&LONCAPA::map::qtescape($url), |
$env{'form.folderpath'},\%curr_groups); |
$env{'form.folderpath'},\%curr_groups); |
next if ($denied{'copy'}); |
next if ($denied{'copy'}); |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url})); |
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx})); |
my ($suffix,$errortxt,$locknotfreed) = |
my ($suffix,$errortxt,$locknotfreed) = |
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); |
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); |
push(@newpaste,$suffix); |
if ($suffix ne '') { |
if ($locknotfreed) { |
push(@newpaste,$suffix); |
return $locknotfreed; |
} else { |
last; |
if ($locknotfreed) { |
|
return $locknotfreed; |
|
} |
} |
} |
if (&is_supplemental_title($title)) { |
if (&is_supplemental_title($title)) { |
&Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title}); |
&Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title}); |
Line 1058 sub update_paste_buffer {
|
Line 1150 sub update_paste_buffer {
|
$addtoenv{'docs.markedcopy_url_'.$suffix} = $url, |
$addtoenv{'docs.markedcopy_url_'.$suffix} = $url, |
$addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd, |
$addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd, |
$addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'}; |
$addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'}; |
|
$addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx; |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { |
my $prefix = $1; |
my $prefix = $1; |
my $subdir =$2; |
my $subdir =$2; |
Line 1081 sub update_paste_buffer {
|
Line 1173 sub update_paste_buffer {
|
} |
} |
} |
} |
} |
} |
|
if ($locknotfreed) { |
|
$output = $locknotfreed; |
|
last; |
|
} |
} |
} |
if (@newpaste) { |
if (@newpaste) { |
$addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste)); |
$addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste)); |
} |
} |
&Apache::lonnet::appenv(\%addtoenv); |
&Apache::lonnet::appenv(\%addtoenv); |
delete($env{'form.markcopy'}); |
delete($env{'form.markcopy'}); |
return; |
return $output; |
} |
} |
|
|
sub recurse_uploaded_maps { |
sub recurse_uploaded_maps { |
Line 1132 sub print_paste_buffer {
|
Line 1228 sub print_paste_buffer {
|
next if ($suffix =~ /\D/); |
next if ($suffix =~ /\D/); |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
|
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
if (($cid =~ /^$match_domain\_$match_courseid$/) && |
if (($cid =~ /^$match_domain\_$match_courseid$/) && |
($url ne '')) { |
($url ne '')) { |
$clipboardcount ++; |
$clipboardcount ++; |
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent, |
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent, |
$canpaste,$nopaste,$othercrs,$areachange); |
$canpaste,$nopaste,$othercrs,$areachange,$is_exttool); |
my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1]; |
my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1]; |
if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
$is_external = 1; |
$is_external = 1; |
|
} elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$}) { |
|
$is_exttool = 1; |
} |
} |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix}); |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix}); |
Line 1157 sub print_paste_buffer {
|
Line 1256 sub print_paste_buffer {
|
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
$othercourse = 1; |
$othercourse = 1; |
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
if ($canpaste) { |
$othercrs = '<br />'.&mt('(from another course)'); |
$othercrs = '<br />'.&mt('(from another course)'); |
|
} |
|
} else { |
} else { |
$canpaste = 0; |
$canpaste = 0; |
$nopaste = &mt('Paste from another course unavailable.'); |
$nopaste = &mt('Paste from another course unavailable.'); |
Line 1173 sub print_paste_buffer {
|
Line 1270 sub print_paste_buffer {
|
} |
} |
$is_uploaded_map = 1; |
$is_uploaded_map = 1; |
} |
} |
|
} elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || |
|
($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg)$})) { |
|
if ($cid ne $env{'request.course.id'}) { |
|
my ($srcdom,$srcnum) = split(/_/,$cid); |
|
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
|
$othercrs = '<br />'.&mt('(from another course)'); |
|
} else { |
|
$canpaste = 0; |
|
$nopaste = &mt('Paste from another course unavailable.'); |
|
} |
|
} |
} |
} |
} |
if ($canpaste) { |
if ($canpaste) { |
push(@pasteable,$suffix); |
push(@pasteable,$suffix); |
} |
} |
} |
my $buffer; |
my $buffer; |
if ($is_external) { |
if (($is_external) || ($is_exttool)) { |
$buffer = &mt('External Resource').': '. |
$buffer = &mt('External Resource').': '. |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('. |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('. |
&LONCAPA::map::qtescape($url).')'; |
&LONCAPA::map::qtescape($url).')'; |
Line 1190 sub print_paste_buffer {
|
Line 1298 sub print_paste_buffer {
|
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); |
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); |
$icon .= '/navmap.folder.closed.gif'; |
$icon .= '/navmap.folder.closed.gif'; |
} |
} |
|
my $title = $env{'docs.markedcopy_title_'.$suffix}; |
|
if ($title eq '') { |
|
($title) = ($url =~ m{/([^/]+)$}); |
|
} |
$buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'. |
$buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'. |
': '. |
': '. |
&Apache::loncommon::parse_supplemental_title( |
&Apache::loncommon::parse_supplemental_title( |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix})); |
&LONCAPA::map::qtescape($title)); |
} |
} |
$pasteitems .= '<div class="LC_left_float">'; |
$pasteitems .= '<div class="LC_left_float">'; |
my ($options,$onclick); |
my ($options,$onclick); |
Line 1231 sub print_paste_buffer {
|
Line 1343 sub print_paste_buffer {
|
my $value = &mt('Paste to current folder'); |
my $value = &mt('Paste to current folder'); |
if ($container eq 'page') { |
if ($container eq 'page') { |
$value = &mt('Paste to current page'); |
$value = &mt('Paste to current page'); |
} |
} |
$buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2); |
$buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2); |
} |
} |
$buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'.(' 'x2); |
$buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2); |
if ($clipboardcount > 1) { |
if ($clipboardcount > 1) { |
$buttons .= |
$buttons .= |
'<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2). |
'<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2). |
Line 1335 sub supp_pasteable {
|
Line 1447 sub supp_pasteable {
|
(($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) || |
(($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) || |
($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) || |
($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) || |
($url =~ m{^/adm/$match_domain/$match_username/aboutme}) || |
($url =~ m{^/adm/$match_domain/$match_username/aboutme}) || |
($url =~ m{^/public/$match_domain/$match_courseid/syllabus})) { |
($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) || |
|
($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$})) { |
return 1; |
return 1; |
} |
} |
return; |
return; |
} |
} |
|
|
sub paste_popup_js { |
sub paste_popup_js { |
my %lt = &Apache::lonlocal::texthash( |
my %html_js_lt = &Apache::lonlocal::texthash( |
show => 'Show Options', |
show => 'Show Options', |
hide => 'Hide Options', |
hide => 'Hide Options', |
|
); |
|
my %js_lt = &Apache::lonlocal::texthash( |
none => 'No items selected from clipboard.', |
none => 'No items selected from clipboard.', |
); |
); |
|
&html_escape(\%html_js_lt); |
|
&js_escape(\%html_js_lt); |
|
&js_escape(\%js_lt); |
return <<"END"; |
return <<"END"; |
|
|
function showPasteOptions(suffix) { |
function showPasteOptions(suffix) { |
document.getElementById('pasteoptions_'+suffix).style.display='block'; |
document.getElementById('pasteoptions_'+suffix).style.display='block'; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$lt{'hide'}</a>'; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>'; |
return; |
return; |
} |
} |
|
|
function hidePasteOptions(suffix) { |
function hidePasteOptions(suffix) { |
document.getElementById('pasteoptions_'+suffix).style.display='none'; |
document.getElementById('pasteoptions_'+suffix).style.display='none'; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>'; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>'; |
return; |
return; |
} |
} |
|
|
function showOptions(caller,suffix) { |
function showOptions(caller,suffix) { |
if (document.getElementById('pasteoptionstext_'+suffix)) { |
if (document.getElementById('pasteoptionstext_'+suffix)) { |
if (caller.checked) { |
if (caller.checked) { |
document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>'; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>'; |
} else { |
} else { |
document.getElementById('pasteoptionstext_'+suffix).innerHTML =''; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML =''; |
} |
} |
Line 1393 function validateClipboard() {
|
Line 1511 function validateClipboard() {
|
if (numchk > 0) { |
if (numchk > 0) { |
return true; |
return true; |
} else { |
} else { |
alert("$lt{'none'}"); |
alert("$js_lt{'none'}"); |
return false; |
return false; |
} |
} |
} |
} |
Line 1402 function checkClipboard() {
|
Line 1520 function checkClipboard() {
|
if (document.pasteform.pasting.length > 1) { |
if (document.pasteform.pasting.length > 1) { |
for (var i=0; i<document.pasteform.pasting.length; i++) { |
for (var i=0; i<document.pasteform.pasting.length; i++) { |
document.pasteform.pasting[i].checked = true; |
document.pasteform.pasting[i].checked = true; |
} |
} |
} |
} |
return; |
return; |
} |
} |
Line 1453 sub do_paste_from_buffer {
|
Line 1571 sub do_paste_from_buffer {
|
} |
} |
|
|
my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate, |
my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate, |
%prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult); |
%prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult); |
|
|
foreach my $suffix (@topaste) { |
foreach my $suffix (@topaste) { |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
|
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
|
my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix}); |
# Supplemental content may only include certain types of content |
# Supplemental content may only include certain types of content |
# Early out if pasted content is not supported in Supplemental area |
# Early out if pasted content is not supported in Supplemental area |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
Line 1478 sub do_paste_from_buffer {
|
Line 1598 sub do_paste_from_buffer {
|
} |
} |
$srcdom{$suffix} = $srcd; |
$srcdom{$suffix} = $srcd; |
$srcnum{$suffix} = $srcn; |
$srcnum{$suffix} = $srcn; |
|
} elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || |
|
($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$})) { |
|
my ($srcd,$srcn) = split(/_/,$cid); |
|
# When paste buffer was populated using an active role in a different course |
|
# check for mdc privilege in the course from which the resource was pasted |
|
if (($srcd ne $coursedom) || ($srcn ne $coursenum)) { |
|
unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) { |
|
$notincrs{$suffix} = 1; |
|
next; |
|
} |
|
} |
|
$srcdom{$suffix} = $srcd; |
|
$srcnum{$suffix} = $srcn; |
} |
} |
|
$srcmapidx{$suffix} = $mapidx; |
push(@dopaste,$suffix); |
push(@dopaste,$suffix); |
if ($url=~/\.(page|sequence)$/) { |
if ($url=~/\.(page|sequence)$/) { |
$is_map{$suffix} = 1; |
$is_map{$suffix} = 1; |
Line 1489 sub do_paste_from_buffer {
|
Line 1622 sub do_paste_from_buffer {
|
my $oldprefix = $1; |
my $oldprefix = $1; |
# When pasting content from Main Content to Supplemental Content and vice versa |
# When pasting content from Main Content to Supplemental Content and vice versa |
# URLs will contain different paths (which depend on whether pasted item is |
# URLs will contain different paths (which depend on whether pasted item is |
# a folder/page or a document. |
# a folder/page or a document). |
if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) { |
if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) { |
$prefixchg{$suffix} = 'docstosupp'; |
$prefixchg{$suffix} = 'docstosupp'; |
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
Line 1571 sub do_paste_from_buffer {
|
Line 1704 sub do_paste_from_buffer {
|
# Maps need to be copied first |
# Maps need to be copied first |
my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies, |
my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies, |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir, |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir, |
%newurls,%tomove); |
%newurls,%tomove,%resdatacopy); |
if (ref($marktomove{$suffix}) eq 'ARRAY') { |
if (ref($marktomove{$suffix}) eq 'ARRAY') { |
map { $tomove{$_} = 1; } @{$marktomove{$suffix}}; |
map { $tomove{$_} = 1; } @{$marktomove{$suffix}}; |
} |
} |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
|
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $oldurl = $url; |
my $oldurl = $url; |
if ($is_map{$suffix}) { |
if ($is_map{$suffix}) { |
# If pasting a map, check if map contains other maps |
# If pasting a map, check if map contains other maps |
Line 1612 sub do_paste_from_buffer {
|
Line 1746 sub do_paste_from_buffer {
|
\%retitles,\%copies,\%dbcopies, |
\%retitles,\%copies,\%dbcopies, |
\%zombies,\%params,\%mapmoves, |
\%zombies,\%params,\%mapmoves, |
\%mapchanges,\%tomove,\%newsubdir, |
\%mapchanges,\%tomove,\%newsubdir, |
\%newurls)) { |
\%newurls,\%resdatacopy)) { |
$mapmoves{$url} = 1; |
$mapmoves{$url} = 1; |
} |
} |
$url = $newurl; |
$url = $newurl; |
Line 1621 sub do_paste_from_buffer {
|
Line 1755 sub do_paste_from_buffer {
|
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
\%zombies,\%params,\%mapmoves,\%mapchanges, |
\%zombies,\%params,\%mapmoves,\%mapchanges, |
\%tomove,\%newsubdir,\%newurls); |
\%tomove,\%newsubdir,\%newurls,\%resdatacopy); |
} |
} |
} elsif ($url=~m {^/res/}) { |
} elsif ($url=~m {^/res/}) { |
# published map can only exists once, so remove from paste buffer when done |
# published map can only exist once, so remove from paste buffer when done |
push(@toclear,$suffix); |
push(@toclear,$suffix); |
# if pasting published map (main content area only) check map not already in course |
# if pasting published map (main content area only) check map not already in course |
if ($folder =~ /^default/) { |
if ($folder =~ /^default/) { |
Line 1637 sub do_paste_from_buffer {
|
Line 1771 sub do_paste_from_buffer {
|
} |
} |
if ($url=~ m{/(bulletinboard|smppg)$}) { |
if ($url=~ m{/(bulletinboard|smppg)$}) { |
my $prefix = $1; |
my $prefix = $1; |
|
my $fromothercrs; |
#need to copy the db contents to a new one, unless this is a move. |
#need to copy the db contents to a new one, unless this is a move. |
my %info = ( |
my %info = ( |
src => $url, |
src => $url, |
cdom => $coursedom, |
cdom => $coursedom, |
cnum => $coursenum, |
cnum => $coursenum, |
); |
); |
unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') { |
if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) { |
|
unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) { |
|
$fromothercrs = 1; |
|
$info{'cdom'} = $srcdom{$suffix}; |
|
$info{'cnum'} = $srcnum{$suffix}; |
|
} |
|
} |
|
unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) { |
my (%lockerr,$msg); |
my (%lockerr,$msg); |
my ($newurl,$result,$errtext) = |
my ($newurl,$result,$errtext) = |
&dbcopy(\%info,$coursedom,$coursenum,\%lockerr); |
&dbcopy(\%info,$coursedom,$coursenum,\%lockerr); |
Line 1662 sub do_paste_from_buffer {
|
Line 1804 sub do_paste_from_buffer {
|
next; |
next; |
} |
} |
if ($lockerr{$prefix}) { |
if ($lockerr{$prefix}) { |
$lockerrs{$suffix} = $lockerr{$prefix}; |
$lockerrs{$suffix} = $lockerr{$prefix}; |
} |
} |
} |
} |
} |
} |
Line 1701 sub do_paste_from_buffer {
|
Line 1843 sub do_paste_from_buffer {
|
if ($newdocsdir eq '') { |
if ($newdocsdir eq '') { |
$newdocsdir = 'default'; |
$newdocsdir = 'default'; |
} |
} |
if (($prefixchg{$suffix}) || |
if (($prefixchg{$suffix}) || |
($srcdom{$suffix} ne $coursedom) || |
($srcdom{$suffix} ne $coursedom) || |
($srcnum{$suffix} ne $coursenum) || |
($srcnum{$suffix} ne $coursenum) || |
($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { |
($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { |
Line 1719 sub do_paste_from_buffer {
|
Line 1861 sub do_paste_from_buffer {
|
} |
} |
} |
} |
} |
} |
|
} elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) { |
|
my $template = $1; |
|
if ($newidx) { |
|
©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix}, |
|
$coursedom,$coursenum,$template,$newidx,"$folder.$container"); |
|
} |
} |
} |
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url). |
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url). |
':'.$ext.':normal:res'; |
':'.$ext.':normal:res'; |
Line 1732 sub do_paste_from_buffer {
|
Line 1880 sub do_paste_from_buffer {
|
} |
} |
} |
} |
|
|
# Apply any changes to maps, or copy dependencies for uploaded HTML pages |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update |
|
# resourcedata for simpleproblems copied from another course |
unless ($allresult eq 'fail') { |
unless ($allresult eq 'fail') { |
my %updated = ( |
my %updated = ( |
rewrites => \%rewrites, |
rewrites => \%rewrites, |
Line 1740 sub do_paste_from_buffer {
|
Line 1889 sub do_paste_from_buffer {
|
removefrommap => \%removefrommap, |
removefrommap => \%removefrommap, |
removeparam => \%removeparam, |
removeparam => \%removeparam, |
dbcopies => \%dbcopies, |
dbcopies => \%dbcopies, |
|
resdatacopy => \%resdatacopy, |
retitles => \%retitles, |
retitles => \%retitles, |
); |
); |
my %info = ( |
my %info = ( |
Line 1904 sub get_newmap_url {
|
Line 2054 sub get_newmap_url {
|
sub dbcopy { |
sub dbcopy { |
my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_; |
my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_; |
my ($url,$result,$errtext); |
my ($url,$result,$errtext); |
$url = $dbref->{'src'}; |
|
if (ref($dbref) eq 'HASH') { |
if (ref($dbref) eq 'HASH') { |
|
$url = $dbref->{'src'}; |
if ($url =~ m{/(smppg|bulletinboard)$}) { |
if ($url =~ m{/(smppg|bulletinboard)$}) { |
my $prefix = $1; |
my $prefix = $1; |
if (($dbref->{'cdom'} =~ /^$match_domain$/) && |
if (($dbref->{'cdom'} =~ /^$match_domain$/) && |
($dbref->{'cnum'} =~ /^$match_courseid$/)) { |
($dbref->{'cnum'} =~ /^$match_courseid$/)) { |
my $db_name; |
my $db_name; |
my $marker = (split(m{/},$url))[4]; |
my $marker = (split(m{/},$url))[4]; |
Line 1948 sub dbcopy {
|
Line 2098 sub dbcopy {
|
my $content = &Apache::lonnet::getfile($photo); |
my $content = &Apache::lonnet::getfile($photo); |
unless ($content eq '-1') { |
unless ($content eq '-1') { |
$env{'form.'.$suffix.'.photourl'} = $content; |
$env{'form.'.$suffix.'.photourl'} = $content; |
$newphoto = |
$newphoto = |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); |
delete($env{'form.'.$suffix.'.photourl'}); |
delete($env{'form.'.$suffix.'.photourl'}); |
} |
} |
Line 1996 sub dbcopy {
|
Line 2146 sub dbcopy {
|
return ($url,$result,$errtext); |
return ($url,$result,$errtext); |
} |
} |
|
|
|
sub copy_templated_files { |
|
my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_; |
|
my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo); |
|
my $srccontainer = 'sequence'; |
|
if ($srcwaspage) { |
|
$srccontainer = 'page'; |
|
} |
|
my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer". |
|
'___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl); |
|
my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb; |
|
my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix); |
|
my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'. |
|
$template.'.problem'; |
|
my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb; |
|
if ($template eq 'simpleproblem') { |
|
$srcprefix .= '.0.'; |
|
my $weightprefix = $newprefix; |
|
$newprefix .= '.0.'; |
|
my @simpleprobqtypes = qw(radio option string essay numerical); |
|
my $qtype=$srcparms{$srcprefix.'questiontype'}; |
|
if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) { |
|
my %newdata; |
|
foreach my $type (@simpleprobqtypes) { |
|
if ($type eq $qtype) { |
|
$newdata{"$weightprefix.$type.weight"}=1; |
|
} else { |
|
$newdata{"$weightprefix.$type.weight"}=0; |
|
} |
|
} |
|
$newdata{$newprefix.'hiddenparts'} = '!'.$qtype; |
|
$newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'}; |
|
$newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'}; |
|
if ($qtype eq 'numerical') { |
|
$newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'}; |
|
$newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'}; |
|
$newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'}; |
|
$newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'}; |
|
} elsif (($qtype eq 'option') || ($qtype eq 'radio')) { |
|
my $maxfoils=$srcparms{$srcprefix.'maxfoils'}; |
|
unless (defined($maxfoils)) { $maxfoils=10; } |
|
unless ($maxfoils=~/^\d+$/) { $maxfoils=10; } |
|
if ($maxfoils<=0) { $maxfoils=10; } |
|
my $randomize=$srcparms{$srcprefix.'randomize'}; |
|
unless (defined($randomize)) { $randomize='yes'; } |
|
unless ($randomize eq 'no') { $randomize='yes'; } |
|
$newdata{$newprefix.'maxfoils'} = $maxfoils; |
|
$newdata{$newprefix.'randomize'} = $randomize; |
|
if ($qtype eq 'option') { |
|
$newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'}; |
|
} |
|
for (my $i=1; $i<=10; $i++) { |
|
$newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i}; |
|
$newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i}; |
|
$newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i}; |
|
} |
|
|
|
} elsif (($qtype eq 'option') || ($qtype eq 'radio')) { |
|
my $maxfoils=$srcparms{$srcprefix.'maxfoils'}; |
|
unless (defined($maxfoils)) { $maxfoils=10; } |
|
unless ($maxfoils=~/^\d+$/) { $maxfoils=10; } |
|
if ($maxfoils<=0) { $maxfoils=10; } |
|
my $randomize=$srcparms{$srcprefix.'randomize'}; |
|
unless (defined($randomize)) { $randomize='yes'; } |
|
unless ($randomize eq 'no') { $randomize='yes'; } |
|
$newdata{$newprefix.'maxfoils'} = $maxfoils; |
|
$newdata{$newprefix.'randomize'} = $randomize; |
|
if ($qtype eq 'option') { |
|
$newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'}; |
|
} |
|
for (my $i=1; $i<=10; $i++) { |
|
$newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i}; |
|
$newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i}; |
|
$newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i}; |
|
} |
|
} elsif ($qtype eq 'string') { |
|
$newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'}; |
|
$newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'}; |
|
} |
|
if (keys(%newdata)) { |
|
my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom, |
|
$coursenum); |
|
if ($putres eq 'ok') { |
|
&Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
sub uniqueness_check { |
sub uniqueness_check { |
my ($newurl) = @_; |
my ($newurl) = @_; |
my $unique = 1; |
my $unique = 1; |
Line 2061 sub contained_map_check {
|
Line 2300 sub contained_map_check {
|
sub url_paste_fixups { |
sub url_paste_fixups { |
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps, |
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps, |
$rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves, |
$rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves, |
$mapchanges,$tomove,$newsubdir,$newurls) = @_; |
$mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_; |
my $checktitle; |
my $checktitle; |
if (($prefixchg) && |
if (($prefixchg) && |
($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) { |
($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) { |
Line 2093 sub url_paste_fixups {
|
Line 2332 sub url_paste_fixups {
|
} |
} |
next if ($token->[2]->{'type'} eq 'external'); |
next if ($token->[2]->{'type'} eq 'external'); |
if ($token->[2]->{'type'} eq 'zombie') { |
if ($token->[2]->{'type'} eq 'zombie') { |
next if ($skip); |
next if ($skip); |
$zombies->{$oldurl}{$id} = $ressrc; |
$zombies->{$oldurl}{$id} = $ressrc; |
$changed = 1; |
$changed = 1; |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
Line 2110 sub url_paste_fixups {
|
Line 2349 sub url_paste_fixups {
|
$srcdom,$srcnum,$allmaps,$rewrites, |
$srcdom,$srcnum,$allmaps,$rewrites, |
$retitles,$copies,$dbcopies,$zombies, |
$retitles,$copies,$dbcopies,$zombies, |
$params,$mapmoves,$mapchanges,$tomove, |
$params,$mapmoves,$mapchanges,$tomove, |
$newsubdir,$newurls); |
$newsubdir,$newurls,$resdatacopy); |
next; |
next; |
} else { |
} else { |
($newurl,my $error) = |
($newurl,my $error) = |
Line 2134 sub url_paste_fixups {
|
Line 2373 sub url_paste_fixups {
|
$cnum,$srcdom,$srcnum,$allmaps, |
$cnum,$srcdom,$srcnum,$allmaps, |
$rewrites,$retitles,$copies,$dbcopies, |
$rewrites,$retitles,$copies,$dbcopies, |
$zombies,$params,$mapmoves,$mapchanges, |
$zombies,$params,$mapmoves,$mapchanges, |
$tomove,$newsubdir,$newurls)) { |
$tomove,$newsubdir,$newurls,$resdatacopy)) { |
$mapmoves->{$ressrc} = 1; |
$mapmoves->{$ressrc} = 1; |
} |
} |
$changed = 1; |
$changed = 1; |
Line 2163 sub url_paste_fixups {
|
Line 2402 sub url_paste_fixups {
|
$dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum; |
$dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum; |
$changed = 1; |
$changed = 1; |
} |
} |
|
} elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') { |
|
if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) { |
|
$resdatacopy->{$oldurl}{$id}{'src'} = $ressrc; |
|
$resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom; |
|
$resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum; |
|
} |
} elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) { |
} elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) { |
next if ($skip); |
next if ($skip); |
my $srcdom = $1; |
my $srcdom = $1; |
Line 2194 sub apply_fixups {
|
Line 2439 sub apply_fixups {
|
$oldurl,$url,$caller) = @_; |
$oldurl,$url,$caller) = @_; |
my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles, |
my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles, |
%params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs, |
%params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs, |
%lockerrors,$lockmsg); |
%resdatacopy,%lockerrors,$lockmsg); |
if (ref($updated) eq 'HASH') { |
if (ref($updated) eq 'HASH') { |
if (ref($updated->{'rewrites'}) eq 'HASH') { |
if (ref($updated->{'rewrites'}) eq 'HASH') { |
%rewrites = %{$updated->{'rewrites'}}; |
%rewrites = %{$updated->{'rewrites'}}; |
Line 2214 sub apply_fixups {
|
Line 2459 sub apply_fixups {
|
if (ref($updated->{'retitles'}) eq 'HASH') { |
if (ref($updated->{'retitles'}) eq 'HASH') { |
%retitles = %{$updated->{'retitles'}}; |
%retitles = %{$updated->{'retitles'}}; |
} |
} |
|
if (ref($updated->{'resdatacopy'}) eq 'HASH') { |
|
%resdatacopy = %{$updated->{'resdatacopy'}}; |
|
} |
} |
} |
if (ref($info) eq 'HASH') { |
if (ref($info) eq 'HASH') { |
if (ref($info->{'newsubdir'}) eq 'HASH') { |
if (ref($info->{'newsubdir'}) eq 'HASH') { |
Line 2364 sub apply_fixups {
|
Line 2612 sub apply_fixups {
|
} |
} |
} |
} |
} |
} |
|
if (ref($resdatacopy{$key}) eq 'HASH') { |
|
if ($newsubdir{$key}) { |
|
|
|
} |
|
foreach my $idx (keys(%{$resdatacopy{$key}})) { |
|
if (ref($resdatacopy{$key}{$idx}) eq 'HASH') { |
|
my $srcurl = $resdatacopy{$key}{$idx}{'src'}; |
|
if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) { |
|
my $template = $1; |
|
if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) && |
|
($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) { |
|
my $srcdom = $resdatacopy{$key}{$idx}{'cdom'}; |
|
my $srcnum = $resdatacopy{$key}{$idx}{'cnum'}; |
|
my ($newmapname) = ($key =~ m{/([^/]+)$}); |
|
my ($srcfolder,$srccontainer) = split(/\./,$newmapname); |
|
my $srcmapinfo = $srcfolder.':'.$idx; |
|
if ($srccontainer eq 'page') { |
|
$srcmapinfo .= ':1'; |
|
} |
|
if ($newsubdir{$key}) { |
|
$newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/; |
|
} |
|
©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom, |
|
$cnum,$template,$idx,$newmapname); |
|
} |
|
} |
|
} |
|
} |
|
} |
if (ref($params{$key}) eq 'HASH') { |
if (ref($params{$key}) eq 'HASH') { |
%currparam = %{$params{$key}}; |
%currparam = %{$params{$key}}; |
} |
} |
Line 2539 sub update_parameter {
|
Line 2816 sub update_parameter {
|
'randomorder' => {}, |
'randomorder' => {}, |
); |
); |
foreach my $which (keys(%allchecked)) { |
foreach my $which (keys(%allchecked)) { |
$env{'form.all'.$which} =~ s/,$//; |
$env{'form.all'.$which} =~ s/,$//; |
if ($which eq 'randompick') { |
if ($which eq 'randompick') { |
foreach my $item (split(/,/,$env{'form.all'.$which})) { |
foreach my $item (split(/,/,$env{'form.all'.$which})) { |
my ($res,$value) = split(/:/,$item); |
my ($res,$value) = split(/:/,$item); |
Line 2566 sub update_parameter {
|
Line 2843 sub update_parameter {
|
foreach my $which (keys(%allchecked)) { |
foreach my $which (keys(%allchecked)) { |
if (($which eq 'randompick' || $which eq 'randomorder')) { |
if (($which eq 'randompick' || $which eq 'randomorder')) { |
next if (!$is_map); |
next if (!$is_map); |
} |
} |
my $oldvalue = 0; |
my $oldvalue = 0; |
my $newvalue = 0; |
my $newvalue = 0; |
if ($allchecked{$which}{$res}) { |
if ($allchecked{$which}{$res}) { |
Line 2602 sub update_parameter {
|
Line 2879 sub update_parameter {
|
} |
} |
return $haschanges; |
return $haschanges; |
} else { |
} else { |
return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/); |
my $haschanges = 0; |
|
return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/); |
|
|
my $which = $env{'form.changeparms'}; |
my $which = $env{'form.changeparms'}; |
my $idx = $env{'form.setparms'}; |
my $idx = $env{'form.setparms'}; |
|
my $oldvalue = 0; |
|
my $newvalue = 0; |
|
my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0]; |
|
if ($which eq 'randompick') { |
|
if ($current =~ /^(\d+)$/) { |
|
$oldvalue = $1; |
|
} |
|
} elsif ($current =~ /^yes$/i) { |
|
$oldvalue = 1; |
|
} |
if ($env{'form.'.$which.'_'.$idx}) { |
if ($env{'form.'.$which.'_'.$idx}) { |
my $value = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} |
$newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} |
: 'yes'; |
: 1; |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value, |
|
$parameter_type{$which}); |
|
&remember_parms($idx,$which,'set',$value); |
|
} else { |
|
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
|
|
|
&remember_parms($idx,$which,'del'); |
|
} |
} |
return 1; |
if ($oldvalue ne $newvalue) { |
|
$haschanges = 1; |
|
if ($newvalue) { |
|
my $storeval = 'yes'; |
|
if ($which eq 'randompick') { |
|
$storeval = $newvalue; |
|
} |
|
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval, |
|
$parameter_type{$which}); |
|
&remember_parms($idx,$which,'set',$storeval); |
|
} else { |
|
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
|
&remember_parms($idx,$which,'del'); |
|
} |
|
} |
|
return $haschanges; |
} |
} |
} |
} |
|
|
|
|
sub handle_edit_cmd { |
sub handle_edit_cmd { |
my ($coursenum,$coursedom) =@_; |
my ($coursenum,$coursedom) =@_; |
if ($env{'form.cmd'} eq '') { |
if ($env{'form.cmd'} eq '') { |
Line 2671 sub handle_edit_cmd {
|
Line 2966 sub handle_edit_cmd {
|
|
|
sub editor { |
sub editor { |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, |
$supplementalflag,$orderhash,$iconpath,$pathitem)=@_; |
$supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref)=@_; |
my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container); |
my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container); |
if ($allowed) { |
if ($allowed) { |
(my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain, |
(my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain, |
Line 2713 sub editor {
|
Line 3008 sub editor {
|
&snapshotbefore(); |
&snapshotbefore(); |
|
|
if (&update_parameter()) { |
if (&update_parameter()) { |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
} |
} |
|
|
Line 2775 sub editor {
|
Line 3070 sub editor {
|
$r->print($upload_output); |
$r->print($upload_output); |
|
|
# Rename, cut, copy or remove a single resource |
# Rename, cut, copy or remove a single resource |
if (&handle_edit_cmd()) { |
if (&handle_edit_cmd($coursenum,$coursedom)) { |
my $contentchg; |
my $contentchg; |
if ($env{'form.cmd'} =~ m{^(del|cut)_}) { |
if ($env{'form.cmd'} =~ m{^(remove|cut)_}) { |
$contentchg = 1; |
$contentchg = 1; |
} |
} |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); |
Line 2809 sub editor {
|
Line 3104 sub editor {
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
$name=&LONCAPA::map::qtescape($name); |
$name=&LONCAPA::map::qtescape($name); |
$url=&LONCAPA::map::qtescape($url); |
$url=&LONCAPA::map::qtescape($url); |
next unless ($name && $url); |
next unless $url; |
my %denied = |
my %denied = |
&action_restrictions($coursenum,$coursedom,$url, |
&action_restrictions($coursenum,$coursedom,$url, |
$env{'form.folderpath'},\%curr_groups); |
$env{'form.folderpath'},\%curr_groups); |
Line 2870 sub editor {
|
Line 3165 sub editor {
|
} else { |
} else { |
return $errortxt; |
return $errortxt; |
} |
} |
|
} elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/exttool}) { |
|
my ($suffix,$errortxt,$locknotfreed) = |
|
&new_timebased_suffix($coursedom,$coursenum,'exttool'); |
|
if ($locknotfreed) { |
|
$r->print($locknotfreed); |
|
} |
|
if ($suffix) { |
|
$url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix}; |
|
} else { |
|
return $errortxt; |
|
} |
} elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) { |
} elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) { |
if ($supplementalflag) { |
if ($supplementalflag) { |
next unless ($1 eq 'supplemental'); |
next unless ($1 eq 'supplemental'); |
Line 2892 sub editor {
|
Line 3198 sub editor {
|
} |
} |
($errtext,$fatal,my $fixuperrors) = |
($errtext,$fatal,my $fixuperrors) = |
&group_import($coursenum, $coursedom, $folder,$container, |
&group_import($coursenum, $coursedom, $folder,$container, |
'londocs',@imports); |
'londocs',$ltitoolsref,@imports); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
if ($fixuperrors) { |
if ($fixuperrors) { |
$r->print($fixuperrors); |
$r->print($fixuperrors); |
Line 2977 sub editor {
|
Line 3283 sub editor {
|
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$coursenum,$coursedom,$crstype, |
$coursenum,$coursedom,$crstype, |
$pathitem,$supplementalflag,$container, |
$pathitem,$supplementalflag,$container, |
\%filters,\%curr_groups); |
\%filters,\%curr_groups,$ltitoolsref); |
$idx++; |
$idx++; |
$shown++; |
$shown++; |
} |
} |
Line 3025 sub editor {
|
Line 3331 sub editor {
|
if (@allidx > 0) { |
if (@allidx > 0) { |
my $path; |
my $path; |
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
$path = |
$path = |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
} |
} |
if (@allidx > 1) { |
if (@allidx > 1) { |
$to_show .= |
$to_show .= |
&Apache::loncommon::continue_data_table_row(). |
&Apache::loncommon::continue_data_table_row(). |
'<td colspan="2"> </td>'. |
'<td colspan="2"> </td>'. |
'<td>'. |
'<td>'. |
Line 3174 sub process_file_upload {
|
Line 3480 sub process_file_upload {
|
my $quotatype = 'unofficial'; |
my $quotatype = 'unofficial'; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$quotatype = 'community'; |
$quotatype = 'community'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) { |
} elsif ($crstype eq 'Placement') { |
|
$quotatype = 'placement'; |
|
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
$quotatype = 'official'; |
$quotatype = 'official'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
$quotatype = 'textbook'; |
$quotatype = 'textbook'; |
Line 3182 sub process_file_upload {
|
Line 3490 sub process_file_upload {
|
if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) { |
if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) { |
$filesize = int($filesize/1000); #expressed in kb |
$filesize = int($filesize/1000); #expressed in kb |
$$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course', |
$$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course', |
$env{'form.uploaddoc.filename'},$filesize,'upload'); |
$env{'form.uploaddoc.filename'},$filesize, |
|
'upload',$quotatype); |
return if ($$upload_output); |
return if ($$upload_output); |
} |
} |
my ($parseaction,$showupload,$nextphase,$mimetype); |
my ($parseaction,$showupload,$nextphase,$mimetype); |
Line 3280 sub process_file_upload {
|
Line 3589 sub process_file_upload {
|
$$upload_output .= &mt('No embedded items identified').'<br />'; |
$$upload_output .= &mt('No embedded items identified').'<br />'; |
} |
} |
$$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>'; |
$$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>'; |
} elsif (&Apache::loncommon::is_archive_file($mimetype)) { |
} elsif ((&Apache::loncommon::is_archive_file($mimetype)) && |
|
($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) { |
$nextphase = 'decompress_uploaded'; |
$nextphase = 'decompress_uploaded'; |
my $position = scalar(@LONCAPA::map::order)-1; |
my $position = scalar(@LONCAPA::map::order)-1; |
my $noextract = &return_to_editor(); |
my $noextract = &return_to_editor(); |
Line 3341 sub is_supplemental_title {
|
Line 3651 sub is_supplemental_title {
|
|
|
sub entryline { |
sub entryline { |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, |
$crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups)=@_; |
$crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups, |
my ($foldertitle,$renametitle); |
$ltitoolsref)=@_; |
|
my ($foldertitle,$renametitle,$oldtitle); |
if (&is_supplemental_title($title)) { |
if (&is_supplemental_title($title)) { |
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); |
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); |
} else { |
} else { |
Line 3355 sub entryline {
|
Line 3666 sub entryline {
|
|
|
$renametitle=~s/\\/\\\\/g; |
$renametitle=~s/\\/\\\\/g; |
$renametitle=~s/\"\;/\\\"/g; |
$renametitle=~s/\"\;/\\\"/g; |
$renametitle=~s/\'\;/\\\'/g; |
$renametitle=~s/"/%22/g; |
$renametitle=~s/ /%20/g; |
$renametitle=~s/ /%20/g; |
|
$oldtitle = $renametitle; |
|
$renametitle=~s/\'/\\\'/g; |
my $line=&Apache::loncommon::start_data_table_row(); |
my $line=&Apache::loncommon::start_data_table_row(); |
my ($form_start,$form_end,$form_common,$form_param); |
my ($form_start,$form_end,$form_common,$form_param); |
# Edit commands |
# Edit commands |
Line 3430 END
|
Line 3743 END
|
'rn' => 'Rename', |
'rn' => 'Rename', |
'cp' => 'Copy', |
'cp' => 'Copy', |
'ex' => 'External Resource', |
'ex' => 'External Resource', |
|
'et' => 'External Tool', |
'ed' => 'Edit', |
'ed' => 'Edit', |
'pr' => 'Preview', |
'pr' => 'Preview', |
'sv' => 'Save', |
'sv' => 'Save', |
Line 3441 END
|
Line 3755 END
|
$currgroups); |
$currgroups); |
my ($copylink,$cutlink,$removelink); |
my ($copylink,$cutlink,$removelink); |
my $skip_confirm = 0; |
my $skip_confirm = 0; |
|
my $confirm_removal = 0; |
if ( $folder =~ /^supplemental/ |
if ( $folder =~ /^supplemental/ |
|| ($url =~ m{( /smppg$ |
|| ($url =~ m{( /smppg$ |
|/syllabus$ |
|/syllabus$ |
|/aboutme$ |
|/aboutme$ |
|/navmaps$ |
|/navmaps$ |
|/bulletinboard$ |
|/bulletinboard$ |
|
|/exttools?$ |
|\.html$)}x) |
|\.html$)}x) |
|| $isexternal) { |
|| $isexternal) { |
$skip_confirm = 1; |
$skip_confirm = 1; |
} |
} |
|
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
|
($url!~/$LONCAPA::assess_page_seq_re/)) { |
|
$confirm_removal = 1; |
|
} |
|
|
if ($denied{'copy'}) { |
if ($denied{'copy'}) { |
$copylink=(<<ENDCOPY) |
$copylink=(<<ENDCOPY) |
Line 3493 ENDCUT
|
Line 3813 ENDCUT
|
ENDREM |
ENDREM |
} else { |
} else { |
my $formname = 'edit_remove_'.$orderidx; |
my $formname = 'edit_remove_'.$orderidx; |
my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm);"; |
my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);"; |
$removelink=(<<ENDREM); |
$removelink=(<<ENDREM); |
<form name="$formname" method="post" action="/adm/coursedocs"> |
<form name="$formname" method="post" action="/adm/coursedocs"> |
$form_common |
$form_common |
<input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" /> |
<input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" /> |
|
<input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" /> |
<input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a> |
<input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a> |
$form_end |
$form_end |
ENDREM |
ENDREM |
Line 3506 ENDREM
|
Line 3827 ENDREM
|
} |
} |
} |
} |
$renamelink=(<<ENDREN); |
$renamelink=(<<ENDREN); |
<a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a> |
<a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a> |
ENDREN |
ENDREN |
$line.=(<<END); |
$line.=(<<END); |
<td> |
<td> |
Line 3583 END
|
Line 3904 END
|
} |
} |
} elsif ($url=~m|^/ext/|) { |
} elsif ($url=~m|^/ext/|) { |
$url='/adm/wrapper'.$url; |
$url='/adm/wrapper'.$url; |
} |
} elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) { |
|
$url='/adm/wrapper'.$url; |
|
} |
if (&Apache::lonnet::symbverify($symb,$url)) { |
if (&Apache::lonnet::symbverify($symb,$url)) { |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
} else { |
} else { |
Line 3646 $form_common."\n".
|
Line 3969 $form_common."\n".
|
$form_param."\n". |
$form_param."\n". |
$form_common."\n". |
$form_common."\n". |
'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'. |
'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'. |
$form_end; |
$form_end; |
} |
} |
} elsif ($supplementalflag && !$allowed) { |
} elsif ($supplementalflag && !$allowed) { |
|
my $isexttool; |
|
if ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) { |
|
$url='/adm/wrapper'.$url; |
|
$isexttool = 1; |
|
} |
$url .= ($url =~ /\?/) ? '&':'?'; |
$url .= ($url =~ /\?/) ? '&':'?'; |
$url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"'); |
$url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"'); |
if ($title) { |
if ($title) { |
$url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"'); |
$url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"'); |
} |
} |
if ($isexternal && $orderidx) { |
if ((($isexternal) || ($isexttool)) && $orderidx) { |
$url .= '&idx='.$orderidx; |
$url .= '&idx='.$orderidx; |
} |
} |
} |
} |
Line 3665 $form_end;
|
Line 3993 $form_end;
|
if ($isexternal) { |
if ($isexternal) { |
($editlink,$extresform) = |
($editlink,$extresform) = |
&Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem); |
&Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem); |
|
} elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) { |
|
($editlink,$extresform) = |
|
&Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem, |
|
undef,undef,undef,'tool',$coursedom, |
|
$coursenum,$ltitoolsref); |
} elsif (!$isfolder && !$ispage) { |
} elsif (!$isfolder && !$ispage) { |
my ($cfile,$home,$switchserver,$forceedit,$forceview) = |
my ($cfile,$home,$switchserver,$forceedit,$forceview) = |
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); |
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); |
Line 3763 sub action_restrictions {
|
Line 4096 sub action_restrictions {
|
if ($url=~ m{^/res/.+\.(page|sequence)$}) { |
if ($url=~ m{^/res/.+\.(page|sequence)$}) { |
# no copy for published maps |
# no copy for published maps |
$denied{'copy'} = 1; |
$denied{'copy'} = 1; |
} elsif ($url=~m{^/res/lib/templates/}) { |
} elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) { |
$denied{'copy'} = 1; |
unless ($1 eq 'simpleproblem') { |
$denied{'cut'} = 1; |
$denied{'copy'} = 1; |
|
} |
|
$denied{'cut'} = 1; |
} elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") { |
} elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") { |
if ($folderpath =~ /^default&[^\&]+$/) { |
if ($folderpath =~ /^default&[^\&]+$/) { |
if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) { |
if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) { |
Line 3821 sub new_timebased_suffix {
|
Line 4156 sub new_timebased_suffix {
|
if ($type eq 'paste') { |
if ($type eq 'paste') { |
$prefix = $type; |
$prefix = $type; |
$namespace = 'courseeditor'; |
$namespace = 'courseeditor'; |
|
$idtype = 'addcode'; |
} elsif ($type eq 'map') { |
} elsif ($type eq 'map') { |
$prefix = 'docs'; |
$prefix = 'docs'; |
if ($area eq 'supplemental') { |
if ($area eq 'supplemental') { |
Line 3832 sub new_timebased_suffix {
|
Line 4168 sub new_timebased_suffix {
|
$prefix = $type; |
$prefix = $type; |
$namespace = 'templated'; |
$namespace = 'templated'; |
} |
} |
$idtype = 'concat'; |
|
my ($suffix,$freedlock,$error) = |
my ($suffix,$freedlock,$error) = |
&Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num); |
&Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype); |
if (!$suffix) { |
if (!$suffix) { |
if ($type eq 'paste') { |
if ($type eq 'paste') { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.'); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.'); |
Line 3850 sub new_timebased_suffix {
|
Line 4185 sub new_timebased_suffix {
|
} |
} |
} |
} |
if ($freedlock ne 'ok') { |
if ($freedlock ne 'ok') { |
$locknotfreed = |
$locknotfreed = |
'<div class="LC_error">'. |
'<div class="LC_error">'. |
&mt('There was a problem removing a lockfile.').' '; |
&mt('There was a problem removing a lockfile.').' '; |
if ($type eq 'paste') { |
if ($type eq 'paste') { |
&mt('This will prevent use of the paste buffer until th next log-in.'); |
if ($freedlock eq 'nolock') { |
|
$locknotfreed = |
|
'<div class="LC_error">'. |
|
&mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '. |
|
|
|
&mt('As a result addition of items to the clipboard will be unavailable until your next log-in.'); |
|
} else { |
|
$locknotfreed .= |
|
&mt('This will prevent addition of items to the clipboard until your next log-in.'); |
|
} |
} elsif ($type eq 'map') { |
} elsif ($type eq 'map') { |
&mt('This will prevent creation of additional folders or composite pages in this course.'); |
$locknotfreed .= |
|
&mt('This will prevent creation of additional folders or composite pages in this course.'); |
} elsif ($type eq 'smppg') { |
} elsif ($type eq 'smppg') { |
$locknotfreed .= |
$locknotfreed .= |
&mt('This will prevent creation of additional simple pages in this course.'); |
&mt('This will prevent creation of additional simple pages in this course.'); |
Line 4249 ENDHEADERS
|
Line 4594 ENDHEADERS
|
return; |
return; |
} |
} |
$r->print( |
$r->print( |
'<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'. |
'<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'. |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.&mt('Resources').'</th>'. |
'<th>'.&mt('Resources').'</th>'. |
Line 4292 ENDHEADERS
|
Line 4637 ENDHEADERS
|
$setversions{$linkurl}, |
$setversions{$linkurl}, |
'set_version_'.$linkurl, |
'set_version_'.$linkurl, |
{'select_form_order' => ['',1..$currentversion,'mostrecent'], |
{'select_form_order' => ['',1..$currentversion,'mostrecent'], |
'' => '', |
'' => '', |
'mostrecent' => &mt('most recent'), |
'mostrecent' => &mt('most recent'), |
map {$_,$_} (1..$currentversion)})); |
map {$_,$_} (1..$currentversion)})); |
my $lastold=1; |
my $lastold=1; |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
my $url=$root.'.'.$prevvers.'.'.$extension; |
my $url=$root.'.'.$prevvers.'.'.$extension; |
Line 4431 sub startContentScreen {
|
Line 4776 sub startContentScreen {
|
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) { |
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) { |
$output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n"; |
|
$output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n"; |
$output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>'; |
$output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>'; |
} else { |
} else { |
$output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n"; |
$output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n"; |
Line 4501 sub handler {
|
Line 4847 sub handler {
|
$allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
$allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
} |
} |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver', |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); |
'inhibitmenu']); |
if ($allowed && $env{'form.verify'}) { |
if ($allowed && $env{'form.chooseserver'}) { |
|
&choose_dump_server($r); |
|
return OK; |
|
} elsif ($allowed && $env{'form.verify'}) { |
|
&init_breadcrumbs('verify','Verify Content','Docs_Verify_Content'); |
&init_breadcrumbs('verify','Verify Content','Docs_Verify_Content'); |
&verifycontent($r); |
&verifycontent($r); |
} elsif ($allowed && $env{'form.listsymbs'}) { |
} elsif ($allowed && $env{'form.listsymbs'}) { |
Line 4567 sub handler {
|
Line 4909 sub handler {
|
my $container; |
my $container; |
my $containertag; |
my $containertag; |
my $pathitem; |
my $pathitem; |
|
my %ltitools; |
|
|
# Do we directly jump somewhere? |
# Do we directly jump somewhere? |
|
|
Line 4704 sub handler {
|
Line 5047 sub handler {
|
} |
} |
} |
} |
my $tabidstr = join("','",@tabids); |
my $tabidstr = join("','",@tabids); |
$script .= &editing_js($udom,$uname,$supplementalflag). |
%ltitools = &Apache::lonnet::get_domain_ltitools($coursedom); |
|
my $posslti = keys(%ltitools); |
|
$script .= &editing_js($udom,$uname,$supplementalflag,$posslti). |
&history_tab_js(). |
&history_tab_js(). |
&inject_data_js(). |
&inject_data_js(). |
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). |
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). |
&Apache::lonextresedit::extedit_javascript(); |
&Apache::lonextresedit::extedit_javascript(\%ltitools); |
$addentries = { |
$addentries = { |
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
}; |
}; |
Line 4724 sub handler {
|
Line 5069 sub handler {
|
.'// <![CDATA['."\n" |
.'// <![CDATA['."\n" |
.$script."\n" |
.$script."\n" |
.'// ]]>'."\n" |
.'// ]]>'."\n" |
.'</script>'."\n"; |
.'</script>'."\n" |
|
.'<script type="text/javascript" |
|
src="/res/adm/includes/file_upload.js"></script>'."\n"; |
|
|
# Breadcrumbs |
# Breadcrumbs |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 4824 sub handler {
|
Line 5171 sub handler {
|
'impo' => 'Import', |
'impo' => 'Import', |
'lnks' => 'Import from Stored Links', |
'lnks' => 'Import from Stored Links', |
'impm' => 'Import from Assembled Map', |
'impm' => 'Import from Assembled Map', |
|
'extr' => 'External Resource', |
|
'extt' => 'External Tool', |
'selm' => 'Select Map', |
'selm' => 'Select Map', |
'load' => 'Load Map', |
'load' => 'Load Map', |
'newf' => 'New Folder', |
'newf' => 'New Folder', |
Line 4832 sub handler {
|
Line 5181 sub handler {
|
'navc' => 'Table of Contents', |
'navc' => 'Table of Contents', |
'sipa' => 'Simple Course Page', |
'sipa' => 'Simple Course Page', |
'sipr' => 'Simple Problem', |
'sipr' => 'Simple Problem', |
'webp' => 'Blank Web Page (editable)', |
'webp' => 'Blank Web Page (editable)', |
'drbx' => 'Drop Box', |
'drbx' => 'Drop Box', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'bull' => 'Discussion Board', |
'bull' => 'Discussion Board', |
Line 4854 sub handler {
|
Line 5203 sub handler {
|
'webctce4' => 'WebCT 4 Campus Edition', |
'webctce4' => 'WebCT 4 Campus Edition', |
); |
); |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
|
|
|
# Calculate free quota space for a user or course. A javascript function checks |
|
# file size to determine if upload should be allowed. |
|
my $quotatype = 'unofficial'; |
|
if ($crstype eq 'Community') { |
|
$quotatype = 'community'; |
|
} elsif ($crstype eq 'Placement') { |
|
$quotatype = 'placement'; |
|
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
|
$quotatype = 'official'; |
|
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
|
$quotatype = 'textbook'; |
|
} |
|
my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom, |
|
'course',$quotatype); # expressed in MB |
|
my $current_disk_usage = 0; |
|
foreach my $subdir ('docs','supplemental') { |
|
$current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum, |
|
"userfiles/$subdir",1); # expressed in kB |
|
} |
|
my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage); |
|
|
my $fileupload=(<<FIUP); |
my $fileupload=(<<FIUP); |
$lt{'file'}:<br /> |
$lt{'file'}:<br /> |
<input type="file" name="uploaddoc" size="40" /> |
<input type="file" name="uploaddoc" class="flUpload" size="40" /> |
|
<input type="hidden" id="free_space" value="$free_space" /> |
FIUP |
FIUP |
|
|
my $checkbox=(<<CHBO); |
my $checkbox=(<<CHBO); |
Line 4903 IMSFORM
|
Line 5275 IMSFORM
|
<fieldset id="uploaddocform" style="display: none;"> |
<fieldset id="uploaddocform" style="display: none;"> |
<legend>$lt{'upfi'}</legend> |
<legend>$lt{'upfi'}</legend> |
<input type="hidden" name="active" value="aa" /> |
<input type="hidden" name="active" value="aa" /> |
$fileupload |
$fileupload |
<br /> |
<br /> |
$lt{'title'}:<br /> |
$lt{'title'}:<br /> |
<input type="text" size="60" name="comment" /> |
<input type="text" size="60" name="comment" /> |
Line 4946 SEDFFORM
|
Line 5318 SEDFFORM
|
my $extresourcesform = |
my $extresourcesform = |
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
$help{'Adding_External_Resource'}); |
$help{'Adding_External_Resource'}); |
|
my $exttoolform = |
|
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
|
$help{'Adding_External_Tool'},undef, |
|
undef,'tool',$coursedom,$coursenum, |
|
\%ltitools); |
if ($allowed) { |
if ($allowed) { |
my $folder = $env{'form.folder'}; |
my $folder = $env{'form.folder'}; |
if ($folder eq '') { |
if ($folder eq '') { |
Line 5123 NROSTFORM
|
Line 5500 NROSTFORM
|
$help{'Web_Page'} |
$help{'Web_Page'} |
</form> |
</form> |
NWEBFORM |
NWEBFORM |
|
|
|
|
my $specialdocumentsform; |
my $specialdocumentsform; |
my @specialdocumentsforma; |
my @specialdocumentsforma; |
Line 5191 NGFFORM
|
Line 5568 NGFFORM
|
my @importdoc = ( |
my @importdoc = ( |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform} |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform} |
); |
); |
|
if (keys(%ltitools)) { |
|
push(@importdoc, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform}, |
|
); |
|
} |
unless ($container eq 'page') { |
unless ($container eq 'page') { |
push(@importdoc, |
push(@importdoc, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform} |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform} |
Line 5232 unless ($container eq 'page') {
|
Line 5614 unless ($container eq 'page') {
|
$hadchanges=0; |
$hadchanges=0; |
unless (($supplementalflag || $toolsflag)) { |
unless (($supplementalflag || $toolsflag)) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
$supplementalflag,\%orderhash,$iconpath,$pathitem); |
$supplementalflag,\%orderhash,$iconpath,$pathitem,\%ltitools); |
if ($error) { |
if ($error) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} |
} |
Line 5299 SNFFORM
|
Line 5681 SNFFORM
|
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
$help{'Adding_External_Resource'}); |
$help{'Adding_External_Resource'}); |
|
|
|
my $supexttoolform = |
|
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
|
$help{'Adding_External_Tool'}, |
|
undef,undef,'tool',$coursedom, |
|
$coursenum,\%ltitools); |
|
|
my $supnewsylform=(<<SNSFORM); |
my $supnewsylform=(<<SNSFORM); |
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
<input type="hidden" name="active" value="ff" /> |
<input type="hidden" name="active" value="ff" /> |
Line 5352 my @specialdocs = (
|
Line 5740 my @specialdocs = (
|
); |
); |
my @supimportdoc = ( |
my @supimportdoc = ( |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />' |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />' |
=>$supextform}, |
=>$supextform}); |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' |
if (keys(%ltitools)) { |
|
push(@supimportdoc, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />' |
|
=>$supexttoolform}); |
|
} |
|
push(@supimportdoc, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' |
=>$supupdocform}, |
=>$supupdocform}, |
); |
); |
|
|
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)); |
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)); |
my %suporderhash = ( |
my %suporderhash = ( |
Line 5365 my %suporderhash = (
|
Line 5759 my %suporderhash = (
|
); |
); |
if ($supplementalflag) { |
if ($supplementalflag) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
$supplementalflag,\%suporderhash,$iconpath,$pathitem); |
$supplementalflag,\%suporderhash,$iconpath,$pathitem,\%ltitools); |
if ($error) { |
if ($error) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} else { |
} else { |
Line 5380 my %suporderhash = (
|
Line 5774 my %suporderhash = (
|
} |
} |
&Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); |
&Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); |
undef($suppchanges); |
undef($suppchanges); |
} |
} |
} |
} |
} |
} |
} elsif ($supplementalflag) { |
} elsif ($supplementalflag) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
Line 5459 sub decompression_info {
|
Line 5853 sub decompression_info {
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $container='sequence'; |
my $container='sequence'; |
my ($pathitem,$hiddenelem); |
my ($pathitem,$hiddenelem); |
my @hiddens = ('newidx','comment','position','folderpath'); |
my @hiddens = ('newidx','comment','position','folderpath','archiveurl'); |
if ($env{'form.folderpath'} =~ /\:1$/) { |
if ($env{'form.folderpath'} =~ /\:1$/) { |
$container='page'; |
$container='page'; |
} |
} |
Line 5467 sub decompression_info {
|
Line 5861 sub decompression_info {
|
foreach my $item (@hiddens) { |
foreach my $item (@hiddens) { |
if ($env{'form.'.$item}) { |
if ($env{'form.'.$item}) { |
$hiddenelem .= '<input type="hidden" name="'.$item.'" value="'. |
$hiddenelem .= '<input type="hidden" name="'.$item.'" value="'. |
$env{'form.'.$item}.'" />'."\n"; |
&HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n"; |
} |
} |
} |
} |
return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container, |
return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container, |
Line 5524 sub remove_archive {
|
Line 5918 sub remove_archive {
|
} else { |
} else { |
$delwarning = &mt('An error occurred retrieving the contents of the current folder.'); |
$delwarning = &mt('An error occurred retrieving the contents of the current folder.'); |
} |
} |
$delwarning .= &mt('As a result the archive file has not been removed.'); |
$delwarning .= ' '.&mt('As a result the archive file has not been removed.'); |
} else { |
} else { |
my $currcmd = $env{'form.cmd'}; |
my $currcmd = $env{'form.cmd'}; |
my $position = $env{'form.position'}; |
my $position = $env{'form.position'}; |
if ($position > 0) { |
my $archiveidx = $position; |
$env{'form.cmd'} = 'remove_'.$position; |
if ($position > 0) { |
my ($title,$url,@rrest) = |
if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) { |
split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]); |
$archiveidx = $position-1; |
if (&handle_edit_cmd($docuname,$docudom)) { |
} |
($errtext,$fatal) = &storemap($docuname,$docudom,$map,1); |
$env{'form.cmd'} = 'remove_'.$archiveidx; |
if ($fatal) { |
my ($title,$url,@rrest) = |
if ($container eq 'page') { |
split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]); |
$delwarning = &mt('An error occurred updating the contents of the current page.'); |
if ($url eq $env{'form.archiveurl'}) { |
|
if (&handle_edit_cmd($docuname,$docudom)) { |
|
($errtext,$fatal) = &storemap($docuname,$docudom,$map,1); |
|
if ($fatal) { |
|
if ($container eq 'page') { |
|
$delwarning = &mt('An error occurred updating the contents of the current page.'); |
|
} else { |
|
$delwarning = &mt('An error occurred updating the contents of the current folder.'); |
|
} |
} else { |
} else { |
$delwarning = &mt('An error occurred updating the contents of the current folder.'); |
$delresult = &mt('Archive file removed.'); |
} |
} |
} else { |
|
$delresult = &mt('Archive file removed.'); |
|
} |
} |
|
} else { |
|
$delwarning .= &mt('Archive file had unexpected item number in folder.'). |
|
' '.&mt('As a result the archive file has not been removed.'); |
} |
} |
} |
} |
$env{'form.cmd'} = $currcmd; |
$env{'form.cmd'} = $currcmd; |
Line 5744 END
|
Line 6147 END
|
} |
} |
|
|
sub editing_js { |
sub editing_js { |
my ($udom,$uname,$supplementalflag) = @_; |
my ($udom,$uname,$supplementalflag,$posslti) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %js_lt = &Apache::lonlocal::texthash( |
p_mnf => 'Name of New Folder', |
p_mnf => 'Name of New Folder', |
t_mnf => 'New Folder', |
t_mnf => 'New Folder', |
p_mnp => 'Name of New Page', |
p_mnp => 'Name of New Page', |
Line 5762 sub editing_js {
|
Line 6165 sub editing_js {
|
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain', |
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain', |
p_chn => 'New Title', |
p_chn => 'New Title', |
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!', |
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!', |
p_rmr2a => 'Remove[_99]', |
p_rmr2a => 'Remove', |
p_rmr2b => '?[_99]', |
p_rmr2b => '?', |
p_rmr3a => 'Remove those [_2]', |
p_rmr3a => 'Remove those', |
p_rmr3b => 'items?[_2]', |
p_rmr3b => 'items?', |
|
p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".', |
|
p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.', |
p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!', |
p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!', |
p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.', |
p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.', |
p_ctr2a => 'Cut[_98]', |
p_ctr2a => 'Cut', |
p_ctr2b => '?[_98]', |
p_ctr2b => '?', |
p_ctr3a => 'Cut those[_2]', |
p_ctr3a => 'Cut those', |
p_ctr3b => 'items?[_2]', |
p_ctr3b => 'items?', |
rpck => 'Enter number to pick (e.g., 3)', |
rpck => 'Enter number to pick (e.g., 3)', |
imsfile => 'You must choose an IMS package for import', |
imsfile => 'You must choose an IMS package for import', |
imscms => 'You must select which Course Management System was the source of the IMS package', |
imscms => 'You must select which Course Management System was the source of the IMS package', |
Line 5783 sub editing_js {
|
Line 6188 sub editing_js {
|
noch => 'No changes to settings specified.', |
noch => 'No changes to settings specified.', |
noac => 'No actions selected.', |
noac => 'No actions selected.', |
); |
); |
|
&js_escape(\%js_lt); |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
my $main_container_page; |
my $main_container_page; |
Line 5805 sub editing_js {
|
Line 6210 sub editing_js {
|
if (&Apache::lonnet::is_on_map($res)) { |
if (&Apache::lonnet::is_on_map($res)) { |
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='. |
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='. |
&HTML::Entities::encode($caller,'<>&"'); |
&HTML::Entities::encode($caller,'<>&"'); |
|
$backtourl = &Apache::loncommon::escape_single($backtourl); |
} else { |
} else { |
$backtourl = '/adm/navmaps'; |
$backtourl = '/adm/navmaps'; |
} |
} |
Line 5818 sub editing_js {
|
Line 6224 sub editing_js {
|
} |
} |
|
|
my $fieldsets = "'ext','doc'"; |
my $fieldsets = "'ext','doc'"; |
|
if ($posslti) { |
|
$fieldsets .= ",'tool'"; |
|
} |
unless ($main_container_page) { |
unless ($main_container_page) { |
$fieldsets .=",'ims'"; |
$fieldsets .=",'ims'"; |
} |
} |
if ($supplementalflag) { |
if ($supplementalflag) { |
$fieldsets = "'suppext','suppdoc'"; |
$fieldsets = "'suppext','suppdoc'"; |
|
if ($posslti) { |
|
$fieldsets .= ",'supptool'"; |
|
} |
} |
} |
|
|
return <<ENDNEWSCRIPT; |
return <<ENDNEWSCRIPT; |
function makenewfolder(targetform,folderseq) { |
function makenewfolder(targetform,folderseq) { |
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}'); |
var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}'); |
if (foldername) { |
if (foldername) { |
targetform.importdetail.value=escape(foldername)+"="+folderseq; |
targetform.importdetail.value=escape(foldername)+"="+folderseq; |
targetform.submit(); |
targetform.submit(); |
Line 5835 function makenewfolder(targetform,folder
|
Line 6247 function makenewfolder(targetform,folder
|
} |
} |
|
|
function makenewpage(targetform,folderseq) { |
function makenewpage(targetform,folderseq) { |
var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}'); |
var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}'); |
if (pagename) { |
if (pagename) { |
targetform.importdetail.value=escape(pagename)+"="+folderseq; |
targetform.importdetail.value=escape(pagename)+"="+folderseq; |
targetform.submit(); |
targetform.submit(); |
Line 5843 function makenewpage(targetform,folderse
|
Line 6255 function makenewpage(targetform,folderse
|
} |
} |
|
|
function makeexamupload() { |
function makeexamupload() { |
var title=prompt('$lt{"p_mxu"}'); |
var title=prompt('$js_lt{"p_mxu"}'); |
if (title) { |
if (title) { |
this.document.forms.newexamupload.importdetail.value= |
this.document.forms.newexamupload.importdetail.value= |
escape(title)+'=/res/lib/templates/examupload.problem'; |
escape(title)+'=/res/lib/templates/examupload.problem'; |
Line 5852 function makeexamupload() {
|
Line 6264 function makeexamupload() {
|
} |
} |
|
|
function makesmppage() { |
function makesmppage() { |
var title=prompt('$lt{"p_msp"}'); |
var title=prompt('$js_lt{"p_msp"}'); |
if (title) { |
if (title) { |
this.document.forms.newsmppg.importdetail.value= |
this.document.forms.newsmppg.importdetail.value= |
escape(title)+'=/adm/$udom/$uname/new/smppg'; |
escape(title)+'=/adm/$udom/$uname/new/smppg'; |
Line 5861 function makesmppage() {
|
Line 6273 function makesmppage() {
|
} |
} |
|
|
function makewebpage(type) { |
function makewebpage(type) { |
var title=prompt('$lt{"p_mwp"}'); |
var title=prompt('$js_lt{"p_mwp"}'); |
var formname; |
var formname; |
if (type == 'supp') { |
if (type == 'supp') { |
formname = this.document.forms.supwebpage; |
formname = this.document.forms.supwebpage; |
Line 5869 function makewebpage(type) {
|
Line 6281 function makewebpage(type) {
|
formname = this.document.forms.newwebpage; |
formname = this.document.forms.newwebpage; |
} |
} |
if (title) { |
if (title) { |
var webpage = formname.importdetail.value; |
var webpage = formname.importdetail.value; |
formname.importdetail.value = escape(title)+'='+webpage; |
formname.importdetail.value = escape(title)+'='+webpage; |
formname.submit(); |
formname.submit(); |
} |
} |
} |
} |
|
|
function makesmpproblem() { |
function makesmpproblem() { |
var title=prompt('$lt{"p_msb"}'); |
var title=prompt('$js_lt{"p_msb"}'); |
if (title) { |
if (title) { |
this.document.forms.newsmpproblem.importdetail.value= |
this.document.forms.newsmpproblem.importdetail.value= |
escape(title)+'=/res/lib/templates/simpleproblem.problem'; |
escape(title)+'=/res/lib/templates/simpleproblem.problem'; |
Line 5885 function makesmpproblem() {
|
Line 6297 function makesmpproblem() {
|
} |
} |
|
|
function makedropbox() { |
function makedropbox() { |
var title=prompt('$lt{"p_mdb"}'); |
var title=prompt('$js_lt{"p_mdb"}'); |
if (title) { |
if (title) { |
this.document.forms.newdropbox.importdetail.value= |
this.document.forms.newdropbox.importdetail.value= |
escape(title)+'=/res/lib/templates/DropBox.problem'; |
escape(title)+'=/res/lib/templates/DropBox.problem'; |
Line 5894 function makedropbox() {
|
Line 6306 function makedropbox() {
|
} |
} |
|
|
function makebulboard() { |
function makebulboard() { |
var title=prompt('$lt{"p_mbb"}'); |
var title=prompt('$js_lt{"p_mbb"}'); |
if (title) { |
if (title) { |
this.document.forms.newbul.importdetail.value= |
this.document.forms.newbul.importdetail.value= |
escape(title)+'=/adm/$udom/$uname/new/bulletinboard'; |
escape(title)+'=/adm/$udom/$uname/new/bulletinboard'; |
Line 5903 function makebulboard() {
|
Line 6315 function makebulboard() {
|
} |
} |
|
|
function makeabout() { |
function makeabout() { |
var user=prompt("$lt{'p_mab'}"); |
var user=prompt("$js_lt{'p_mab'}"); |
if (user) { |
if (user) { |
var comp=new Array(); |
var comp=new Array(); |
comp=user.split(':'); |
comp=user.split(':'); |
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { |
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { |
if ((comp[0]) && (comp[1])) { |
if ((comp[0]) && (comp[1])) { |
this.document.forms.newaboutsomeone.importdetail.value= |
this.document.forms.newaboutsomeone.importdetail.value= |
'$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; |
'$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; |
this.document.forms.newaboutsomeone.submit(); |
this.document.forms.newaboutsomeone.submit(); |
} else { |
} else { |
alert("$lt{'p_mab_alrt1'}"); |
alert("$js_lt{'p_mab_alrt1'}"); |
} |
} |
} else { |
} else { |
alert("$lt{'p_mab_alrt2'}"); |
alert("$js_lt{'p_mab_alrt2'}"); |
} |
} |
} |
} |
} |
} |
Line 5932 function toggleUpload(caller) {
|
Line 6344 function toggleUpload(caller) {
|
} |
} |
} |
} |
document.getElementById('upload'+blocks[i]+'form').style.display=disp; |
document.getElementById('upload'+blocks[i]+'form').style.display=disp; |
|
if ((caller == 'tool') || (caller == 'supptool')) { |
|
if (disp == 'block') { |
|
if (document.getElementById('LC_exttoolid')) { |
|
var toolselector = document.getElementById('LC_exttoolid'); |
|
var suppflag = 0; |
|
if (caller == 'supptool') { |
|
suppflag = 1; |
|
} |
|
currForm = document.getElementById('new'+caller); |
|
updateExttool(toolselector,currForm,suppflag); |
|
} |
|
} |
|
} |
} |
} |
resize_scrollbox('contentscroll','1','1'); |
resize_scrollbox('contentscroll','1','1'); |
return; |
return; |
Line 5954 function toggleMap(caller) {
|
Line 6379 function toggleMap(caller) {
|
|
|
function makeims(imsform) { |
function makeims(imsform) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
alert("$lt{'imsfile'}"); |
alert("$js_lt{'imsfile'}"); |
return; |
return; |
} |
} |
if (imsform.source.selectedIndex == 0) { |
if (imsform.source.selectedIndex == 0) { |
alert("$lt{'imscms'}"); |
alert("$js_lt{'imscms'}"); |
return; |
return; |
} |
} |
newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes"); |
newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes"); |
Line 5966 function makeims(imsform) {
|
Line 6391 function makeims(imsform) {
|
} |
} |
|
|
function changename(folderpath,index,oldtitle) { |
function changename(folderpath,index,oldtitle) { |
var title=prompt('$lt{"p_chn"}',oldtitle); |
var title=prompt('$js_lt{"p_chn"}',oldtitle); |
if (title) { |
if (title) { |
this.document.forms.renameform.markcopy.value=''; |
this.document.forms.renameform.markcopy.value=''; |
this.document.forms.renameform.title.value=title; |
this.document.forms.renameform.title.value=title; |
Line 5990 function updatePick(targetform,index,cal
|
Line 6415 function updatePick(targetform,index,cal
|
picknumtext = document.getElementById('randompicknum_'+index); |
picknumtext = document.getElementById('randompicknum_'+index); |
} |
} |
if (pickitem.checked) { |
if (pickitem.checked) { |
var picknum=prompt('$lt{"rpck"}',picknumitem.value); |
var picknum=prompt('$js_lt{"rpck"}',picknumitem.value); |
if (picknum == '' || picknum == null) { |
if (picknum == '' || picknum == null) { |
if (caller == 'check') { |
if (caller == 'check') { |
pickitem.checked=false; |
pickitem.checked=false; |
Line 6140 function propagateState(form,param) {
|
Line 6565 function propagateState(form,param) {
|
return; |
return; |
} |
} |
|
|
function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) { |
function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) { |
var dosettings; |
var dosettings; |
var doaction; |
var doaction; |
var control = document.togglemultsettings; |
var control = document.togglemultsettings; |
Line 6178 function checkForSubmit(targetform,param
|
Line 6603 function checkForSubmit(targetform,param
|
targetform.markcopy.value=idx+':'+param; |
targetform.markcopy.value=idx+':'+param; |
targetform.copyfolder.value=folder+'.'+container; |
targetform.copyfolder.value=folder+'.'+container; |
if (param == 'remove') { |
if (param == 'remove') { |
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) { |
var doremove = 0; |
|
if (skip_confirm) { |
|
if (confirm_removal) { |
|
if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) { |
|
doremove = 1; |
|
} |
|
} else { |
|
doremove = 1; |
|
} |
|
} else { |
|
if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) { |
|
doremove = 1; |
|
} |
|
} |
|
if (doremove) { |
targetform.markcopy.value=''; |
targetform.markcopy.value=''; |
targetform.copyfolder.value=''; |
targetform.copyfolder.value=''; |
targetform.submit(); |
targetform.submit(); |
} |
} |
} |
} |
if (param == 'cut') { |
if (param == 'cut') { |
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) { |
if (skip_confirm || confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr2a"} "'+oldtitle+'" $js_lt{"p_ctr2b"}')) { |
targetform.submit(); |
targetform.submit(); |
return; |
return; |
} |
} |
Line 6250 for (i = 0; i < currentLis.length; i++)
|
Line 6689 for (i = 0; i < currentLis.length; i++)
|
|
|
function hideAll(current, nav, data) { |
function hideAll(current, nav, data) { |
unselectInactive(nav); |
unselectInactive(nav); |
if (current) { |
if (current) { |
if (current.className == 'right'){ |
if (current.className == 'right'){ |
current.className = 'right active' |
current.className = 'right active' |
} else { |
} else { |
current.className = 'active'; |
current.className = 'active'; |
} |
} |
} |
} |
currentData = document.getElementById(data); |
currentData = document.getElementById(data); |
Line 6292 function showPage(current, pageId, nav,
|
Line 6731 function showPage(current, pageId, nav,
|
unselectInactive(nav); |
unselectInactive(nav); |
if ((currstate == 'active') || (currstate == 'right active')) { |
if ((currstate == 'active') || (currstate == 'right active')) { |
if (currstate == 'active') { |
if (currstate == 'active') { |
current.className = ''; |
current.className = ''; |
} else { |
} else { |
current.className = 'right'; |
current.className = 'right'; |
} |
} |
activeTab = ''; |
activeTab = ''; |
toggleUpload(); |
toggleUpload(); |
toggleMap(); |
toggleMap(); |
resize_scrollbox('contentscroll','1','0'); |
resize_scrollbox('contentscroll','1','0'); |
Line 6364 function togglePick(caller,value) {
|
Line 6803 function togglePick(caller,value) {
|
} |
} |
document.getElementById('multi'+caller).style.display=disp; |
document.getElementById('multi'+caller).style.display=disp; |
if (value == 1) { |
if (value == 1) { |
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>'; |
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>'; |
} else { |
} else { |
document.getElementById('more'+caller).innerHTML = ''; |
document.getElementById('more'+caller).innerHTML = ''; |
} |
} |
Line 6390 function togglePick(caller,value) {
|
Line 6829 function togglePick(caller,value) {
|
|
|
function toggleCheckUncheck(caller,more) { |
function toggleCheckUncheck(caller,more) { |
if (more == 1) { |
if (more == 1) { |
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$lt{'less'}</a>'; |
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>'; |
document.getElementById('allfields'+caller).style.display='block'; |
document.getElementById('allfields'+caller).style.display='block'; |
} else { |
} else { |
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>'; |
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>'; |
document.getElementById('allfields'+caller).style.display='none'; |
document.getElementById('allfields'+caller).style.display='none'; |
} |
} |
resize_scrollbox('contentscroll','1','1'); |
resize_scrollbox('contentscroll','1','1'); |
Line 6435 function checkSubmits() {
|
Line 6874 function checkSubmits() {
|
var doactions = multiActions(); |
var doactions = multiActions(); |
var cutwarnings = 0; |
var cutwarnings = 0; |
var remwarnings = 0; |
var remwarnings = 0; |
|
var removalinfo = 0; |
if (doactions == 1) { |
if (doactions == 1) { |
var remidxlist = document.cumulativeactions.allremoveidx.value; |
var remidxlist = document.cumulativeactions.allremoveidx.value; |
if ((remidxlist != '') && (remidxlist != null)) { |
if ((remidxlist != '') && (remidxlist != null)) { |
Line 6449 function checkSubmits() {
|
Line 6889 function checkSubmits() {
|
remwarnings ++; |
remwarnings ++; |
} |
} |
} |
} |
|
if (document.getElementById('confirm_removal_'+remidxs[i])) { |
|
if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) { |
|
removalinfo ++; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 6547 function checkSubmits() {
|
Line 6992 function checkSubmits() {
|
} |
} |
if (doactions == 1) { |
if (doactions == 1) { |
if (numchanges > 0) { |
if (numchanges > 0) { |
if ((cutwarnings > 0) || (remwarnings > 0)) { |
if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) { |
if (remwarnings > 0) { |
if (remwarnings > 0) { |
if (!confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr3a"} '+remwarnings+' $lt{"p_rmr3b"}')) { |
if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) { |
|
return false; |
|
} |
|
} |
|
if (removalinfo > 0) { |
|
if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) { |
return false; |
return false; |
} |
} |
} |
} |
if (cutwarnings > 0) { |
if (cutwarnings > 0) { |
if (!confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr3a"} '+cutwarnings+' $lt{"p_ctr3b"}')) { |
if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) { |
return false; |
return false; |
} |
} |
} |
} |
Line 6570 function checkSubmits() {
|
Line 7020 function checkSubmits() {
|
} |
} |
} |
} |
if ((dosettings == 1) && (doactions == 1)) { |
if ((dosettings == 1) && (doactions == 1)) { |
alert("$lt{'noor'}"); |
alert("$js_lt{'noor'}"); |
} else { |
} else { |
if (dosettings == 1) { |
if (dosettings == 1) { |
alert("$lt{'noch'}"); |
alert("$js_lt{'noch'}"); |
} else { |
} else { |
alert("$lt{'noac'}"); |
alert("$js_lt{'noac'}"); |
} |
} |
} |
} |
return false; |
return false; |
Line 6690 ENDINJECT
|
Line 7140 ENDINJECT
|
|
|
sub dump_switchserver_js { |
sub dump_switchserver_js { |
my @hosts = @_; |
my @hosts = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %js_lt = &Apache::lonlocal::texthash( |
dump => 'Copying content to Authoring Space requires switching server.', |
dump => 'Copying content to Authoring Space requires switching server.', |
swit => 'Switch server?', |
swit => 'Switch server?', |
|
); |
|
my %html_js_lt = &Apache::lonlocal::texthash( |
|
swit => 'Switch server?', |
duco => 'Copying Content to Authoring Space', |
duco => 'Copying Content to Authoring Space', |
yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.', |
yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.', |
chos => 'Choose server', |
chos => 'Choose server', |
); |
); |
|
&js_escape(\%js_lt); |
|
&html_escape(\%html_js_lt); |
|
&js_escape(\%html_js_lt); |
my $role = $env{'request.role'}; |
my $role = $env{'request.role'}; |
my $js = <<"ENDSWJS"; |
my $js = <<"ENDSWJS"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 6737 ENDSWJS
|
Line 7193 ENDSWJS
|
|
|
function dump_needs_switchserver(url) { |
function dump_needs_switchserver(url) { |
if (url!='' && url!= null) { |
if (url!='' && url!= null) { |
if (confirm("$lt{'dump'}\\n$lt{'swit'}")) { |
if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) { |
go(url); |
go(url); |
} |
} |
} |
} |
Line 6748 function choose_switchserver_window() {
|
Line 7204 function choose_switchserver_window() {
|
newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes') |
newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes') |
newWindow.document.open(); |
newWindow.document.open(); |
newWindow.document.writeln('$startpage'); |
newWindow.document.writeln('$startpage'); |
newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+ |
newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+ |
'<p>$lt{'yone'}<\\/p>\\n'+ |
'<p>$html_js_lt{'yone'}<\\/p>\\n'+ |
'<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+ |
'<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+ |
'<form name="setserver" method="post" action="" \\/>\\n'+ |
'<form name="setserver" method="post" action="" \\/>\\n'+ |
'$hostpicker\\n'+ |
'$hostpicker\\n'+ |
'<br \\/><br \\/>\\n'+ |
'<br \\/><br \\/>\\n'+ |
'<input type="button" name="makeswitch" value="$lt{'swit'}" '+ |
'<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+ |
'onclick="write_switchserver();" \\/>\\n'+ |
'onclick="write_switchserver();" \\/>\\n'+ |
'<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n'); |
'<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n'); |
newWindow.document.writeln('$endpage'); |
newWindow.document.writeln('$endpage'); |