version 1.484.2.15, 2012/12/13 02:45:27
|
version 1.489, 2012/07/05 21:33:39
|
Line 69 sub mapread {
|
Line 69 sub mapread {
|
} |
} |
|
|
sub storemap { |
sub storemap { |
my ($coursenum,$coursedom,$map,$contentchg)=@_; |
my ($coursenum,$coursedom,$map)=@_; |
my $report; |
|
if (($contentchg) && ($map =~ /^default/)) { |
|
$report = 1; |
|
} |
|
my ($outtext,$errtext)= |
my ($outtext,$errtext)= |
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
$map,1,$report); |
$map,1); |
if ($errtext) { return ($errtext,2); } |
if ($errtext) { return ($errtext,2); } |
|
|
$hadchanges=1; |
$hadchanges=1; |
Line 309 sub group_import {
|
Line 305 sub group_import {
|
join(':', ($name, $url, $ext, 'normal', 'res')); |
join(':', ($name, $url, $ext, 'normal', 'res')); |
} |
} |
} |
} |
return &storemap($coursenum, $coursedom, $folder.'.'.$container,1); |
return &storemap($coursenum, $coursedom, $folder.'.'.$container); |
} |
} |
|
|
sub breadcrumbs { |
sub breadcrumbs { |
Line 322 sub breadcrumbs {
|
Line 318 sub breadcrumbs {
|
@folders=split('&',$env{'form.folderpath'}); |
@folders=split('&',$env{'form.folderpath'}); |
} |
} |
my $folderpath; |
my $folderpath; |
|
my $cpinfo=''; |
my $plain=''; |
my $plain=''; |
my $randompick=-1; |
my $randompick=-1; |
my $isencrypted=0; |
my $isencrypted=0; |
Line 354 sub breadcrumbs {
|
Line 351 sub breadcrumbs {
|
$name = &mt('Supplemental '.$crstype.' Content'); |
$name = &mt('Supplemental '.$crstype.' Content'); |
} |
} |
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
{'href'=>$url, |
{'href'=>$url.$cpinfo, |
'title'=>$name, |
'title'=>$name, |
'text'=>$name, |
'text'=>$name, |
'no_mt'=>1, |
'no_mt'=>1, |
Line 368 sub breadcrumbs {
|
Line 365 sub breadcrumbs {
|
} |
} |
|
|
sub log_docs { |
sub log_docs { |
return &Apache::lonnet::write_log('course','docslog',@_); |
return &Apache::lonnet::instructor_log('docslog',@_); |
} |
} |
|
|
{ |
{ |
Line 537 sub docs_change_log {
|
Line 534 sub docs_change_log {
|
':'.$docslog{$id}{'exe_udom'}.'</tt>'. |
':'.$docslog{$id}{'exe_udom'}.'</tt>'. |
$send_msg_link.'</td><td>'. |
$send_msg_link.'</td><td>'. |
$docslog{$id}{'logentry'}{'folder'}.'</td><td>'); |
$docslog{$id}{'logentry'}{'folder'}.'</td><td>'); |
my $is_supp = 0; |
my $is_supp = 0; |
if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) { |
if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) { |
$is_supp = 1; |
$is_supp = 1; |
} |
} |
Line 560 sub docs_change_log {
|
Line 557 sub docs_change_log {
|
if ($is_supp) { |
if ($is_supp) { |
$shown = &Apache::loncommon::parse_supplemental_title($shown); |
$shown = &Apache::loncommon::parse_supplemental_title($shown); |
} |
} |
$r->print('<li>'.$shown.'</li>'); |
$r->print('<li>'.$shown.'</li>'); |
} |
} |
} |
} |
$r->print('</ul>'); |
$r->print('</ul>'); |
Line 615 sub docs_change_log {
|
Line 612 sub docs_change_log {
|
} |
} |
|
|
sub update_paste_buffer { |
sub update_paste_buffer { |
my ($coursenum,$coursedom,$folder) = @_; |
my ($coursenum,$coursedom) = @_; |
|
|
return if (!defined($env{'form.markcopy'})); |
return if (!defined($env{'form.markcopy'})); |
return if (!defined($env{'form.copyfolder'})); |
return if (!defined($env{'form.copyfolder'})); |
Line 636 sub update_paste_buffer {
|
Line 633 sub update_paste_buffer {
|
} |
} |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
|
|
(my $cmd,undef)=split('_',$env{'form.cmd'}); |
&Apache::lonnet::appenv({'docs.markedcopy_title' => $title, |
|
'docs.markedcopy_url' => $url}); |
my %addtoenv = ( |
|
'docs.markedcopy_title' => $title, |
|
'docs.markedcopy_url' => $url, |
|
'docs.markedcopy_cmd' => $cmd, |
|
); |
|
&Apache::lonnet::delenv('docs.markedcopy_nested'); |
|
&Apache::lonnet::delenv('docs.markedcopy_nestednames'); |
|
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { |
|
my $prefix = $1; |
|
my $subdir =$2; |
|
if ($subdir eq '') { |
|
$subdir = $prefix; |
|
} |
|
my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); |
|
&contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps, |
|
\%hierarchy,\%titles,\%allmaps); |
|
if (ref($hierarchy{$url}) eq 'HASH') { |
|
my ($nested,$nestednames); |
|
&recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames); |
|
$nested =~ s/\&$//; |
|
$nestednames =~ s/\Q___&&&___\E$//; |
|
if ($nested ne '') { |
|
$addtoenv{'docs.markedcopy_nested'} = $nested; |
|
} |
|
if ($nestednames ne '') { |
|
$addtoenv{'docs.markedcopy_nestednames'} = $nestednames; |
|
} |
|
} |
|
} |
|
&Apache::lonnet::appenv(\%addtoenv); |
|
delete($env{'form.markcopy'}); |
delete($env{'form.markcopy'}); |
} |
} |
|
|
sub recurse_uploaded_maps { |
|
my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_; |
|
if (ref($hierarchy->{$url}) eq 'HASH') { |
|
my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}})); |
|
my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}})); |
|
my (@uploaded,@names,%shorter); |
|
for (my $i=0; $i<@maps; $i++) { |
|
my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$}); |
|
if ($inner ne '') { |
|
push(@uploaded,$inner); |
|
push(@names,&escape($titles[$i])); |
|
$shorter{$maps[$i]} = $inner; |
|
} |
|
} |
|
$$nestref .= "$dir:".join(',',@uploaded).'&'; |
|
$$namesref .= "$dir:".(join(',',@names)).'___&&&___'; |
|
foreach my $map (@maps) { |
|
if ($shorter{$map} ne '') { |
|
&recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref); |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub print_paste_buffer { |
sub print_paste_buffer { |
my ($r,$container,$folder,$coursedom,$coursenum) = @_; |
my ($r,$container,$folder) = @_; |
return if (!defined($env{'docs.markedcopy_url'})); |
return if (!defined($env{'docs.markedcopy_url'})); |
|
|
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent); |
my $is_external; |
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; |
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; |
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
$is_external = 1; |
$is_external = 1; |
} |
} |
|
|
my ($canpaste,$nopaste,$othercrs,$areachange,$is_uploaded_map); |
my $canpaste; |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url'}); |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url'}); |
unless ($canpaste) { |
|
$nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.'); |
|
} |
|
} else { |
} else { |
$canpaste = 1; |
$canpaste = 1; |
} |
} |
|
|
|
my $pasteinfo; |
if ($canpaste) { |
if ($canpaste) { |
if ($env{'docs.markedcopy_url'} =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
$pasteinfo = '<form name="pasteform" action="/adm/coursedocs" method="post">' |
my $srcdom = $1; |
.'<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> '; |
my $srcnum = $2; |
} else { |
my $rem = $3; |
$pasteinfo = &mt('Paste buffer contains:').' '; |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
|
$othercourse = 1; |
|
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
|
if ($canpaste) { |
|
$othercrs = '<br />'.&mt('(from another course).'); |
|
} |
|
} else { |
|
$canpaste = 0; |
|
$nopaste = &mt('Paste from another course unavailable.') |
|
} |
|
} |
|
if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) { |
|
my $prefix = $1; |
|
$parent = $2; |
|
if ($folder !~ /^\Q$prefix\E/) { |
|
$areachange = 1; |
|
} |
|
$is_uploaded_map = 1; |
|
} |
|
} |
|
} |
} |
|
|
$r->print('<fieldset>' |
$r->print('<fieldset>' |
.'<legend>'.&mt('Clipboard').'</legend>'); |
.'<legend>'.&mt('Clipboard').'</legend>' |
my ($type,$buffer); |
.$pasteinfo |
|
); |
|
|
|
my $type; |
if ($is_external) { |
if ($is_external) { |
$type = &mt('External Resource'); |
$type = &mt('External Resource'); |
$buffer = $type.': '. |
$r->print($type.': '. |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('. |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('. |
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')'; |
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')'); |
} else { |
} else { |
my $icon = &Apache::loncommon::icon($extension); |
my $icon = &Apache::loncommon::icon($extension); |
if ($extension eq 'sequence' && |
if ($extension eq 'sequence' && |
Line 759 sub print_paste_buffer {
|
Line 682 sub print_paste_buffer {
|
$icon .= '/navmap.folder.closed.gif'; |
$icon .= '/navmap.folder.closed.gif'; |
} |
} |
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />'; |
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />'; |
$buffer = $icon.$type.': '. &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})); |
$r->print($icon.$type.': '. &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}))); |
} |
} |
if ($canpaste) { |
if ($canpaste) { |
$r->print('<form name="pasteform" action="/adm/coursedocs" method="post">'.$buffer); |
|
if (($is_uploaded_map) && (!$areachange)) { |
|
if ((!$othercourse) && ($env{'docs.markedcopy_cmd'} eq 'cut')) { |
|
$r->print((' 'x 4).'<span id="pasteoptionstext">'. |
|
'<a href="javascript:showPasteOptions();" class="LC_menubuttons_link">'. |
|
&mt('Show Paste Options').'</a></span><br />'. |
|
'<div id="pasteoptions" class="LC_dccid">'.(' 'x 4). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_options" value="new" checked="checked" />'. |
|
&mt('Copy to new folder').'</label>'.(' ' x2). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_options" value="move" />'. |
|
&mt('Move old folder').'</label><br />'); |
|
if ($env{'docs.markedcopy_nested'}) { |
|
$r->print('<br />'.&mt('Folder to paste contains sub-folders'). |
|
'<br /><table border="0">'); |
|
my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested'}); |
|
my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames'}); |
|
my $lastdir = $parent; |
|
my %depths = ( |
|
$lastdir => 0, |
|
); |
|
my (%display,%deps); |
|
for (my $i=0; $i<@pastemaps; $i++) { |
|
($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]); |
|
my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]); |
|
my @subfolders = split(/,/,$subfolderstr); |
|
$deps{$lastdir} = \@subfolders; |
|
my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr); |
|
my $depth = $depths{$lastdir} + 1; |
|
my $offset = int($depth * 4); |
|
my $indent = (' ' x $offset); |
|
for (my $j=0; $j<@subfolders; $j++) { |
|
$depths{$subfolders[$j]} = $depth; |
|
$display{$subfolders[$j]} = |
|
'<tr><td>'.$indent.$subfoldertitles[$j].' </td>'. |
|
'<td><label>'. |
|
'<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="move" />'. |
|
&mt('Move old').'</label>'. |
|
'</td></tr>'; |
|
} |
|
} |
|
&recurse_print($r,$parent,\%deps,\%display); |
|
$r->print('</table>'); |
|
} |
|
$r->print('</div>'); |
|
} |
|
} |
|
$r->print('<br /><input type="submit" name="pastemarked" value="'.&mt('Paste').'" />'.$othercrs); |
|
if ($container eq 'page') { |
if ($container eq 'page') { |
$r->print(' |
$r->print(' |
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" /> |
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" /> |
Line 825 sub print_paste_buffer {
|
Line 697 sub print_paste_buffer {
|
} |
} |
$r->print('</form>'); |
$r->print('</form>'); |
} else { |
} else { |
$r->print(&mt('Paste buffer contains:').' '.$buffer. |
$r->print('<br /><p class="LC_info">'.&mt('Paste into Supplemental Content unavailable for this type of content.').'</p>'); |
'<br /><p class="LC_info">'.$nopaste.'</p>'); |
|
} |
} |
$r->print('</fieldset>'); |
$r->print('</fieldset>'); |
} |
} |
|
|
sub recurse_print { |
|
my ($r,$dir,$deps,$display) = @_; |
|
$r->print($display->{$dir}."\n"); |
|
if (ref($deps->{$dir}) eq 'ARRAY') { |
|
foreach my $subdir (@{$deps->{$dir}}) { |
|
&recurse_print($r,$subdir,$deps,$display); |
|
} |
|
} |
|
} |
|
|
|
sub supp_pasteable { |
sub supp_pasteable { |
my ($url) = @_; |
my ($url) = @_; |
if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) || |
if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) || |
Line 853 sub supp_pasteable {
|
Line 714 sub supp_pasteable {
|
return; |
return; |
} |
} |
|
|
sub paste_popup_js { |
|
my %lt = &Apache::lonlocal::texthash( |
|
show => 'Show Paste Options', |
|
hide => 'Hide Paste Options', |
|
); |
|
return <<"END"; |
|
|
|
function showPasteOptions() { |
|
document.getElementById('pasteoptions').style.display='block'; |
|
document.getElementById('pasteoptions').style.textAlign='left'; |
|
document.getElementById('pasteoptions').style.textFace='normal'; |
|
document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:hidePasteOptions();" class="LC_menubuttons_link">$lt{'hide'}</a><br />'; |
|
return; |
|
} |
|
|
|
function hidePasteOptions() { |
|
document.getElementById('pasteoptions').style.display='none'; |
|
document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:showPasteOptions()" class="LC_menubuttons_link">$lt{'show'}</a>'; |
|
return; |
|
} |
|
|
|
END |
|
|
|
} |
|
|
|
|
|
sub do_paste_from_buffer { |
sub do_paste_from_buffer { |
my ($coursenum,$coursedom,$folder,$container,$errors) = @_; |
my ($coursenum,$coursedom,$folder) = @_; |
|
|
# Early out if paste buffer is empty |
|
if (!$env{'form.pastemarked'}) { |
if (!$env{'form.pastemarked'}) { |
return (); |
return; |
} |
} |
|
|
# 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 |
|
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
unless (&supp_pasteable($env{'docs.markedcopy_url'})) { |
unless (&supp_pasteable($env{'docs.markedcopy_url'})) { |
return (&mt('Paste failed: content type is not supported within Supplemental Content')); |
return &mt('Paste failed: content type is not supported within Supplemental Content'); |
} |
} |
} |
} |
|
|
# Prepare to paste resource at end of list |
# paste resource to end of list |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); |
|
|
my ($is_map,$srcdom,$srcnum,$prefixchg,%before,%after,%mapchanges,%tomove); |
|
if ($url=~/\.(page|sequence)$/) { |
|
$is_map = 1; |
|
} |
|
if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/([^/]+)}) { |
|
$srcdom = $1; |
|
$srcnum = $2; |
|
my $oldprefix = $3; |
|
# 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 (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
|
unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
|
return (&mt('Paste failed: Item is from a different course which you do not have rights to edit.')); |
|
} |
|
} |
|
# When pasting content from Main Content to Supplemental Content and vice versa |
|
# URLs will contain different paths (which depend on whether pasted item is |
|
# a folder/page or a document. |
|
if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) { |
|
$prefixchg = 1; |
|
%before = ( map => 'default', |
|
doc => 'docs'); |
|
%after = ( map => 'supplemental', |
|
doc => 'supplemental' ); |
|
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
|
$prefixchg = 1; |
|
%before = ( map => 'supplemental', |
|
doc => 'supplemental'); |
|
%after = ( map => 'default', |
|
doc => 'docs'); |
|
} |
|
|
|
# If pasting an uploaded map, get list of contained uploaded maps. |
|
my @nested; |
|
if ($env{'docs.markedcopy_nested'}) { |
|
my ($type) = ($oldprefix =~ /^(default|supplemental)/); |
|
my @items = split(/\&/,$env{'docs.markedcopy_nested'}); |
|
my @deps = map { /\d+:([\d,]+$)/ } @items; |
|
foreach my $dep (@deps) { |
|
if ($dep =~ /,/) { |
|
push(@nested,split(/,/,$dep)); |
|
} else { |
|
push(@nested,$dep); |
|
} |
|
} |
|
foreach my $item (@nested) { |
|
if ($env{'form.docs.markedcopy_'.$item} eq 'move') { |
|
$tomove{$type.'_'.$item} = 1; |
|
} |
|
} |
|
} |
|
} |
|
|
|
# Maps need to be copied first |
# Maps need to be copied first |
my ($oldurl,%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies, |
my ($oldurl,%removefrommap,%addedmaps,%rewrites,%copies,%dbcopies,%zombies,%params, |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls); |
%moves,$srcdom,$srcnum); |
$oldurl = $url; |
$oldurl = $url; |
if ($is_map) { |
if ($url=~/\.(page|sequence)$/) { |
if ($folder =~ /^default/) { |
# If pasting a map, check if map contains other maps |
my $lastchange = &Apache::lonnet::get_coursechange($coursedom,$coursenum); |
&contained_map_check($url,$folder,\%removefrommap,\%addedmaps); |
if ($lastchange > $env{'request.course.tied'}) { |
if (keys(%addedmaps) > 0) { |
&reinit_role($coursedom,$coursenum,$env{"course.$env{'request.course.id'}.home"}); |
&reinit_role($coursedom,$coursenum,$env{"course.$env{'request.course.id'}.home"}); |
} |
} |
} |
my %allmaps; |
# If pasting a map, check if map contains other maps |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my (%allmaps,%hierarchy,%titles); |
if (defined($navmap)) { |
if ($folder =~ /^default/) { |
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) { |
my $navmap = Apache::lonnavmaps::navmap->new(); |
$allmaps{$res->src()} = 1; |
if (defined($navmap)) { |
|
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) { |
|
$allmaps{$res->src()} = 1; |
|
} |
|
} |
} |
} |
} |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
|
\%addedmaps,\%hierarchy,\%titles,\%allmaps); |
|
if ($url=~ m{^/uploaded/}) { |
if ($url=~ m{^/uploaded/}) { |
my $newurl; |
$title=&mt('Copy of').' '.$title; |
unless ($env{'form.docs.markedcopy_options'} eq 'move') { |
} |
($newurl,my $error) = |
my $newid=$$.int(rand(100)).time; |
&get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum, |
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/); |
$srcdom,$srcnum,\$title,\%allmaps,\%newurls); |
if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) { |
if ($error) { |
my $path = $1; |
return ($error); |
my $prefix = $2; |
} |
my $ancestor = $3; |
if ($newurl ne '') { |
if (length($ancestor) > 10) { |
if ($newurl ne $url) { |
$ancestor = substr($ancestor,-10,10); |
if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) { |
} |
$newsubdir{$url} = $1; |
$oldid = $path.$prefix.$ancestor; |
|
my $counter = 0; |
|
my $newurl=$oldid.$newid.'.'.$ext; |
|
my $is_unique = &uniqueness_check($newurl); |
|
if ($allmaps{$newurl}) { |
|
$is_unique = 0; |
|
} |
|
while (!$is_unique && $allmaps{$newurl} && $counter < 100) { |
|
$counter ++; |
|
$newid ++; |
|
$newurl = $oldid.$newid; |
|
$is_unique = &uniqueness_check($newurl); |
|
} |
|
if ($is_unique) { |
|
if ($path =~ m{^/uploaded/($match_domain)/($match_courseid)/$}) { |
|
$srcdom = $1; |
|
$srcnum = $2; |
|
if (($1 ne $coursedom) && ($2 ne $coursenum)) { |
|
my $srcdom = $1; |
|
my $srcnum = $2; |
|
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
|
&url_paste_fixups($oldid,$ext,$coursedom,$coursenum, |
|
\%allmaps, \%rewrites,\%copies,\%dbcopies,\%zombies,\%params); |
|
} else { |
|
return &mt('Paste failed: Item is from a different course which you do not have rights to edit'); |
} |
} |
$mapchanges{$url} = 1; |
|
} |
} |
} |
} |
|
} else { |
|
if ($url=~/\.page$/) { |
|
return &mt('Paste failed: an error occurred creating a unique URL for the composite page'); |
|
} else { |
|
return &mt('Paste failed: an error occurred creating a unique URL for the folder'); |
|
} |
} |
} |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) || |
my $storefn=$newurl; |
(($newurl ne '') && ($newurl ne $url))) { |
$storefn=~s{^/\w+/$match_domain/$match_username/}{}; |
unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum, |
my $paste_map_result = |
\%allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, |
\%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove, |
&Apache::lonnet::getfile($url)); |
\%newsubdir,\%newurls)) { |
if ($paste_map_result eq '/adm/notfound.html') { |
$mapmoves{$url} = 1; |
if ($url=~/\.page$/) { |
|
return &mt('Paste failed: an error occurred saving the composite page'); |
|
} else { |
|
return &mt('Paste failed: an error occurred saving the folder'); |
} |
} |
$url = $newurl; |
|
} elsif ($env{'docs.markedcopy_nested'}) { |
|
&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,\%allmaps,\%rewrites, |
|
\%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves, |
|
\%mapchanges,\%tomove,\%newsubdir,\%newurls); |
|
} |
} |
|
$url = $newurl; |
} elsif ($url=~m {^/res/}) { |
} elsif ($url=~m {^/res/}) { |
# published maps can only exists once, so remove it from paste buffer when done |
# published maps can only exists once, so remove it from paste buffer when done |
&Apache::lonnet::delenv('docs.markedcopy'); |
&Apache::lonnet::delenv('docs.markedcopy'); |
# if pasting published map (main content are only) check map is not already in course |
if ($allmaps{$url}) { |
if ($folder =~ /^default/) { |
return &mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'); |
if ($allmaps{$url}) { |
} |
return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.')); |
} |
} |
} elsif ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) { |
|
if (($1 ne $coursedom) || ($2 ne $coursenum)) { |
|
$srcdom = $1; |
|
$srcnum = $2; |
|
unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
|
return &mt('Paste failed: Item is from a different course which you do not have rights to edit'); |
} |
} |
} |
} |
} |
} |
if ($url=~ m{/smppg$}) { |
if ($url=~ m{/smppg$}) { |
my $db_name = &Apache::lonsimplepage::get_db_name($url); |
my $db_name = &Apache::lonsimplepage::get_db_name($url); |
if ($db_name =~ /^smppage_/) { |
if ($db_name =~ /^smppage_/) { |
#simple pages, need to copy the db contents to a new one. |
#simple pages, need to copy the db contents to a new one. |
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum); |
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum); |
my $now = time(); |
my $now = time(); |
$db_name =~ s{_\d*$ }{_$now}x; |
$db_name =~ s{_\d*$ }{_$now}x; |
my $dbresult=&Apache::lonnet::put($db_name,\%contents, |
my $result=&Apache::lonnet::put($db_name,\%contents, |
$coursedom,$coursenum); |
$coursedom,$coursenum); |
if ($dbresult eq 'ok') { |
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x; |
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x; |
$title=&mt('Copy of').' '.$title; |
$title=&mt('Copy of').' '.$title; |
} |
} else { |
} |
return (&mt('Paste failed: An error occurred when copying the simple page.')); |
my ($relpath,$oldprefix,$prefixchg); |
} |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(.+)$}) { |
|
$oldprefix = $1; |
|
$relpath = $2; |
|
if (($folder =~ /^supplemental/) && ($oldprefix eq 'docs')) { |
|
$prefixchg = 1; |
|
} elsif (($folder =~ /^default/) && ($oldprefix eq 'supplemental')) { |
|
$prefixchg = 1; |
} |
} |
} |
} |
$title = &LONCAPA::map::qtunescape($title); |
$title = &LONCAPA::map::qtunescape($title); |
my $ext='false'; |
my $ext='false'; |
if ($url=~m{^http(|s)://}) { $ext='true'; } |
if ($url=~m{^http(|s)://}) { $ext='true'; } |
$url = &LONCAPA::map::qtunescape($url); |
$url = &LONCAPA::map::qtunescape($url); |
|
|
# For uploaded files (excluding pages/sequences) path in copied file is changed |
|
# if paste is from Main to Supplemental (or vice versa), or if pasting between |
|
# courses. |
|
|
|
my $newidx; |
|
unless ($is_map) { |
|
# Now insert the URL at the bottom |
# Now insert the URL at the bottom |
$newidx = &LONCAPA::map::getresidx($url); |
my $newidx = &LONCAPA::map::getresidx($url); |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) { |
if ($relpath ne '') { |
my $relpath = $1; |
my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$}); |
if ($relpath ne '') { |
my ($newloc,$newsubdir) = ($folder =~ /^(default|supplemental)_?(\d*)/); |
my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$}); |
my $newprefix = $newloc; |
my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/); |
if ($newloc eq 'default') { |
my $newprefix = $newloc; |
$newprefix = 'docs'; |
if ($newloc eq 'default') { |
} |
$newprefix = 'docs'; |
if ($newsubdir eq '') { |
} |
$newsubdir = 'default'; |
if ($newdocsdir eq '') { |
} |
$newdocsdir = 'default'; |
if (($prefixchg) || ($srcdom ne '') && ($srcnum ne '')) { |
} |
my $newpath = "$newprefix/$newsubdir/$newidx/$rem"; |
if (($prefixchg) || ($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
$url = |
my $newpath = "$newprefix/$newdocsdir/$newidx/$rem"; |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath, |
$url = |
&Apache::lonnet::getfile($oldurl)); |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath, |
if ($url eq '/adm/notfound.html') { |
&Apache::lonnet::getfile($oldurl)); |
return &mt('Paste failed: an error occurred saving the file.'); |
if ($url eq '/adm/notfound.html') { |
} else { |
return (&mt('Paste failed: an error occurred saving the file.')); |
my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$}); |
} else { |
$newsubpath =~ s{/+$}{/}; |
my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$}); |
$moves{$oldurl} = $newsubpath; |
$newsubpath =~ s{/+$}{/}; |
|
$docmoves{$oldurl} = $newsubpath; |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages |
my $noparams = 0; |
my ($result,$save_err); |
if ((ref($params{$oldurl}) eq 'HASH') && ($relpath ne '') && ($folder =~ /^supplemental/)) { |
$result = |
$noparams = 1; |
&apply_fixups($folder,$is_map,$prefixchg,$coursedom,$coursenum,$oldurl, |
|
$url,\%removefrommap,\%removeparam,\%rewrites,\%retitles, |
|
\%copies,\%dbcopies,\%zombies,\%params,\%docmoves, |
|
\%mapmoves,\%newsubdir,$errors,\%before,\%after); |
|
if ($result eq 'ok') { |
|
if ($is_map) { |
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
|
$folder.'.'.$container); |
|
return $errtext if ($fatal); |
|
|
|
if ($#LONCAPA::map::order<1) { |
|
my $idx=&LONCAPA::map::getresidx(); |
|
if ($idx<=0) { $idx=1; } |
|
$LONCAPA::map::order[0]=$idx; |
|
$LONCAPA::map::resources[$idx]=''; |
|
} |
|
$newidx = &LONCAPA::map::getresidx($url); |
|
} |
|
if ($env{'docs.markedcopy_supplemental'}) { |
|
if ($folder !~ /^supplemental/) { |
|
(undef,undef,$title) = |
|
&Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental'}); |
|
} |
|
} else { |
|
if ($folder=~/^supplemental/) { |
|
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
|
$env{'user.domain'}.'___&&&___'.$title; |
|
} |
|
} |
|
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; |
|
push(@LONCAPA::map::order, $newidx); |
|
|
|
# Store the result |
|
my ($errtext,$fatal) = |
|
&storemap($coursenum,$coursedom,$folder.'.'.$container,1); |
|
if ($fatal) { |
|
$save_err = $errtext; |
|
} |
|
} |
} |
|
&apply_fixups($coursedom,$coursenum,$oldurl,$url,$noparams,\%rewrites,\%copies, |
if ($env{'form.docs.markedcopy_options'} eq 'move') { |
\%dbcopies,\%zombies,\%params,\%moves); |
&Apache::lonnet::delenv('docs.markedcopy'); |
if ($env{'docs.markedcopy_supplemental'}) { |
&Apache::lonnet::delenv('docs.markedcopy_nested'); |
if ($folder =~ /^supplemental/) { |
&Apache::lonnet::delenv('docs.markedcopy_nestednames'); |
$title = $env{'docs.markedcopy_supplemental'}; |
} |
|
return ($result,$save_err); |
|
} |
|
|
|
sub get_newmap_url { |
|
my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum, |
|
$titleref,$allmaps,$newurls) = @_; |
|
my $newurl; |
|
if ($url=~ m{^/uploaded/}) { |
|
$$titleref=&mt('Copy of').' '.$$titleref; |
|
} |
|
my $now = time; |
|
my $suffix=$$.int(rand(100)).$now; |
|
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/); |
|
if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) { |
|
my $path = $1; |
|
my $prefix = $2; |
|
my $ancestor = $3; |
|
if (length($ancestor) > 10) { |
|
$ancestor = substr($ancestor,-10,10); |
|
} |
|
my $newid; |
|
if ($prefixchg) { |
|
if ($folder =~ /^supplemental/) { |
|
$prefix =~ s/^default/supplemental/; |
|
} else { |
|
$prefix =~ s/^supplemental/default/; |
|
} |
|
} |
|
if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) { |
|
$newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext; |
|
} else { |
} else { |
$newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext; |
(undef,undef,$title) = |
|
&Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental'}); |
} |
} |
my $counter = 0; |
} else { |
my $is_unique = &uniqueness_check($newurl); |
if ($folder=~/^supplemental/) { |
if ($folder =~ /^default/) { |
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
if ($allmaps->{$newurl}) { |
$env{'user.domain'}.'___&&&___'.$title; |
$is_unique = 0; |
|
} |
|
} |
|
while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) { |
|
$counter ++; |
|
$suffix ++; |
|
if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) { |
|
$newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext; |
|
} else { |
|
$newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext; |
|
} |
|
$is_unique = &uniqueness_check($newurl); |
|
} |
|
if ($is_unique) { |
|
$newurls->{$newurl} = 1; |
|
} else { |
|
if ($url=~/\.page$/) { |
|
return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page')); |
|
} else { |
|
return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder')); |
|
} |
|
} |
} |
} |
} |
return ($newurl); |
|
|
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; |
|
push(@LONCAPA::map::order, $newidx); |
|
return 'ok'; |
|
# Store the result |
} |
} |
|
|
sub dbcopy { |
sub dbcopy { |
Line 1219 sub uniqueness_check {
|
Line 935 sub uniqueness_check {
|
} |
} |
|
|
sub contained_map_check { |
sub contained_map_check { |
my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles, |
my ($url,$folder,$removefrommap,$addedmaps) = @_; |
$allmaps) = @_; |
|
my $content = &Apache::lonnet::getfile($url); |
my $content = &Apache::lonnet::getfile($url); |
unless ($content eq '-1') { |
unless ($content eq '-1') { |
my $parser = HTML::TokeParser->new(\$content); |
my $parser = HTML::TokeParser->new(\$content); |
Line 1232 sub contained_map_check {
|
Line 947 sub contained_map_check {
|
my $ressrc = $token->[2]->{'src'}; |
my $ressrc = $token->[2]->{'src'}; |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
unless (&supp_pasteable($ressrc)) { |
unless (&supp_pasteable($ressrc)) { |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
$removefrommap->{$url}{$token->[2]->{'id'}}; |
next; |
next; |
} |
} |
} |
} |
if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) { |
if ($ressrc =~ /\.(sequence|page)$/) { |
if ($1 eq 'uploaded') { |
if (ref($addedmaps->{$ressrc}) eq 'ARRAY') { |
$hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc; |
push(@{$addedmaps->{$ressrc}},$url); |
$titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'}; |
|
} else { |
} else { |
if ($allmaps->{$ressrc}) { |
$addedmaps->{$ressrc} = [$url]; |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
|
} elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') { |
|
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
|
} else { |
|
$addedmaps->{$ressrc} = [$url]; |
|
} |
|
} |
} |
&contained_map_check($ressrc,$folder,$removefrommap,$removeparam, |
&contained_map_check($ressrc,$folder,$removefrommap,$addedmaps); |
$addedmaps,$hierarchy,$titles,$allmaps); |
|
} |
} |
} elsif ($token->[1] eq 'param') { |
} elsif ($token->[1] !~ /^resource|map|link$/) { |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') { |
$removefrommap->{$url}{$token->[1]}; |
push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'}); |
|
} else { |
|
$removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}]; |
|
} |
|
} |
} |
} |
} |
} |
} |
Line 1276 sub reinit_role {
|
Line 979 sub reinit_role {
|
} |
} |
|
|
sub url_paste_fixups { |
sub url_paste_fixups { |
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$allmaps,$rewrites,$retitles,$copies, |
my ($oldurl,$ext,$cdom,$cnum,$allmaps,$rewrites,$copies,$dbcopies,$zombies,$params) = @_; |
$dbcopies,$zombies,$params,$mapmoves,$mapchanges,$tomove,$newsubdir,$newurls) = @_; |
my $file = &Apache::lonnet::getfile("$oldurl.$ext"); |
my $checktitle; |
|
if (($prefixchg) && |
|
($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) { |
|
$checktitle = 1; |
|
} |
|
my $skip; |
|
if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) { |
|
my $mapid = $1.$2; |
|
if ($tomove->{$mapid}) { |
|
$skip = 1; |
|
} |
|
} |
|
my $file = &Apache::lonnet::getfile($oldurl); |
|
return if ($file eq '-1'); |
return if ($file eq '-1'); |
my $parser = HTML::TokeParser->new(\$file); |
my $parser = HTML::TokeParser->new(\$file); |
$parser->attr_encoded(1); |
$parser->attr_encoded(1); |
my $changed = 0; |
|
while (my $token = $parser->get_token) { |
while (my $token = $parser->get_token) { |
next if ($token->[0] ne 'S'); |
next if ($token->[0] ne 'S'); |
if ($token->[1] eq 'resource') { |
if ($token->[1] eq 'resource') { |
my $ressrc = $token->[2]->{'src'}; |
my $ressrc = $token->[2]->{'src'}; |
next if ($ressrc eq ''); |
next if ($ressrc eq ''); |
my $id = $token->[2]->{'id'}; |
|
my $title = $token->[2]->{'title'}; |
|
if ($checktitle) { |
|
if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) { |
|
$retitles->{$oldurl}{$ressrc} = $id; |
|
} |
|
} |
|
next if ($token->[2]->{'type'} eq 'external'); |
next if ($token->[2]->{'type'} eq 'external'); |
|
my $id = $token->[2]->{'id'}; |
if ($token->[2]->{'type'} eq 'zombie') { |
if ($token->[2]->{'type'} eq 'zombie') { |
next if ($skip); |
|
$zombies->{$oldurl}{$ressrc} = $id; |
$zombies->{$oldurl}{$ressrc} = $id; |
$changed = 1; |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)}) { |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
my $srccdom = $1; |
my $srcdom = $1; |
my $srccnum = $2; |
my $srcnum = $2; |
|
my $rem = $3; |
my $rem = $3; |
my $newurl; |
if (($srccdom ne $cdom) || ($srccnum ne $cnum)) { |
my $mapname; |
|
if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) { |
|
my $prefix = $1; |
|
$mapname = $prefix.$2; |
|
if ($tomove->{$mapname}) { |
|
&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,$allmaps, |
|
$rewrites,$retitles,$copies,$dbcopies,$zombies, |
|
$params,$mapmoves,$mapchanges,$tomove,$newsubdir, |
|
$newurls); |
|
next; |
|
} else { |
|
($newurl,my $error) = |
|
&get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum, |
|
$srcdom,$srcnum,\$title,$allmaps,$newurls); |
|
if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) { |
|
$newsubdir->{$ressrc} = $1; |
|
} |
|
if ($error) { |
|
next; |
|
} |
|
} |
|
} |
|
if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) || |
|
($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) { |
|
|
|
if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) { |
if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) { |
$rewrites->{$oldurl}{$ressrc} = $id; |
$rewrites->{$oldurl}{$ressrc} = $id; |
$mapchanges->{$ressrc} = 1; |
&url_paste_fixups($ressrc,$3,$cdom,$cnum,$allmaps,$rewrites,$copies,$dbcopies,$zombies,$params); |
unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,$allmaps, |
|
$rewrites,$retitles,$copies,$dbcopies,$zombies, |
|
$params,$mapmoves,$mapchanges,$tomove,$newsubdir, |
|
$newurls)) { |
|
$mapmoves->{$ressrc} = 1; |
|
} |
|
$changed = 1; |
|
} else { |
} else { |
$rewrites->{$oldurl}{$ressrc} = $id; |
$rewrites->{$oldurl}{$ressrc} = $id; |
$copies->{$oldurl}{$ressrc} = $id; |
$copies->{$oldurl}{$ressrc} = $id; |
$changed = 1; |
|
} |
} |
} |
} |
} elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) { |
} elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) { |
next if ($skip); |
my $srccdom = $1; |
my $srcdom = $1; |
my $srccnum = $2; |
my $srcnum = $2; |
if (($srccdom ne $cdom) || ($srccnum ne $cnum)) { |
if (($srcdom ne $cdom) || ($srcnum ne $cnum)) { |
|
$rewrites->{$oldurl}{$ressrc} = $id; |
$rewrites->{$oldurl}{$ressrc} = $id; |
$dbcopies->{$oldurl}{$ressrc} = $id; |
$dbcopies->{$oldurl}{$ressrc} = $id; |
$changed = 1; |
|
} |
} |
} elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) { |
} elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) { |
next if ($skip); |
my $srccdom = $1; |
my $srcdom = $1; |
my $srccnum = $2; |
my $srcnum = $2; |
if (($srccdom ne $cdom) || ($srccnum ne $cnum)) { |
if (($srcdom ne $cdom) || ($srcnum ne $cnum)) { |
|
$rewrites->{$oldurl}{$ressrc} = $id; |
$rewrites->{$oldurl}{$ressrc} = $id; |
$dbcopies->{$oldurl}{$ressrc} = $id; |
$dbcopies->{$oldurl}{$ressrc} = $id; |
$changed = 1; |
|
} |
} |
} |
} |
} elsif ($token->[1] eq 'param') { |
} elsif ($token->[1] eq 'param') { |
next if ($skip); |
my $to = $token->[2]->{'to'}; |
my $to = $token->[2]->{'to'}; |
|
if ($to ne '') { |
if ($to ne '') { |
if (ref($params->{$oldurl}{$to}) eq 'ARRAY') { |
if (ref($params->{$oldurl}{$to}) eq 'ARRAY') { |
push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'}); |
push (@{$params->{$oldurl}{$to}},$token->[2]->{'name'}); |
} else { |
} else { |
@{$params->{$oldurl}{$to}} = ($token->[2]->{'name'}); |
@{$params->{$oldurl}{$to}} = ($token->[2]->{'name'}); |
} |
} |
} |
} |
} |
} |
} |
} |
return $changed; |
return; |
} |
} |
|
|
sub apply_fixups { |
sub apply_fixups { |
my ($folder,$is_map,$prefixchg,$cdom,$cnum,$oldurl,$url,$removefrommap, |
my ($cdom,$cnum,$oldurl,$url,$noparams,$rewrites,$copies,$dbcopies,$zombies,$params, |
$removeparam,$rewrites,$retitles,$copies,$dbcopies,$zombies,$params, |
$moves) = @_; |
$docmoves,$mapmoves,$newsubdir,$errors,$before,$after) = @_; |
my (%newdb,%newdoc); |
foreach my $key (keys(%{$copies}),keys(%{$docmoves})) { |
if (ref($dbcopies->{$oldurl}) eq 'HASH') { |
my @allcopies; |
foreach my $item (keys(%{$dbcopies->{$oldurl}})) { |
if (ref($copies->{$key}) eq 'HASH') { |
$newdb{$item} = &dbcopy($item); |
my %added; |
} |
foreach my $innerkey (keys(%{$copies->{$key}})) { |
} |
if (($innerkey ne '') && (!$added{$innerkey})) { |
my @allcopies; |
push(@allcopies,$innerkey); |
if (ref($copies->{$oldurl}) eq 'HASH') { |
$added{$innerkey} = 1; |
push(@allcopies,keys(%{$copies->{$oldurl}})); |
} |
} |
} |
if ((ref($moves) eq 'HASH') && (exists($moves->{$oldurl}))) { |
undef(%added); |
push(@allcopies,$oldurl); |
} |
} |
if ($key eq $oldurl) { |
if (@allcopies > 0) { |
if ((exists($docmoves->{$key}))) { |
foreach my $item (@allcopies) { |
unless (grep(/^\Q$oldurl\E/,@allcopies)) { |
my $content = &Apache::lonnet::getfile($item); |
push(@allcopies,$oldurl); |
unless ($content eq '-1') { |
} |
my $mm = new File::MMagic; |
} |
my $mimetype = $mm->checktype_contents($content); |
} |
if ($mimetype eq 'text/html') { |
if (@allcopies > 0) { |
my (%allfiles,%codebase,$state); |
foreach my $item (@allcopies) { |
if (&Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content) eq 'ok') { |
my ($relpath,$oldsubdir,$fname) = |
my ($numexisting,$numpathchanges,$existing); |
($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$}); |
(undef,$numexisting,$numpathchanges,$existing) = |
if ($fname ne '') { |
&Apache::loncommon::ask_for_embedded_content( |
my $content = &Apache::lonnet::getfile($item); |
'/adm/coursedocs',$state,\%allfiles,\%codebase, |
unless ($content eq '-1') { |
{'error_on_invalid_names' => 1, |
my $storefn; |
'ignore_remote_references' => 1, |
if (($key eq $oldurl) && (ref($docmoves) eq 'HASH') && (exists($docmoves->{$key}))) { |
'docs_url' => $oldurl, |
$storefn = $docmoves->{$key}; |
'context' => 'paste'}); |
} else { |
if ($numexisting > 0) { |
$storefn = $relpath; |
if (ref($existing) eq 'HASH') { |
$storefn =~s{^/uploaded/$match_domain/$match_courseid/}{}; |
my ($relpath) = ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(?:default|\d+)/.*/)[^/]+$}); |
if ($prefixchg) { |
foreach my $dep (keys(%{$existing})) { |
$storefn =~ s/^\Q$before->{'doc'}\E/$after->{'doc'}/; |
$dep =~ s{^\Q$relpath\E}{}; |
} |
my $depfile = $relpath.$dep; |
if ($newsubdir->{$key}) { |
my $depstorefn; |
$storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir->{$key}#; |
if ((ref($copies->{$oldurl}) eq 'HASH') && |
} |
($copies->{$oldurl}{$item})) { |
} |
$depstorefn = $relpath; |
©_dependencies($item,$storefn,$relpath,$errors,\$content); |
$depstorefn =~s{^/\w+/$match_domain/$match_courseid/}{}; |
my $copyurl = |
} elsif ((ref($moves) eq 'HASH') && |
&Apache::lonclonecourse::writefile($env{'request.course.id'}, |
(exists($moves->{$oldurl}))) { |
$storefn.$fname,$content); |
$depstorefn = $moves->{$oldurl}; |
if ($copyurl eq '/adm/notfound.html') { |
} |
if ((ref($docmoves) eq 'HASH') && (exists($docmoves->{$oldurl}))) { |
$depstorefn .= $dep; |
return &mt('Paste failed: an error occurred copying the file.'); |
my $depcontent = &Apache::lonnet::getfile($depfile); |
} elsif (ref($errors) eq 'HASH') { |
unless ($depcontent eq '-1') { |
$errors->{$item} = 1; |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$depstorefn,$depcontent); |
} |
} |
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
foreach my $key (keys(%{$mapmoves})) { |
|
my $storefn=$key; |
|
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{}; |
|
if ($prefixchg) { |
|
$storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/; |
|
} |
|
if ($newsubdir->{$key}) { |
|
$storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/; |
|
} |
|
my $mapcontent = &Apache::lonnet::getfile($key); |
|
if ($mapcontent eq '-1') { |
|
if (ref($errors) eq 'HASH') { |
|
$errors->{$key} = 1; |
|
} |
|
} else { |
|
my $newmap = |
|
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, |
|
$mapcontent); |
|
if ($newmap eq '/adm/notfound.html') { |
|
if (ref($errors) eq 'HASH') { |
|
$errors->{$key} = 1; |
|
} |
|
} |
|
} |
|
} |
|
my %updates; |
|
if ($is_map) { |
|
foreach my $key (keys(%{$rewrites})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%{$zombies})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%{$removefrommap})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%{$removeparam})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%{$dbcopies})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%{$retitles})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%updates)) { |
|
my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb); |
|
if (ref($rewrites->{$key}) eq 'HASH') { |
|
%torewrite = %{$rewrites->{$key}}; |
|
} |
|
if (ref($retitles->{$key}) eq 'HASH') { |
|
%toretitle = %{$retitles->{$key}}; |
|
} |
|
if (ref($removefrommap->{$key}) eq 'HASH') { |
|
%toremove = %{$removefrommap->{$key}}; |
|
} |
|
if (ref($removeparam->{$key}) eq 'HASH') { |
|
%remparam = %{$removeparam->{$key}}; |
|
} |
|
if (ref($zombies->{$key}) eq 'HASH') { |
|
%zombie = %{$zombies->{$key}}; |
|
} |
|
if (ref($dbcopies->{$key}) eq 'HASH') { |
|
foreach my $item (keys(%{$dbcopies->{$key}})) { |
|
$newdb{$item} = &dbcopy($item); |
|
} |
|
} |
|
if (ref($params->{$key}) eq 'HASH') { |
|
%currparam = %{$params->{$key}}; |
|
} |
|
my ($errtext,$fatal) = &LONCAPA::map::mapread($key); |
|
if ($fatal) { |
|
return $errtext; |
|
} |
|
for (my $i=0; $i<@LONCAPA::map::zombies; $i++) { |
|
if (defined($LONCAPA::map::zombies[$i])) { |
|
my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]); |
|
if ($zombie{$src} eq $i) { |
|
undef($LONCAPA::map::zombies[$i]); |
|
} |
|
} |
|
} |
|
for (my $i=0; $i<@LONCAPA::map::resources; $i++) { |
|
if (defined($LONCAPA::map::resources[$i])) { |
|
my $changed; |
|
my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$i]); |
|
if ($toremove{$src} eq $i) { |
|
splice(@LONCAPA::map::order,$i,1); |
|
if (ref($currparam{$i}) eq 'ARRAY') { |
|
foreach my $name (@{$currparam{$i}}) { |
|
&LONCAPA::map::delparameter($i,'parameter_'.$name); |
|
} |
|
} |
|
next; |
|
} |
|
my $origsrc = $src; |
|
if ((exists($toretitle{$src})) && ($toretitle{$src} eq $i)) { |
|
if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) { |
|
$changed = 1; |
|
} |
|
} |
|
if ((exists($torewrite{$src})) && ($torewrite{$src} eq $i)) { |
|
$src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/}; |
|
if ($origsrc =~ m{^/uploaded/}) { |
|
if ($prefixchg) { |
|
if ($src =~ /\.(page|sequence)$/) { |
|
$src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'map'}\E#$1$after->{'map'}#; |
|
} else { |
|
$src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'doc'}\E#$1$after->{'doc'}#; |
|
} |
|
} |
|
if ($newsubdir->{$origsrc}) { |
|
if ($src =~ /\.(page|sequence)$/) { |
|
$src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir->{$origsrc}#; |
|
} else { |
|
$src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir->{$origsrc}#; |
|
} |
} |
} |
} |
} |
} |
$changed = 1; |
|
} elsif ($newdb{$src} ne '') { |
|
$src = $newdb{$src}; |
|
$changed = 1; |
|
} |
|
if ($changed) { |
|
$LONCAPA::map::resources[$i] = join(':',($title,$src,$ext,$type)); |
|
} |
|
} |
|
} |
|
foreach my $idx (keys(%remparam)) { |
|
if (ref($remparam{$idx}) eq 'ARRAY') { |
|
foreach my $name (@{$remparam{$idx}}) { |
|
&LONCAPA::map::delparameter($idx,'parameter_'.$name); |
|
} |
} |
} |
} |
} |
my $storefn=$item; |
my $storefn; |
unless (exists($moves->{$oldurl})) { |
if ($key eq $oldurl) { |
$storefn=~s{^/\w+/$match_domain/$match_courseid/}{}; |
$storefn = $url; |
$newdoc{$item} = &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,$content); |
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{}; |
|
} else { |
|
$storefn = $key; |
|
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{}; |
|
if ($prefixchg) { |
|
$storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/; |
|
} |
|
if ($newsubdir->{$key}) { |
|
$storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/; |
|
} |
} |
} |
} |
my $report; |
|
if ($folder !~ /^supplemental/) { |
|
$report = 1; |
|
} |
|
my ($outtext,$errtext) = |
|
&LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report); |
|
if ($errtext) { |
|
return &mt('Paste failed: an error occurred saving the folder or page.'); |
|
} |
|
} |
} |
} |
} |
return 'ok'; |
if (((ref($rewrites->{$oldurl}) eq 'HASH') || (ref($zombies->{$oldurl}) eq 'HASH')) || |
} |
($noparams) || (keys(%newdb) > 0) || (keys(%newdoc) > 0)) { |
|
my $map = &Apache::lonnet::getfile($url); |
sub copy_dependencies { |
my $newcontent; |
my ($item,$storefn,$relpath,$errors,$contentref) = @_; |
unless ($map eq '-1') { |
my $content; |
my $parser = HTML::TokeParser->new(\$map); |
if (ref($contentref)) { |
$parser->attr_encoded(1); |
$content = $$contentref; |
while (my $token = $parser->get_token) { |
} else { |
if ($token->[0] eq 'S') { |
$content = &Apache::lonnet::getfile($item); |
next if ($token->[2]->{'type'} eq 'zombie'); |
} |
next if (($token->[1] eq 'param') && $noparams); |
unless ($content eq '-1') { |
if ($token->[1] eq 'resource') { |
my $mm = new File::MMagic; |
my $src = $token->[2]->{'src'}; |
my $mimetype = $mm->checktype_contents($content); |
my $id = $token->[2]->{'id'}; |
if ($mimetype eq 'text/html') { |
if (($rewrites->{$oldurl}{$src} eq $id) || ($newdb{$src} ne '') |
my (%allfiles,%codebase,$state); |
|| ($newdoc{$src} ne '')) { |
my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content); |
if (ref($rewrites->{$oldurl}) eq 'HASH') { |
if ($res eq 'ok') { |
if ($rewrites->{$oldurl}{$src} eq $id) { |
my ($numexisting,$numpathchanges,$existing); |
$token->[2]->{'src'} =~ s{^(/uploaded|adm|public)/$match_domain/$match_courseid/}{$1/$cdom/$cnum}; |
(undef,$numexisting,$numpathchanges,$existing) = |
|
&Apache::loncommon::ask_for_embedded_content( |
|
'/adm/coursedocs',$state,\%allfiles,\%codebase, |
|
{'error_on_invalid_names' => 1, |
|
'ignore_remote_references' => 1, |
|
'docs_url' => $item, |
|
'context' => 'paste'}); |
|
if ($numexisting > 0) { |
|
if (ref($existing) eq 'HASH') { |
|
foreach my $dep (keys(%{$existing})) { |
|
my $depfile = $dep; |
|
unless ($depfile =~ m{^\Q$relpath\E}) { |
|
$depfile = $relpath.$dep; |
|
} |
|
my $depcontent = &Apache::lonnet::getfile($depfile); |
|
unless ($depcontent eq '-1') { |
|
my $storedep = $dep; |
|
$storedep =~ s{^\Q$relpath\E}{}; |
|
my $dep_url = |
|
&Apache::lonclonecourse::writefile( |
|
$env{'request.course.id'}, |
|
$storefn.$storedep,$depcontent); |
|
if ($dep_url eq '/adm/notfound.html') { |
|
if (ref($errors) eq 'HASH') { |
|
$errors->{$depfile} = 1; |
|
} |
|
} else { |
|
©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent); |
|
} |
} |
|
} elsif ($newdb{$src} ne '') { |
|
$token->[2]->{'src'} = $newdb{$src}; |
} |
} |
|
$newcontent .= "<$token->[1] "; |
|
foreach my $attr (@{$token->[3]}) { |
|
$newcontent .= ' '.$attr.'="'.$token->[2]->{$attr},'"' |
|
} |
|
$newcontent .= ' />'; |
|
} else { |
|
$newcontent .= $token->[4]."\n"; |
} |
} |
} |
} |
|
} elsif ($token->[0] eq 'E') { |
|
$newcontent .= $token->[2]."\n"; |
} |
} |
} |
} |
} |
} |
|
my $storefn=$url; |
|
$storefn=~s{^/\w+/$match_domain/$match_courseid/}{}; |
|
my $storeres = |
|
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, |
|
$newcontent); |
} |
} |
return; |
return; |
} |
} |
Line 1743 sub handle_edit_cmd {
|
Line 1220 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,$uploadtag)=@_; |
$supplementalflag,$orderhash,$iconpath)=@_; |
my $container= ($env{'form.pagepath'}) ? 'page' |
my $container= ($env{'form.pagepath'}) ? 'page' |
: 'sequence'; |
: 'sequence'; |
|
|
Line 1790 sub editor {
|
Line 1267 sub editor {
|
} |
} |
|
|
if ($env{'form.pastemarked'}) { |
if ($env{'form.pastemarked'}) { |
my %paste_errors; |
my $paste_res = |
my ($paste_res,$save_error) = |
&do_paste_from_buffer($coursenum,$coursedom,$folder); |
&do_paste_from_buffer($coursenum,$coursedom,$folder,$container, |
if ($paste_res eq 'ok') { |
\%paste_errors); |
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); |
if ($save_error ne '') { |
return $errtext if ($fatal); |
return $save_error; |
} elsif ($paste_res ne '') { |
} |
|
if ($paste_res ne 'ok') { |
|
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>'); |
} |
} |
if (keys(%paste_errors) > 0) { |
|
$r->print('<p span class="LC_warning">'."\n". |
|
&mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n". |
|
'<ul>'."\n"); |
|
foreach my $key (sort(keys(%paste_errors))) { |
|
$r->print('<li>'.$key.'</li>'."\n"); |
|
} |
|
$r->print('</ul></p>'."\n"); |
|
} |
|
} |
} |
|
|
$r->print($upload_output); |
$r->print($upload_output); |
|
|
if (&handle_edit_cmd()) { |
if (&handle_edit_cmd()) { |
my $contentchg; |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
if ($env{'form.cmd'} =~ /^(del|cut)_/) { |
|
$contentchg = 1; |
|
} |
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); |
|
return $errtext if ($fatal); |
return $errtext if ($fatal); |
} |
} |
# Group import/search |
# Group import/search |
Line 1828 sub editor {
|
Line 1290 sub editor {
|
if (defined($item)) { |
if (defined($item)) { |
my ($name,$url,$residx)= |
my ($name,$url,$residx)= |
map {&unescape($_)} split(/\=/,$item); |
map {&unescape($_)} split(/\=/,$item); |
if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) { |
|
my ($suffix,$errortxt,$locknotfreed) = |
|
&newmap_suffix($1,$2,$coursedom,$coursenum); |
|
if ($locknotfreed) { |
|
$r->print($locknotfreed); |
|
} |
|
if ($suffix) { |
|
$url =~ s/_new\./_$suffix./; |
|
} else { |
|
return $errortxt; |
|
} |
|
} |
|
push(@imports, [$name, $url, $residx]); |
push(@imports, [$name, $url, $residx]); |
} |
} |
} |
} |
Line 1857 sub editor {
|
Line 1307 sub editor {
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; |
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; |
} |
} |
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
$folder.'.'.$container,1); |
$folder.'.'.$container); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
} else { |
} else { |
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>'); |
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>'); |
Line 1911 sub editor {
|
Line 1361 sub editor {
|
unless ($name) { $name=(split(/\//,$url))[-1]; } |
unless ($name) { $name=(split(/\//,$url))[-1]; } |
unless ($name) { $idx++; next; } |
unless ($name) { $idx++; next; } |
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$coursenum,$coursedom,$crstype, |
$coursenum,$crstype); |
$uploadtag,$supplementalflag); |
|
$idx++; |
$idx++; |
$shown++; |
$shown++; |
} |
} |
Line 1950 sub editor {
|
Line 1399 sub editor {
|
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container"; |
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container"; |
$r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto, |
$r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto, |
$readfile)); |
$readfile)); |
&print_paste_buffer($r,$container,$folder,$coursedom,$coursenum); |
&print_paste_buffer($r,$container,$folder); |
} else { |
} else { |
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { |
#Function Box for Supplemental Content for users with mdc priv. |
#Function Box for Supplemental Content for users with mdc priv. |
Line 2038 sub process_file_upload {
|
Line 1487 sub process_file_upload {
|
$comment.':'.$url.':'.$ext.':normal:res'; |
$comment.':'.$url.':'.$ext.':normal:res'; |
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx; |
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx; |
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
$folder.'.'.$container,1); |
$folder.'.'.$container); |
if ($fatal) { |
if ($fatal) { |
$$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>'; |
$$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>'; |
return; |
return; |
Line 2129 sub is_supplemental_title {
|
Line 1578 sub is_supplemental_title {
|
# --------------------------------------------------------------- An entry line |
# --------------------------------------------------------------- An entry line |
|
|
sub entryline { |
sub entryline { |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_; |
$crstype,$uploadtag,$supplementalflag)=@_; |
|
my ($foldertitle,$pagetitle,$renametitle); |
my ($foldertitle,$pagetitle,$renametitle); |
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); |
Line 2144 sub entryline {
|
Line 1592 sub entryline {
|
|
|
my $orderidx=$LONCAPA::map::order[$index]; |
my $orderidx=$LONCAPA::map::order[$index]; |
|
|
|
|
$renametitle=~s/\\/\\\\/g; |
$renametitle=~s/\\/\\\\/g; |
$renametitle=~s/\"\;/\\\"/g; |
$renametitle=~s/\"\;/\\\"/g; |
$renametitle=~s/ /%20/g; |
$renametitle=~s/ /%20/g; |
Line 2162 sub entryline {
|
Line 1611 sub entryline {
|
$type = $container = 'page'; |
$type = $container = 'page'; |
$esc_path=&escape($env{'form.pagepath'}); |
$esc_path=&escape($env{'form.pagepath'}); |
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); |
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); |
|
$symb=&escape($env{'form.pagesymb'}); |
} |
} |
if (!$supplementalflag && $residx) { |
my $cpinfo=''; |
my $currurl = $url; |
|
$currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; |
|
my $path = 'uploaded/'. |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'; |
|
$symb = &Apache::lonnet::encode_symb($path.$folder.".$container", |
|
$residx, |
|
&Apache::lonnet::declutter($currurl)); |
|
} |
|
my %lt; |
|
if ($allowed) { |
if ($allowed) { |
my $incindex=$index+1; |
my $incindex=$index+1; |
my $selectbox=''; |
my $selectbox=''; |
Line 2196 sub entryline {
|
Line 1636 sub entryline {
|
} |
} |
$selectbox.='</select>'; |
$selectbox.='</select>'; |
} |
} |
%lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'up' => 'Move Up', |
'up' => 'Move Up', |
'dw' => 'Move Down', |
'dw' => 'Move Down', |
'rm' => 'Remove', |
'rm' => 'Remove', |
'ct' => 'Cut', |
'ct' => 'Cut', |
'rn' => 'Rename', |
'rn' => 'Rename', |
'cp' => 'Copy', |
'cp' => 'Copy'); |
'ex' => 'External Resource', |
|
'ed' => 'Edit', |
|
'pr' => 'Preview', |
|
'sv' => 'Save', |
|
'ul' => 'URL', |
|
'ti' => 'Title', |
|
); |
|
my $nocopy=0; |
my $nocopy=0; |
my $nocut=0; |
my $nocut=0; |
my $noremove=0; |
if ($url=~/\.(page|sequence)$/) { |
if ($url=~ m{^/res/.+\.(page|sequence)$}) { |
if ($url =~ m{/res/}) { |
# no copy for published maps |
# no copy for published maps |
$nocopy=1; |
$nocopy = 1; |
} |
} else { |
|
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) { |
|
my ($title,$url,$ext,$type)=split(/\:/,$item); |
|
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { |
|
$nocopy=1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
if ($url=~/^\/res\/lib\/templates\//) { |
if ($url=~/^\/res\/lib\/templates\//) { |
$nocopy=1; |
$nocopy=1; |
$nocut=1; |
$nocut=1; |
} |
} |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") { |
|
if ($env{'form.folderpath'} =~ /^default&[^\&]+$/) { |
|
my %curr_groups = &Apache::longroup::coursegroups(); |
|
if (keys(%curr_groups) > 0) { |
|
$noremove=1; |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} |
|
} elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) { |
|
my $group = $1; |
|
if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) { |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
if (keys(%curr_group) > 0) { |
|
$noremove=1; |
|
} |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) { |
|
my $group = $1; |
|
if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) { |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group}); |
|
if (keys(%groupsettings) > 0) { |
|
$noremove=1; |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} |
|
} elsif ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) { |
|
my $group = $1; |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
if ($url =~ /group_boards_\Q$group\E/) { |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group}); |
|
if (keys(%groupsettings) > 0) { |
|
if (ref($groupsettings{'functions'}) eq 'HASH') { |
|
if ($groupsettings{'functions'}{'discussion'} eq 'on') { |
|
$noremove=1; |
|
} |
|
} |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} |
|
} |
|
my $copylink=' '; |
my $copylink=' '; |
my $cutlink=' '; |
my $cutlink=' '; |
my $removelink=' '; |
|
|
|
my $skip_confirm = 0; |
my $skip_confirm = 0; |
if ( $folder =~ /^supplemental/ |
if ( $folder =~ /^supplemental/ |
Line 2296 ENDCOPY
|
Line 1688 ENDCOPY
|
<a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$symb','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a> |
<a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$symb','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a> |
ENDCUT |
ENDCUT |
} |
} |
if (!$noremove) { |
|
$removelink=(<<ENDREM); |
|
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a> |
|
ENDREM |
|
} |
|
$form_start = ' |
$form_start = ' |
<form action="/adm/coursedocs" method="post"> |
<form action="/adm/coursedocs" method="post"> |
'; |
'; |
Line 2314 END
|
Line 1701 END
|
$line.=(<<END); |
$line.=(<<END); |
<td> |
<td> |
<div class="LC_docs_entry_move"> |
<div class="LC_docs_entry_move"> |
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb'> |
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
<img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" /> |
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /> |
</a> |
</a> |
</div> |
</div> |
<div class="LC_docs_entry_move"> |
<div class="LC_docs_entry_move"> |
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb'> |
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
<img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" /> |
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /> |
</a> |
</a> |
</div> |
</div> |
</td> |
</td> |
Line 2331 END
|
Line 1718 END
|
$form_end |
$form_end |
</td> |
</td> |
<td class="LC_docs_entry_commands"> |
<td class="LC_docs_entry_commands"> |
$removelink |
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a> |
$cutlink |
$cutlink |
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a> |
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a> |
$copylink |
$copylink |
Line 2371 END
|
Line 1758 END
|
} |
} |
} |
} |
|
|
my $editlink; |
|
my $orig_url = $url; |
my $orig_url = $url; |
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}); |
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}); |
if (!$supplementalflag && $residx && $symb) { |
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { |
if ($container eq 'page') { |
my $symb=&Apache::lonnet::symbclean( |
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); |
&Apache::lonnet::declutter('uploaded/'. |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
} |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. |
if ((!$isfolder) && (!$ispage)) { |
'.sequence'). |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
'___'.$residx.'___'. |
$url=&Apache::lonnet::clutter($url); |
&Apache::lonnet::declutter($url)); |
if ($url=~/^\/*uploaded\//) { |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
$url=~/\.(\w+)$/; |
$url=&Apache::lonnet::clutter($url); |
my $embstyle=&Apache::loncommon::fileembstyle($1); |
if ($url=~/^\/*uploaded\//) { |
if (($embstyle eq 'img') || ($embstyle eq 'emb')) { |
$url=~/\.(\w+)$/; |
$url='/adm/wrapper'.$url; |
my $embstyle=&Apache::loncommon::fileembstyle($1); |
} elsif ($embstyle eq 'ssi') { |
if (($embstyle eq 'img') || ($embstyle eq 'emb')) { |
#do nothing with these |
$url='/adm/wrapper'.$url; |
} elsif ($url!~/\.(sequence|page)$/) { |
} elsif ($embstyle eq 'ssi') { |
$url='/adm/coursedocs/showdoc'.$url; |
#do nothing with these |
} |
} elsif ($url!~/\.(sequence|page)$/) { |
} elsif ($url=~m|^/ext/|) { |
$url='/adm/coursedocs/showdoc'.$url; |
$url='/adm/wrapper'.$url; |
} |
$external = 1; |
} elsif ($url=~m|^/ext/|) { |
} |
$url='/adm/wrapper'.$url; |
if (&Apache::lonnet::symbverify($symb,$url)) { |
$external = 1; |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
} |
} else { |
if (&Apache::lonnet::symbverify($symb,$url)) { |
$url=''; |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
} |
} else { |
|
$url=''; |
} |
} |
|
if ($container eq 'page') { |
|
my $symb=$env{'form.pagesymb'}; |
|
|
|
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); |
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
|
} |
} |
} |
my ($rand_pick_text,$rand_order_text); |
my ($rand_pick_text,$rand_order_text); |
if ($isfolder || $extension eq 'sequence') { |
if ($isfolder || $extension eq 'sequence') { |
Line 2419 END
|
Line 1812 END
|
'parameter_encrypturl'))[0]=~/^yes$/i) |
'parameter_encrypturl'))[0]=~/^yes$/i) |
.':'.((&LONCAPA::map::getparameter($orderidx, |
.':'.((&LONCAPA::map::getparameter($orderidx, |
'parameter_randomorder'))[0]=~/^yes$/i); |
'parameter_randomorder'))[0]=~/^yes$/i); |
$url.='folderpath='.&escape($folderpath); |
$url.='folderpath='.&escape($folderpath).$cpinfo; |
my $rpicknum = (&LONCAPA::map::getparameter($orderidx, |
my $rpicknum = (&LONCAPA::map::getparameter($orderidx, |
'parameter_randompick'))[0]; |
'parameter_randompick'))[0]; |
my $rpckchk; |
my $rpckchk; |
Line 2448 $form_common.'
|
Line 1841 $form_common.'
|
my $folderpath=$env{'form.folderpath'}; |
my $folderpath=$env{'form.folderpath'}; |
if ($folderpath) { $pagepath = $folderpath.'&' }; |
if ($folderpath) { $pagepath = $folderpath.'&' }; |
$pagepath.=$pagearg.'&'.$pagename; |
$pagepath.=$pagearg.'&'.$pagename; |
|
my $symb=$env{'form.pagesymb'}; |
|
if (!$symb) { |
|
my $path='uploaded/'. |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'; |
|
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', |
|
$residx, |
|
$path.$pagearg.'.page'); |
|
} |
$url.='pagepath='.&escape($pagepath). |
$url.='pagepath='.&escape($pagepath). |
'&pagesymb='.&escape($symb); |
'&pagesymb='.&escape($symb).$cpinfo; |
} |
} |
if ($allowed) { |
if (($external) && ($allowed)) { |
my $fileloc = |
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext'; |
&Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url)); |
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>'; |
|
} else { |
if ($external) { |
undef($external); |
$editlink = <<"EXTLNK"; |
|
|
|
<a class="LC_docs_ext_edit" href="javascript:editext('$residx');"> |
|
$lt{'ed'}</a> |
|
<form action="/adm/coursedocs" method="post" name="editext_$residx"> |
|
<fieldset id="uploadext$residx" style="display: none;" /> |
|
<input type="hidden" name="active" value="aa" /> |
|
<span class="LC_nobreak"> |
|
<span class="LC_docs_ext_edit">$lt{'ul'} </span> |
|
<input type="text" size="40" name="exturl" id="exturl_$residx" value="$orig_url" /> |
|
<a class="LC_docs_ext_edit" href="javascript:extUrlPreview('exturl_$residx');">$lt{'pr'}</a></span> |
|
</span><br /> |
|
<span class="LC_nobreak"> |
|
<span class="LC_docs_ext_edit">$lt{'ti'} </span> |
|
<input type="text" size="40" name="exttitle" value="$title" /> |
|
$uploadtag |
|
<input type="hidden" name="importdetail" value="" /> |
|
<input type="button" value="$lt{'sv'}" onclick="javascript:setExternal(this.form,'$residx')" /> |
|
</span> |
|
</fieldset> |
|
</form> |
|
EXTLNK |
|
} else { |
|
my ($cfile,$home,$switchserver,$forceedit,$forceview) = |
|
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); |
|
if (($cfile ne '') && ($symb ne '')) { |
|
my $jscall = |
|
&Apache::lonhtmlcommon::jump_to_editres($cfile,$home, |
|
$switchserver, |
|
$forceedit, |
|
undef,$symb); |
|
if ($jscall) { |
|
$editlink = ' <a class="LC_docs_ext_edit" href="javascript:'. |
|
$jscall.'" >'.&mt('Edit').'</a>'; |
|
} |
|
} |
|
} |
|
} |
} |
my $reinit; |
my $reinit; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
Line 2518 EXTLNK
|
Line 1883 EXTLNK
|
} else { |
} else { |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
} |
} |
$line.=$editlink."</td>"; |
$line.=$external."</td>"; |
$rand_pick_text = ' ' if ($rand_pick_text eq ''); |
$rand_pick_text = ' ' if ($rand_pick_text eq ''); |
$rand_order_text = ' ' if ($rand_order_text eq ''); |
$rand_order_text = ' ' if ($rand_order_text eq ''); |
if (($allowed) && ($folder!~/^supplemental/)) { |
if (($allowed) && ($folder!~/^supplemental/)) { |
Line 2549 ENDPARMS
|
Line 1914 ENDPARMS
|
return $line; |
return $line; |
} |
} |
|
|
sub newmap_suffix { |
|
my ($area,$container,$coursedom,$coursenum) = @_; |
|
my ($prefix,$idtype,$errtext,$locknotfreed); |
|
$prefix = 'docs'; |
|
if ($area eq 'supplemental') { |
|
$prefix = 'supp'; |
|
} |
|
$prefix .= $container; |
|
$idtype = 'concat'; |
|
my ($suffix,$freedlock,$error) = |
|
&Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps', |
|
$coursedom,$coursenum); |
|
if (!$suffix) { |
|
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.'); |
|
if ($error) { |
|
$errtext .= '<br />'.$error; |
|
} |
|
} |
|
if ($freedlock ne 'ok') { |
|
$locknotfreed = '<div class="LC_error">'.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course. Please contact the domain coordinator for your LON-CAPA domain.').'</div>'; |
|
} |
|
return ($suffix,$errtext,$locknotfreed); |
|
} |
|
|
|
=pod |
=pod |
|
|
=item tiehash() |
=item tiehash() |
Line 2938 ENDHEADERS
|
Line 2279 ENDHEADERS
|
'<th colspan="'.$num_ver_col.'">'.&mt('History').'</th>'. |
'<th colspan="'.$num_ver_col.'">'.&mt('History').'</th>'. |
'</b>'); |
'</b>'); |
foreach my $key (sort(keys(%changes))) { |
foreach my $key (sort(keys(%changes))) { |
#excludes not versionable problems from resource version history: |
if ($changes{$key}>$starttime) { |
next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/); |
|
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); |
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); |
my $currentversion=&Apache::lonnet::getversion($key); |
my $currentversion=&Apache::lonnet::getversion($key); |
if ($currentversion<0) { |
if ($currentversion<0) { |
Line 3105 sub init_breadcrumbs {
|
Line 2445 sub init_breadcrumbs {
|
sub create_list_elements { |
sub create_list_elements { |
my @formarr = @_; |
my @formarr = @_; |
my $list = ''; |
my $list = ''; |
foreach my $button (@formarr){ |
for my $button (@formarr){ |
foreach my $picture (keys(%{$button})) { |
for my $picture(keys %$button) { |
$list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''}); |
$list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); |
} |
} |
} |
} |
return $list; |
return $list; |
Line 3130 sub startContentScreen {
|
Line 2470 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('Content Editor').' </b></a></li>'."\n"; |
$output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'."\n"; |
Line 3176 sub handler {
|
Line 2517 sub handler {
|
'Adding_External_Resource','Navigate_Content', |
'Adding_External_Resource','Navigate_Content', |
'Adding_Folders','Docs_Overview', 'Load_Map', |
'Adding_Folders','Docs_Overview', 'Load_Map', |
'Supplemental','Score_Upload_Form','Adding_Pages', |
'Supplemental','Score_Upload_Form','Adding_Pages', |
'Importing_LON-CAPA_Resource','Importing_IMS_Course', |
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', |
'Uploading_From_Harddrive', |
|
'Check_Resource_Versions','Verify_Content') { |
'Check_Resource_Versions','Verify_Content') { |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
} |
} |
Line 3468 sub handler {
|
Line 2808 sub handler {
|
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
}; |
}; |
} |
} |
if ($env{'docs.markedcopy_url'}) { |
|
$script .= &paste_popup_js(); |
|
} |
|
my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. |
|
&mt('Switch server?'); |
|
} |
} |
# -------------------------------------------------------------------- Body tag |
# -------------------------------------------------------------------- Body tag |
$script = '<script type="text/javascript">'."\n" |
$script = '<script type="text/javascript">'."\n" |
Line 3565 sub handler {
|
Line 2900 sub handler {
|
'upls' => 'Upload a new supplemental '.lc($crstype).' document', |
'upls' => 'Upload a new supplemental '.lc($crstype).' document', |
'impp' => 'Import a document', |
'impp' => 'Import a document', |
'copm' => 'All documents out of a published map into this folder', |
'copm' => 'All documents out of a published map into this folder', |
'upfi' => 'Upload File', |
'upld' => 'Import Document', |
'upld' => 'Import Content', |
|
'srch' => 'Search', |
'srch' => 'Search', |
'impo' => 'Import', |
'impo' => 'Import', |
'lnks' => 'Import from Stored Links', |
'lnks' => 'Import from Stored Links', |
'impm' => 'Import from Assembled Map', |
|
'selm' => 'Select Map', |
'selm' => 'Select Map', |
'load' => 'Load Map', |
'load' => 'Load Map', |
'reco' => 'Recover Deleted Documents', |
'reco' => 'Recover Deleted Documents', |
Line 3590 sub handler {
|
Line 2923 sub handler {
|
'abou' => 'Personal Information Page for a User', |
'abou' => 'Personal Information Page for a User', |
'imsf' => 'IMS Import', |
'imsf' => 'IMS Import', |
'imsl' => 'Import IMS package', |
'imsl' => 'Import IMS package', |
'cms' => 'Origin of IMS package', |
|
'file' => 'File', |
'file' => 'File', |
'se' => 'Select', |
|
'title' => 'Title', |
'title' => 'Title', |
'comment' => 'Comment', |
'comment' => 'Comment', |
'url' => 'URL', |
|
'prev' => 'Preview', |
|
'lnk' => 'Add Link', |
|
'parse' => 'Upload embedded images/multimedia files if HTML file', |
'parse' => 'Upload embedded images/multimedia files if HTML file', |
'nd' => 'Upload Document', |
'nd' => 'Upload Document', |
'pm' => 'Published Map', |
'pm' => 'Published Map', |
Line 3618 FIUP
|
Line 2946 FIUP
|
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'} |
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'} |
</label> |
</label> |
CHBO |
CHBO |
my $imsfolder = $env{'form.folder'}; |
|
if ($imsfolder eq '') { |
my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}"; |
$imsfolder = 'default'; |
my $fileuploadform=(<<FUFORM); |
} |
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
my $imspform=(<<IMSFORM); |
|
<a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');"> |
|
$lt{'imsf'}</a> $help{'Importing_IMS_Course'} |
|
<form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport"> |
|
<fieldset id="uploadimsform" style="display: none;" /> |
|
<legend>$lt{'imsf'}</legend> |
|
$fileupload |
|
<br /> |
|
<p> |
|
$lt{'cms'}: |
|
<select name="source"> |
|
<option value="-1" selected="selected">$lt{'se'}</option> |
|
<option value="bb5">Blackboard 5</option> |
|
<option value="bb6">Blackboard 6</option> |
|
<option value="angel5">ANGEL 5.5</option> |
|
<option value="webctce4">WebCT 4 Campus Edition</option> |
|
</select> |
|
<input type="hidden" name="folder" value="$imsfolder" /> |
|
</p> |
|
<input type="hidden" name="phase" value="one" /> |
|
<input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" /> |
|
</fieldset> |
|
</form> |
|
IMSFORM |
|
|
|
my $fileuploadform=(<<FUFORM); |
|
<a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');"> |
|
$lt{'upfi'}</a> $help{'Uploading_From_Harddrive'} |
|
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
|
<fieldset id="uploaddocform" style="display: none;" /> |
|
<legend>$lt{'upfi'}</legend> |
|
<input type="hidden" name="active" value="aa" /> |
<input type="hidden" name="active" value="aa" /> |
$fileupload |
$fileupload |
<br /> |
<br /> |
Line 3664 IMSFORM
|
Line 2961 IMSFORM
|
<span class="LC_nobreak" style="float:left"> |
<span class="LC_nobreak" style="float:left"> |
$checkbox |
$checkbox |
</span> |
</span> |
<br clear="all" /> |
|
<input type="submit" value="$lt{'upld'}" /> |
|
</fieldset> |
|
</form> |
|
FUFORM |
FUFORM |
|
$fileuploadform .= $fileuploada.'</form>'; |
|
|
my $importpubform=(<<SEDFFORM); |
my $simpleeditdefaultform=(<<SEDFFORM); |
<a class="LC_menubuttons_link" href="javascript:toggleMap();"> |
<form action="/adm/coursedocs" method="post" name="simpleeditdefault"> |
$lt{'impm'}</a>$help{'Load_Map'} |
<input type="hidden" name="active" value="bb" /> |
<form action="/adm/coursedocs" method="post" name="mapimportform"> |
|
<fieldset id="importmapform" style="display: none;" /> |
|
<legend>$lt{'impm'}</legend> |
|
<input type="hidden" name="active" value="bb" /> |
|
$lt{'copm'}<br /> |
|
<span class="LC_nobreak"> |
|
<input type="text" name="importmap" size="40" value="" |
|
onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" /> |
|
<a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a><br /> |
|
<input type="submit" name="loadmap" value="$lt{'load'}" /> |
|
</fieldset> |
|
</form> |
|
|
|
SEDFFORM |
SEDFFORM |
|
|
my @simpleeditdefaultforma = ( |
my @simpleeditdefaultforma = ( |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap();" />' => $importpubform } |
); |
); |
$simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma)); |
$importpubform = &create_form_ul(&create_list_elements(@importpubforma)); |
$simpleeditdefaultform .=(<<SEDFFORM); |
|
<hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" /> |
|
$lt{'copm'}<br /> |
|
<input type="text" size="40" name="importmap" /><br /> |
|
<span class="LC_nobreak" style="float:left"><input type="button" |
|
onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" |
|
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" /> |
|
$help{'Load_Map'}</span> |
|
</form> |
|
SEDFFORM |
|
|
my $extresourcesform=(<<ERFORM); |
my $extresourcesform=(<<ERFORM); |
<a class="LC_menubuttons_link" href="javascript:toggleUpload('ext');">$lt{'extr'}</a>$help{'Adding_External_Resource'} |
|
<form action="/adm/coursedocs" method="post" name="newext"> |
<form action="/adm/coursedocs" method="post" name="newext"> |
<fieldset id="uploadextform" style="display: none;" /> |
|
<legend>$lt{'extr'}</legend> |
|
<input type="hidden" name="active" value="aa" /> |
|
$lt{'url'}:<br /> |
|
<input type="text" size="60" name="exturl" id="exturl" value="http://" /> |
|
<input type="button" name="view" value="$lt{'prev'}" onclick="javascript:extUrlPreview('exturl');" /><br /> |
|
$lt{'title'}:<br /> |
|
<input type="text" size="60" name="exttitle" value="$lt{'extr'}" /> |
|
$uploadtag |
$uploadtag |
<br /> |
|
<input type="hidden" name="importdetail" value="" /> |
<input type="hidden" name="importdetail" value="" /> |
<input type="button" value="$lt{'lnk'}" onclick="javascript:setExternal(this.form,0)" /> |
<a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'} |
</fieldset> |
|
</form> |
</form> |
ERFORM |
ERFORM |
|
|
|
|
if ($allowed) { |
if ($allowed) { |
my $folder = $env{'form.folder'}; |
&update_paste_buffer($coursenum,$coursedom); |
if ($folder eq '') { |
|
$folder='default'; |
|
} |
|
&update_paste_buffer($coursenum,$coursedom,$folder); |
|
$r->print(<<HIDDENFORM); |
$r->print(<<HIDDENFORM); |
<form name="renameform" method="post" action="/adm/coursedocs"> |
<form name="renameform" method="post" action="/adm/coursedocs"> |
<input type="hidden" name="title" /> |
<input type="hidden" name="title" /> |
Line 3770 HIDDENFORM
|
Line 3044 HIDDENFORM
|
} else { |
} else { |
#$postexec='self.close();'; |
#$postexec='self.close();'; |
} |
} |
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence'; |
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
'.sequence'; |
'.sequence'; |
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page'; |
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
'.page'; |
'.page'; |
my $container='sequence'; |
my $container='sequence'; |
if ($env{'form.pagepath'}) { |
if ($env{'form.pagepath'}) { |
Line 3780 HIDDENFORM
|
Line 3054 HIDDENFORM
|
} |
} |
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; |
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; |
|
|
|
my $imspform=(<<IMSPFORM); |
|
<form action="/adm/imsimportdocs" method="post" name="ims"> |
|
<input type="hidden" name="folder" value="$folder" /> |
|
<a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a> |
|
</form> |
|
IMSPFORM |
|
|
my $newnavform=(<<NNFORM); |
my $newnavform=(<<NNFORM); |
<form action="/adm/coursedocs" method="post" name="newnav"> |
<form action="/adm/coursedocs" method="post" name="newnav"> |
<input type="hidden" name="active" value="cc" /> |
<input type="hidden" name="active" value="cc" /> |
Line 3934 NGFFORM
|
Line 3215 NGFFORM
|
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma)); |
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma)); |
|
|
|
|
|
|
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="javascript:makenewext(\'newext\');" />'=>$extresourcesform}, |
{'<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:makeims();" />'=>$imspform},); |
{'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform, |
$fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform; |
}); |
|
$fileuploadform = &create_form_ul(&create_list_elements(@importdoc)); |
|
|
|
@gradingforma=( |
@gradingforma=( |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
Line 3961 NGFFORM
|
Line 3239 NGFFORM
|
|
|
my %orderhash = ( |
my %orderhash = ( |
'aa' => ['Import Content',$fileuploadform], |
'aa' => ['Import Content',$fileuploadform], |
'bb' => ['Published Content',$importpubform], |
'bb' => ['Published Content',$simpleeditdefaultform], |
'cc' => ['Grading Resources',$gradingform], |
'cc' => ['Grading Resources',$gradingform], |
); |
); |
unless ($env{'form.pagepath'}) { |
unless ($env{'form.pagepath'}) { |
Line 3973 unless ($env{'form.pagepath'}) {
|
Line 3251 unless ($env{'form.pagepath'}) {
|
$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,$uploadtag); |
$supplementalflag,\%orderhash,$iconpath); |
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 4000 unless ($env{'form.pagepath'}) {
|
Line 3278 unless ($env{'form.pagepath'}) {
|
$env{'form.pagepath'} = ''; |
$env{'form.pagepath'} = ''; |
if ($allowed) { |
if ($allowed) { |
my $folderseq= |
my $folderseq= |
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence'; |
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. |
|
'.sequence'; |
|
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
|
|
|
my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}"; |
my $supupdocform=(<<SUPDOCFORM); |
my $supupdocform=(<<SUPDOCFORM); |
<a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');"> |
|
$lt{'upfi'}</a> $help{'Uploading_From_Harddrive'} |
|
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> |
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> |
<fieldset id="uploadsuppdocform" style="display: none;" /> |
|
<legend>$lt{'upfi'}</legend> |
|
<input type="hidden" name="active" value="ee" /> |
<input type="hidden" name="active" value="ee" /> |
$fileupload |
$fileupload |
<br /> |
<br /> |
Line 4023 unless ($env{'form.pagepath'}) {
|
Line 3299 unless ($env{'form.pagepath'}) {
|
<br /> |
<br /> |
<input type="hidden" name="folderpath" value="$path" /> |
<input type="hidden" name="folderpath" value="$path" /> |
<input type="hidden" name="cmd" value="upload_supplemental" /> |
<input type="hidden" name="cmd" value="upload_supplemental" /> |
<input type='submit' value="$lt{'upld'}" /> |
SUPDOCFORM |
</form> |
$supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>"; |
|
|
my $supnewfolderform=(<<SNFFORM); |
my $supnewfolderform=(<<SNFFORM); |
<form action="/adm/coursedocs" method="post" name="supnewfolder"> |
<form action="/adm/coursedocs" method="post" name="supnewfolder"> |
Line 4036 unless ($env{'form.pagepath'}) {
|
Line 3312 unless ($env{'form.pagepath'}) {
|
</form> |
</form> |
SNFFORM |
SNFFORM |
|
|
my $supextform=(<<ERFORM); |
|
<a class="LC_menubuttons_link" href="javascript:toggleUpload('suppext');">$lt{'extr'}</a>$help{'Adding_External_Resource'} |
my $supnewextform=(<<SNEFORM); |
<form action="/adm/coursedocs" method="post" name="newsuppext"> |
<form action="/adm/coursedocs" method="post" name="supnewext"> |
<fieldset id="uploadsuppextform" style="display: none;" /> |
<input type="hidden" name="active" value="ff" /> |
<legend>$lt{'extr'}</legend> |
<input type="hidden" name="folderpath" value="$path" /> |
<input type="hidden" name="active" value="ee" /> |
<input type="hidden" name="importdetail" value="" /> |
$lt{'url'}:<br /> |
<a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'} |
<input type="text" size="60" name="exturl" id="exturl" value="http://" /> |
</form> |
<input type="button" name="view" value="$lt{'prev'}" onclick="javascript:extUrlPreview('exturl');" /><br /> |
SNEFORM |
$lt{'title'}:<br /> |
|
<input type="text" size="60" name="exttitle" value="$lt{'extr'}" /> |
|
$uploadtag |
|
<br /> |
|
<input type="hidden" name="importdetail" value="" /> |
|
<input type="button" value="$lt{'lnk'}" onclick="javascript:setExternal(this.form,0)" /> |
|
</fieldset> |
|
</form> |
|
ERFORM |
|
|
|
my $supnewsylform=(<<SNSFORM); |
my $supnewsylform=(<<SNSFORM); |
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
Line 4085 my @specialdocs = (
|
Line 3352 my @specialdocs = (
|
=>$supnewaboutmeform}, |
=>$supnewaboutmeform}, |
); |
); |
my @supimportdoc = ( |
my @supimportdoc = ( |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supext\');" />' |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />' |
=>$supextform}, |
=>$supnewextform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' |
|
=>$supupdocform}, |
|
); |
); |
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)); |
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform; |
my %suporderhash = ( |
my %suporderhash = ( |
'00' => ['Supnewfolder', $supnewfolderform], |
'00' => ['Supnewfolder', $supnewfolderform], |
'ee' => ['Import Content',$supupdocform], |
'ee' => ['Import Content',$supupdocform], |
Line 4098 my %suporderhash = (
|
Line 3363 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,$uploadtag); |
$supplementalflag,\%suporderhash,$iconpath); |
if ($error) { |
if ($error) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} |
} |
} |
} |
} elsif ($supplementalflag) { |
} elsif ($supplementalflag) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
$supplementalflag,'',$iconpath,$uploadtag); |
$supplementalflag,'',$iconpath); |
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 4125 my %suporderhash = (
|
Line 3390 my %suporderhash = (
|
} elsif ($showdoc) { |
} elsif ($showdoc) { |
# -------------------------------------------------------- This is showdoc mode |
# -------------------------------------------------------- This is showdoc mode |
$r->print("<h1>".&mt('Uploaded Document').' - '. |
$r->print("<h1>".&mt('Uploaded Document').' - '. |
&Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'. |
&Apache::lonnet::gettitle($r->uri).'</h1><p>'. |
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>". |
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>". |
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
} |
} |
Line 4199 sub decompression_phase_one {
|
Line 3464 sub decompression_phase_one {
|
my ($dir,$file,$warning,$error,$output); |
my ($dir,$file,$warning,$error,$output); |
my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)= |
my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)= |
&decompression_info(); |
&decompression_info(); |
if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) { |
if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/docs/\E(?:default|supplemental|\d+).*/([^/]+)$}) { |
$error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'}); |
$error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'}); |
} else { |
} else { |
my $file = $1; |
my $file = $1; |
Line 4254 sub remove_archive {
|
Line 3519 sub remove_archive {
|
my ($title,$url,@rrest) = |
my ($title,$url,@rrest) = |
split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]); |
split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]); |
if (&handle_edit_cmd($docuname,$docudom)) { |
if (&handle_edit_cmd($docuname,$docudom)) { |
($errtext,$fatal) = &storemap($docuname,$docudom,$map,1); |
($errtext,$fatal) = &storemap($docuname,$docudom,$map); |
if ($fatal) { |
if ($fatal) { |
if ($container eq 'page') { |
if ($container eq 'page') { |
$delwarning = &mt('An error occurred updating the contents of the current page.'); |
$delwarning = &mt('An error occurred updating the contents of the current page.'); |
Line 4378 sub generate_edit_table {
|
Line 3643 sub generate_edit_table {
|
my $backicon = $iconpath.'clickhere.gif'; |
my $backicon = $iconpath.'clickhere.gif'; |
my $backtext = &mt('To Overview'); |
my $backtext = &mt('To Overview'); |
$form = '<div class="LC_Box" style="margin:0;">'. |
$form = '<div class="LC_Box" style="margin:0;">'. |
'<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n". |
'<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n". |
'<li class="goback">'. |
'<li class="goback">'. |
'<a href="javascript:toContents('."'$jumpto'".');">'. |
'<a href="javascript:toContents('."'$jumpto'".');">'. |
'<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'. |
'<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'. |
' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n". |
' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n". |
'<li>'. |
'<li>'. |
'<a href="javascript:groupopen('."'$readfile'".',1);">'. |
'<a href="javascript:groupopen('."'$readfile'".',1);">'. |
&mt('Undo Delete').'</a></li>'."\n"; |
&mt('Undo Delete').'</a></li>'."\n"; |
if ($env{'form.docslog'}) { |
if ($env{'form.docslog'}) { |
$form .= '<li class="active">'; |
$form .= '<li class="active">'; |
} else { |
} else { |
Line 4405 sub generate_edit_table {
|
Line 3670 sub generate_edit_table {
|
$active = 'class="active"'; |
$active = 'class="active"'; |
} |
} |
$form .= '<li style="float:right" '.$active |
$form .= '<li style="float:right" '.$active |
|
.' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"' |
.' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n"; |
.' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n"; |
} else { |
} else { |
$form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n"; |
$form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n"; |
Line 4461 sub editing_js {
|
Line 3727 sub editing_js {
|
p_ctr2a => 'Cut[_98]', |
p_ctr2a => 'Cut[_98]', |
p_ctr2b => '?[_98]', |
p_ctr2b => '?[_98]', |
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', |
|
imscms => 'You must select which Course Management System was the source of the IMS package', |
|
invurl => 'Invalid URL', |
|
titbl => 'Title is blank', |
|
); |
); |
|
|
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
Line 4484 sub editing_js {
|
Line 3746 sub editing_js {
|
$backtourl = '/adm/supplemental'; |
$backtourl = '/adm/supplemental'; |
} |
} |
|
|
my $fieldsets = "'ext','doc','ims'"; |
|
if ($supplementalflag) { |
|
$fieldsets = "'suppext','suppdoc'"; |
|
} |
|
|
|
my $urlregexp = <<'ENDREGEXP'; |
|
/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i |
|
ENDREGEXP |
|
|
|
return <<ENDNEWSCRIPT; |
return <<ENDNEWSCRIPT; |
function makenewfolder(targetform,folderseq) { |
function makenewfolder(targetform,folderseq) { |
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}'); |
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}'); |
Line 4510 function makenewpage(targetform,folderse
|
Line 3763 function makenewpage(targetform,folderse
|
} |
} |
} |
} |
|
|
function editext(residx) { |
function makenewext(targetname) { |
if (document.getElementById('uploadext'+residx)) { |
this.document.forms.extimport.useform.value=targetname; |
var curr = document.getElementById('uploadext'+residx).style.display; |
this.document.forms.extimport.title.value=''; |
if (curr == 'none') { |
this.document.forms.extimport.url.value=''; |
disp = 'block'; |
this.document.forms.extimport.residx.value=''; |
} else { |
window.open('/adm/rat/extpickframe.html'); |
disp = 'none'; |
} |
} |
|
document.getElementById('uploadext'+residx).style.display=disp; |
function edittext(targetname,residx,title,url) { |
} |
this.document.forms.extimport.useform.value=targetname; |
resize_scrollbox('contentscroll','1','1'); |
this.document.forms.extimport.residx.value=residx; |
return; |
this.document.forms.extimport.url.value=url; |
|
this.document.forms.extimport.title.value=title; |
|
window.open('/adm/rat/extpickframe.html'); |
} |
} |
|
|
function makeexamupload() { |
function makeexamupload() { |
Line 4588 function makeabout() {
|
Line 3843 function makeabout() {
|
} |
} |
} |
} |
|
|
function toggleUpload(caller) { |
function makeims() { |
var blocks = Array($fieldsets); |
var caller = document.forms.ims.folder.value; |
for (var i=0; i<blocks.length; i++) { |
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; |
var disp = 'none'; |
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); |
if (caller == blocks[i]) { |
newWindow.location.href = newlocation; |
var curr = document.getElementById('upload'+caller+'form').style.display; |
|
if (curr == 'none') { |
|
disp='block'; |
|
} |
|
} |
|
document.getElementById('upload'+blocks[i]+'form').style.display=disp; |
|
} |
|
resize_scrollbox('contentscroll','1','1'); |
|
return; |
|
} |
|
|
|
function toggleMap() { |
|
var disp = 'none'; |
|
var curr = document.getElementById('importmapform').style.display; |
|
if (curr == 'none') { |
|
disp='block'; |
|
} |
|
document.getElementById('importmapform').style.display=disp; |
|
resize_scrollbox('contentscroll','1','1'); |
|
return; |
|
} |
|
|
|
|
|
function extUrlPreview(caller) { |
|
if (document.getElementById(caller)) { |
|
var url = document.getElementById(caller).value; |
|
var regexp = $urlregexp; |
|
if (regexp.test(url)) { |
|
openMyModal(url,500,400,'yes'); |
|
} else { |
|
alert("$lt{'invurl'}"); |
|
} |
|
} |
|
} |
|
|
|
function makeims(imsform) { |
|
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
|
alert("$lt{'imsfile'}"); |
|
return; |
|
} |
|
if (imsform.source.selectedIndex == 0) { |
|
alert("$lt{'imscms'}"); |
|
return; |
|
} |
|
newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes"); |
|
imsform.submit(); |
|
} |
} |
|
|
function setExternal(extform,residx) { |
function finishpick() { |
var title=extform.exttitle.value; |
var title=this.document.forms.extimport.title.value; |
if (!String.trim) { |
var url=this.document.forms.extimport.url.value; |
String.prototype.trim = function() {return this.replace(\/^\\s+|\\s+$\/g, "");}; } |
var form=this.document.forms.extimport.useform.value; |
var url=extform.exturl.value; |
var residx=this.document.forms.extimport.residx.value; |
var regexp = $urlregexp; |
eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();'); |
if (title == null || title.trim()=="") { |
|
alert("$lt{'titbl'}"); |
|
extform.exttitle.focus(); |
|
return; |
|
} |
|
if (regexp.test(url)) { |
|
url = escape(url); |
|
if (residx > 0) { |
|
eval("extform.importdetail.value=title+'='+url+'='+residx;extform.submit();"); |
|
} else { |
|
eval("extform.importdetail.value=title+'='+url;extform.submit();"); |
|
} |
|
} else { |
|
alert("$lt{'invurl'}"); |
|
extform.exturl.focus(); |
|
return; |
|
} |
|
} |
} |
|
|
function changename(folderpath,index,oldtitle,container,pagesymb) { |
function changename(folderpath,index,oldtitle,container,pagesymb) { |
Line 4817 function showPage(current, pageId, nav,
|
Line 4009 function showPage(current, pageId, nav,
|
currentData = document.getElementById(pageId); |
currentData = document.getElementById(pageId); |
currentData.style.display = 'block'; |
currentData.style.display = 'block'; |
activeTab = pageId; |
activeTab = pageId; |
toggleUpload(); |
|
toggleMap(); |
|
if (nav == 'mainnav') { |
if (nav == 'mainnav') { |
var storedpath = "$docs_folderpath"; |
var storedpath = "$docs_folderpath"; |
if (storedpath == '') { |
if (storedpath == '') { |
Line 5045 Return hash with valid author names
|
Line 4235 Return hash with valid author names
|
|
|
=item do_paste_from_buffer() |
=item do_paste_from_buffer() |
|
|
=item get_newmap_url() |
|
|
|
=item dbcopy() |
|
|
|
=item uniqueness_check() |
|
|
|
=item contained_map_check() |
|
|
|
=item reinit_role() |
|
|
|
=item url_paste_fixups() |
|
|
|
=item apply_fixups() |
|
|
|
=item copy_dependencies() |
|
|
|
=item update_parameter() |
=item update_parameter() |
|
|
=item handle_edit_cmd() |
=item handle_edit_cmd() |