--- loncom/interface/londocs.pm 2016/08/06 21:53:02 1.484.2.64 +++ loncom/interface/londocs.pm 2014/03/09 15:49:48 1.578 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.64 2016/08/06 21:53:02 raeburn Exp $ +# $Id: londocs.pm,v 1.578 2014/03/09 15:49:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -196,7 +196,7 @@ ENDJS } else { &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles, 'dumpdocs',$cdom,$cnum); - } + } my @todump = &Apache::loncommon::get_env_multiple('form.archive'); my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages, %newcontent,%has_simpleprobs); @@ -207,7 +207,7 @@ ENDJS if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) { $tocopy{$1} = $name; $display{$item} = $1; - $lookup{$1} = $item; + $lookup{$1} = $item; } elsif ($res eq 'lib/templates/simpleproblem.problem') { $simpleproblems{$item} = { symb => $resources{$item}, @@ -307,7 +307,7 @@ $contents{content}.' '; } if ($contents{webreferences}) { - $content .= ' + $content .= '

'.&mt('Web References').'

'. $contents{webreferences}.' @@ -317,10 +317,10 @@ $contents{webreferences}.' '; - $newcontent{'/'.$simplepages{$item}{res}} = $content; + $newcontent{'/'.$simplepages{$item}{res}} = $content; } } - foreach my $item (keys(%tocopy)) { + foreach my $item (keys(%tocopy)) { unless ($item=~/\.(sequence|page)$/) { my $currurlpath = $prefix.$item; my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath); @@ -351,39 +351,39 @@ $contents{webreferences}.' if ($simpleproblems{$num}) { $newfilename=$title.'/'.$simpleproblems{$num}{'name'}; } else { - $newfilename=$title.'/'.$replacehash{$item}; + $newfilename=$title.'/'.$replacehash{$item}; } - $newfilename=~s/\.(\w+)$//; - my $ext=$1; - $newfilename=&clean($newfilename); - $newfilename.='.'.$ext; - my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); + $newfilename=~s/\.(\w+)$//; + my $ext=$1; + $newfilename=&clean($newfilename); + $newfilename.='.'.$ext; + my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); if ($newrelpath ne $replacehash{$item}) { $replacehash{$item} = $newrelpath; } - my @dirs=split(/\//,$newfilename); - my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; - my $makepath=$path; - my $fail; + my @dirs=split(/\//,$newfilename); + my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; + my $makepath=$path; + my $fail; my $origin; - for (my $i=0;$i<$#dirs;$i++) { - $makepath.='/'.$dirs[$i]; - unless (-e $makepath) { - unless(mkdir($makepath,0755)) { + for (my $i=0;$i<$#dirs;$i++) { + $makepath.='/'.$dirs[$i]; + unless (-e $makepath) { + unless(mkdir($makepath,0755)) { $fail = &mt('Directory creation failed.'); } - } - } + } + } if ($i == 0) { - $result = '
'.$item.' => '.$newfilename.': '; + $result = '
'.$item.' => '.$newfilename.': '; } else { $depresult .= '
  • '.$item.' => '.$newfilename.' '. ''. &mt('(dependency)').': '; } if (-e $path.'/'.$newfilename) { - $fail = &mt('Destination already exists -- not overwriting.'); - } else { + $fail = &mt('Destination already exists -- not overwriting.'); + } else { if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) || ($item =~ /^simpleproblem_/)) { @@ -405,18 +405,18 @@ $contents{webreferences}.' while (my $token = $parser->get_token) { if ($token->[0] eq 'S') { if (($token->[1] eq 'resource') && - ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && + ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && ($changes{$token->[2]->{'id'}})) { my $id = $token->[2]->{'id'}; $updatedcontent .= '<'.$token->[1]; foreach my $attrib (@{$token->[3]}) { - next unless ($attrib =~ /^(src|type|title|id)$/); + next unless ($attrib =~ /^(src|type|title|id)$/); if ($attrib eq 'src') { - my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); + my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); if ($file) { $updatedcontent .= ' '.$attrib.'="'.$file.'"'; } else { - $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; + $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; } } else { $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; @@ -431,36 +431,36 @@ $contents{webreferences}.' } } print $fh $updatedcontent; - } else { - print $fh &Apache::lonclonecourse::rewritefile( + } else { + print $fh &Apache::lonclonecourse::rewritefile( &Apache::lonclonecourse::readfile($env{'request.course.id'},$item), - (%replacehash,$crs => '') - ); + (%replacehash,$crs => '') + ); } } else { - print $fh + print $fh &Apache::lonclonecourse::readfile($env{'request.course.id'},$item); - } + } } else { - $fail = &mt('Source does not exist.'); + $fail = &mt('Source does not exist.'); } } $fh->close(); - } else { - $fail = &mt('Could not write to destination.'); + } else { + $fail = &mt('Could not write to destination.'); } - } + } my $text; - if ($fail) { + if ($fail) { $text = ''.&mt('fail').(' 'x3).$fail.''; - } else { + } else { $text = ''.&mt('ok').''; } if ($i == 0) { $result .= $text; } else { $depresult .= $text.'
  • '; - } + } } $r->print($result); if ($depresult) { @@ -477,63 +477,63 @@ $contents{webreferences}.' $r->rflush(); my ($preamble,$formname); $formname = 'dumpdoc'; - unless ($home==1) { - $preamble = '
    '. - '
    '. + unless ($home==1) { + $preamble = '
    '. + '
    '. &mt('Select the Authoring Space'). ''; - } else { - $preamble .= ''; - } - } - unless ($home==1) { - $preamble .= '
    '."\n"; - } - my $title=$origcrsdata{'description'}; - $title=~s/[\/\s]+/\_/gs; - $title=&clean($title); - $preamble .= '
    '. + if ($home==1) { + $preamble .= ''; + } else { + $preamble .= ''; + } + } + unless ($home==1) { + $preamble .= '
    '."\n"; + } + my $title=$origcrsdata{'description'}; + $title=~s/[\/\s]+/\_/gs; + $title=&clean($title); + $preamble .= '
    '. '
    '.&mt('Folder in Authoring Space').''. ''. '
    '."\n"; my %uploadedfiles; - &tiehash(); - foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { - my ($ext)=($file=~/\.(\w+)$/); + &tiehash(); + foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { + my ($ext)=($file=~/\.(\w+)$/); # FIXME Check supplemental here - my $title=$hash{'title_'.$hash{ - 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; - if (!$title) { - $title=$file; - } else { - $title=~s|/|_|g; - } - $title=~s/\.(\w+)$//; - $title=&clean($title); - $title.='.'.$ext; -# $r->print("\n" + my $title=$hash{'title_'.$hash{ + 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; + if (!$title) { + $title=$file; + } else { + $title=~s|/|_|g; + } + $title=~s/\.(\w+)$//; + $title=&clean($title); + $title.='.'.$ext; +# $r->print("\n" $uploadedfiles{$file} = $title; - } - &untiehash(); + } + &untiehash(); $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef, undef,undef,$preamble,$home,\%uploadedfiles)); } @@ -564,16 +564,16 @@ sub recurse_html { } else { $relfile = $dependency; $depurl = $currurlpath; - $depurl =~ s{[^/]+$}{}; + $depurl =~ s{[^/]+$}{}; $depurl .= $dependency; - ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); + ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); } next if ($relfile eq ''); my $newname = $replacehash->{$container}; $newname =~ s{[^/]+$}{}; $replacehash->{$newcontainer} = $newname.$relfile; $deps->{$item}{$newcontainer} = 1; - my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); + my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); my $depfile = &Apache::lonnet::filelocation('',$depurl); my $type = $mm->checktype_filename($depfile); if ($type eq 'text/html') { @@ -652,7 +652,7 @@ sub group_import { } else { $fname =~ s/\W/_/g; } - if (length($fname) > 15) { + if (length($fname > 15)) { $fname = substr($fname,0,14); } my $initialtext = &mt('Replace with your own content.'); @@ -667,7 +667,7 @@ $initialtext END $env{'form.output'}=$newhtml; - my $result = + my $result = &Apache::lonnet::finishuserfileupload($coursenum,$coursedom, 'output', "$filepath/$residx/$fname.html"); @@ -692,7 +692,7 @@ END removefrommap => \%removefrommap, removeparam => \%removeparam, ); - my ($result,$msgsarray,$lockerror) = + my ($result,$msgsarray,$lockerror) = &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); if (keys(%import_errors) > 0) { $fixuperrors = @@ -977,7 +977,7 @@ sub docs_change_log { sub update_paste_buffer { my ($coursenum,$coursedom,$folder) = @_; - my (@possibles,%removals,%cuts,$output); + my (@possibles,%removals,%cuts); if ($env{'form.multiremove'}) { $env{'form.multiremove'} =~ s/,$//; map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'}); @@ -1045,12 +1045,10 @@ sub update_paste_buffer { next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url})); my ($suffix,$errortxt,$locknotfreed) = &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); - if ($suffix ne '') { - push(@newpaste,$suffix); - } else { - if ($locknotfreed) { - return $locknotfreed; - } + push(@newpaste,$suffix); + if ($locknotfreed) { + return $locknotfreed; + last; } if (&is_supplemental_title($title)) { &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title}); @@ -1084,17 +1082,13 @@ sub update_paste_buffer { } } } - if ($locknotfreed) { - $output = $locknotfreed; - last; - } } if (@newpaste) { $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste)); } &Apache::lonnet::appenv(\%addtoenv); delete($env{'form.markcopy'}); - return $output; + return; } sub recurse_uploaded_maps { @@ -1197,14 +1191,10 @@ sub print_paste_buffer { $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); $icon .= '/navmap.folder.closed.gif'; } - my $title = $env{'docs.markedcopy_title_'.$suffix}; - if ($title eq '') { - ($title) = ($url =~ m{/([^/]+)$}); - } $buffer = ''. ': '. &Apache::loncommon::parse_supplemental_title( - &LONCAPA::map::qtescape($title)); + &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix})); } $pasteitems .= '
    '; my ($options,$onclick); @@ -1242,10 +1232,10 @@ sub print_paste_buffer { my $value = &mt('Paste to current folder'); if ($container eq 'page') { $value = &mt('Paste to current page'); - } + } $buttons = ''.(' 'x2); } - $buttons .= ''.(' 'x2); + $buttons .= ''.(' 'x2); if ($clipboardcount > 1) { $buttons .= ''.(' 'x20).''.(' 'x2). @@ -1353,34 +1343,29 @@ sub supp_pasteable { } sub paste_popup_js { - my %html_js_lt = &Apache::lonlocal::texthash( + my %lt = &Apache::lonlocal::texthash( show => 'Show Options', hide => 'Hide Options', - ); - my %js_lt = &Apache::lonlocal::texthash( none => 'No items selected from clipboard.', ); - &html_escape(\%html_js_lt); - &js_escape(\%html_js_lt); - &js_escape(\%js_lt); return <<"END"; function showPasteOptions(suffix) { document.getElementById('pasteoptions_'+suffix).style.display='block'; - document.getElementById('pasteoptionstext_'+suffix).innerHTML = '    $html_js_lt{'hide'}'; + document.getElementById('pasteoptionstext_'+suffix).innerHTML = '    $lt{'hide'}'; return; } function hidePasteOptions(suffix) { document.getElementById('pasteoptions_'+suffix).style.display='none'; - document.getElementById('pasteoptionstext_'+suffix).innerHTML ='    $html_js_lt{'show'}'; + document.getElementById('pasteoptionstext_'+suffix).innerHTML ='    $lt{'show'}'; return; } function showOptions(caller,suffix) { if (document.getElementById('pasteoptionstext_'+suffix)) { if (caller.checked) { - document.getElementById('pasteoptionstext_'+suffix).innerHTML ='    $html_js_lt{'show'}'; + document.getElementById('pasteoptionstext_'+suffix).innerHTML ='    $lt{'show'}'; } else { document.getElementById('pasteoptionstext_'+suffix).innerHTML =''; } @@ -1409,7 +1394,7 @@ function validateClipboard() { if (numchk > 0) { return true; } else { - alert("$js_lt{'none'}"); + alert("$lt{'none'}"); return false; } } @@ -1418,7 +1403,7 @@ function checkClipboard() { if (document.pasteform.pasting.length > 1) { for (var i=0; i{'cdom'} =~ /^$match_domain$/) && + if (($dbref->{'cdom'} =~ /^$match_domain$/) && ($dbref->{'cnum'} =~ /^$match_courseid$/)) { my $db_name; my $marker = (split(m{/},$url))[4]; @@ -1959,12 +1944,12 @@ sub dbcopy { my $photo = $contents{'uploaded.photourl'}; my ($subdir,$fname) = ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$}); - my $newphoto; + my $newphoto; if ($fname ne '') { my $content = &Apache::lonnet::getfile($photo); unless ($content eq '-1') { $env{'form.'.$suffix.'.photourl'} = $content; - $newphoto = + $newphoto = &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); delete($env{'form.'.$suffix.'.photourl'}); } @@ -2109,7 +2094,7 @@ sub url_paste_fixups { } next if ($token->[2]->{'type'} eq 'external'); if ($token->[2]->{'type'} eq 'zombie') { - next if ($skip); + next if ($skip); $zombies->{$oldurl}{$id} = $ressrc; $changed = 1; } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { @@ -2555,7 +2540,7 @@ sub update_parameter { 'randomorder' => {}, ); foreach my $which (keys(%allchecked)) { - $env{'form.all'.$which} =~ s/,$//; + $env{'form.all'.$which} =~ s/,$//; if ($which eq 'randompick') { foreach my $item (split(/,/,$env{'form.all'.$which})) { my ($res,$value) = split(/:/,$item); @@ -2582,7 +2567,7 @@ sub update_parameter { foreach my $which (keys(%allchecked)) { if (($which eq 'randompick' || $which eq 'randomorder')) { next if (!$is_map); - } + } my $oldvalue = 0; my $newvalue = 0; if ($allchecked{$which}{$res}) { @@ -2618,45 +2603,26 @@ sub update_parameter { } return $haschanges; } else { - my $haschanges = 0; - return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/); + return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/); my $which = $env{'form.changeparms'}; my $idx = $env{'form.setparms'}; - my $oldvalue = 0; - my $newvalue = 0; - my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0]; - if ($which eq 'randompick') { - if ($current =~ /^(\d+)$/) { - $oldvalue = $1; - } - } elsif ($current =~ /^yes$/i) { - $oldvalue = 1; - } if ($env{'form.'.$which.'_'.$idx}) { - $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} - : 1; - } - if ($oldvalue ne $newvalue) { - $haschanges = 1; - if ($newvalue) { - my $storeval = 'yes'; - if ($which eq 'randompick') { - $storeval = $newvalue; - } - &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval, - $parameter_type{$which}); - &remember_parms($idx,$which,'set',$storeval); - } else { - &LONCAPA::map::delparameter($idx,'parameter_'.$which); - &remember_parms($idx,$which,'del'); - } + my $value = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} + : 'yes'; + &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value, + $parameter_type{$which}); + &remember_parms($idx,$which,'set',$value); + } else { + &LONCAPA::map::delparameter($idx,'parameter_'.$which); + + &remember_parms($idx,$which,'del'); } - return $haschanges; + return 1; } - return; } + sub handle_edit_cmd { my ($coursenum,$coursedom) =@_; if ($env{'form.cmd'} eq '') { @@ -2748,7 +2714,7 @@ sub editor { &snapshotbefore(); if (&update_parameter()) { - ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1); + ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); return $errtext if ($fatal); } @@ -2810,9 +2776,9 @@ sub editor { $r->print($upload_output); # Rename, cut, copy or remove a single resource - if (&handle_edit_cmd($coursenum,$coursedom)) { + if (&handle_edit_cmd()) { my $contentchg; - if ($env{'form.cmd'} =~ m{^(remove|cut)_}) { + if ($env{'form.cmd'} =~ m{^(del|cut)_}) { $contentchg = 1; } ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); @@ -2844,7 +2810,7 @@ sub editor { my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); $name=&LONCAPA::map::qtescape($name); $url=&LONCAPA::map::qtescape($url); - next unless $url; + next unless ($name && $url); my %denied = &action_restrictions($coursenum,$coursedom,$url, $env{'form.folderpath'},\%curr_groups); @@ -3060,11 +3026,11 @@ sub editor { if (@allidx > 0) { my $path; if ($env{'form.folderpath'}) { - $path = + $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); } if (@allidx > 1) { - $to_show .= + $to_show .= &Apache::loncommon::continue_data_table_row(). ' '. ''. @@ -3208,8 +3174,8 @@ sub process_file_upload { } my $quotatype = 'unofficial'; if ($crstype eq 'Community') { - $quotatype = 'community'; - } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { + $quotatype = 'community'; + } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) { $quotatype = 'official'; } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { $quotatype = 'textbook'; @@ -3217,8 +3183,7 @@ sub process_file_upload { if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) { $filesize = int($filesize/1000); #expressed in kb $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course', - $env{'form.uploaddoc.filename'},$filesize, - 'upload',$quotatype); + $env{'form.uploaddoc.filename'},$filesize,'upload'); return if ($$upload_output); } my ($parseaction,$showupload,$nextphase,$mimetype); @@ -3379,7 +3344,7 @@ sub is_supplemental_title { sub entryline { my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups)=@_; - my ($foldertitle,$renametitle,$oldtitle); + my ($foldertitle,$renametitle); if (&is_supplemental_title($title)) { ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); } else { @@ -3392,10 +3357,8 @@ sub entryline { $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; - $renametitle=~s/"/%22/g; + $renametitle=~s/\'/\\\'/g; $renametitle=~s/ /%20/g; - $oldtitle = $renametitle; - $renametitle=~s/\'\;/\\\'/g; my $line=&Apache::loncommon::start_data_table_row(); my ($form_start,$form_end,$form_common,$form_param); # Edit commands @@ -3480,7 +3443,6 @@ END $currgroups); my ($copylink,$cutlink,$removelink); my $skip_confirm = 0; - my $confirm_removal = 0; if ( $folder =~ /^supplemental/ || ($url =~ m{( /smppg$ |/syllabus$ @@ -3491,10 +3453,6 @@ END || $isexternal) { $skip_confirm = 1; } - if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && - ($url!~/$LONCAPA::assess_page_seq_re/)) { - $confirm_removal = 1; - } if ($denied{'copy'}) { $copylink=(< $form_common - $lt{'rm'} $form_end ENDREM @@ -3551,7 +3508,7 @@ ENDREM } } $renamelink=(<$lt{'rn'} +$lt{'rn'} ENDREN $line.=(< @@ -3691,7 +3648,7 @@ $form_common."\n". $form_param."\n". $form_common."\n". ''. -$form_end; +$form_end; } } elsif ($supplementalflag && !$allowed) { $url .= ($url =~ /\?/) ? '&':'?'; @@ -3866,7 +3823,6 @@ sub new_timebased_suffix { if ($type eq 'paste') { $prefix = $type; $namespace = 'courseeditor'; - $idtype = 'addcode'; } elsif ($type eq 'map') { $prefix = 'docs'; if ($area eq 'supplemental') { @@ -3878,8 +3834,9 @@ sub new_timebased_suffix { $prefix = $type; $namespace = 'templated'; } + $idtype = 'concat'; my ($suffix,$freedlock,$error) = - &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype); + &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num); if (!$suffix) { if ($type eq 'paste') { $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.'); @@ -3895,23 +3852,13 @@ sub new_timebased_suffix { } } if ($freedlock ne 'ok') { - $locknotfreed = + $locknotfreed = '
    '. &mt('There was a problem removing a lockfile.').' '; if ($type eq 'paste') { - if ($freedlock eq 'nolock') { - $locknotfreed = - '
    '. - &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '. - - &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.'); - } else { - $locknotfreed .= - &mt('This will prevent addition of items to the clipboard until your next log-in.'); - } + &mt('This will prevent use of the paste buffer until th next log-in.'); } elsif ($type eq 'map') { - $locknotfreed .= - &mt('This will prevent creation of additional folders or composite pages in this course.'); + &mt('This will prevent creation of additional folders or composite pages in this course.'); } elsif ($type eq 'smppg') { $locknotfreed .= &mt('This will prevent creation of additional simple pages in this course.'); @@ -4304,7 +4251,7 @@ ENDHEADERS return; } $r->print( - ''. + ''. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). ''.&mt('Resources').''. @@ -4347,9 +4294,9 @@ ENDHEADERS $setversions{$linkurl}, 'set_version_'.$linkurl, {'select_form_order' => ['',1..$currentversion,'mostrecent'], - '' => '', - 'mostrecent' => &mt('most recent'), - map {$_,$_} (1..$currentversion)})); + '' => '', + 'mostrecent' => &mt('most recent'), + map {$_,$_} (1..$currentversion)})); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -4486,6 +4433,7 @@ sub startContentScreen { if (($mode eq 'navmaps') || ($mode eq 'supplemental')) { $output .= '    '.&mt('Content Overview').'    '."\n"; $output .= '     '.&mt('Content Search').'     '."\n"; + $output .= '      '.&mt('Content Index').'      '."\n"; $output .= '
  • '.&mt('Supplemental Content').'
  • '; } else { $output .= '
  •       '.&mt('Main Content Editor').'      
  • '."\n"; @@ -4556,8 +4504,12 @@ sub handler { $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); } - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); - if ($allowed && $env{'form.verify'}) { + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver', + 'inhibitmenu']); + if ($allowed && $env{'form.chooseserver'}) { + &choose_dump_server($r); + return OK; + } elsif ($allowed && $env{'form.verify'}) { &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content'); &verifycontent($r); } elsif ($allowed && $env{'form.listsymbs'}) { @@ -4883,7 +4835,7 @@ sub handler { 'navc' => 'Table of Contents', 'sipa' => 'Simple Course Page', 'sipr' => 'Simple Problem', - 'webp' => 'Blank Web Page (editable)', + 'webp' => 'Blank Web Page (editable)', 'drbx' => 'Drop Box', 'scuf' => 'External Scores (handgrade, upload, clicker)', 'bull' => 'Discussion Board', @@ -4905,39 +4857,7 @@ sub handler { 'webctce4' => 'WebCT 4 Campus Edition', ); # ----------------------------------------------------------------------------- - # Calculate free quota space for a user or course. - my $quotatype = 'unofficial'; - if ($crstype eq 'Community') { - $quotatype = 'community'; - } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { - $quotatype = 'official'; - } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { - $quotatype = 'textbook'; - } - my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom, - 'course',$quotatype); # expressed in MB - my $current_disk_usage = 0; - foreach my $subdir ('docs','supplemental') { - $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum, - "userfiles/$subdir",1); # expressed in kB - } - my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage); - my $usage = $current_disk_usage/1024; # in MB - my $quota = $disk_quota; - my $percent; - if ($disk_quota == 0) { - $percent = 100.0; - } else { - $percent = 100*($current_disk_usage/$disk_quota); - } - $usage = sprintf("%.2f",$usage); - $quota = sprintf("%.2f",$quota); - $percent = sprintf("%.0f",$percent); - my $quotainfo = '

    '.&mt('Currently using [_1] of the [_2] available.', - $percent.'%',$quota.' MB').'

    '; - my $fileupload=(< FIUP @@ -5463,8 +5383,8 @@ my %suporderhash = ( } &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); undef($suppchanges); - } - } + } + } } } elsif ($supplementalflag) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, @@ -5542,7 +5462,7 @@ sub decompression_info { my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; my $container='sequence'; my ($pathitem,$hiddenelem); - my @hiddens = ('newidx','comment','position','folderpath','archiveurl'); + my @hiddens = ('newidx','comment','position','folderpath'); if ($env{'form.folderpath'} =~ /\:1$/) { $container='page'; } @@ -5550,7 +5470,7 @@ sub decompression_info { foreach my $item (@hiddens) { if ($env{'form.'.$item}) { $hiddenelem .= ''."\n"; + $env{'form.'.$item}.'" />'."\n"; } } return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container, @@ -5607,34 +5527,25 @@ sub remove_archive { } else { $delwarning = &mt('An error occurred retrieving the contents of the current folder.'); } - $delwarning .= ' '.&mt('As a result the archive file has not been removed.'); + $delwarning .= &mt('As a result the archive file has not been removed.'); } else { my $currcmd = $env{'form.cmd'}; my $position = $env{'form.position'}; - my $archiveidx = $position; if ($position > 0) { - if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) { - $archiveidx = $position-1; - } - $env{'form.cmd'} = 'remove_'.$archiveidx; - my ($title,$url,@rrest) = - split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]); - if ($url eq $env{'form.archiveurl'}) { - if (&handle_edit_cmd($docuname,$docudom)) { - ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1); - if ($fatal) { - if ($container eq 'page') { - $delwarning = &mt('An error occurred updating the contents of the current page.'); - } else { - $delwarning = &mt('An error occurred updating the contents of the current folder.'); - } + $env{'form.cmd'} = 'remove_'.$position; + my ($title,$url,@rrest) = + split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]); + if (&handle_edit_cmd($docuname,$docudom)) { + ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1); + if ($fatal) { + if ($container eq 'page') { + $delwarning = &mt('An error occurred updating the contents of the current page.'); } else { - $delresult = &mt('Archive file removed.'); + $delwarning = &mt('An error occurred updating the contents of the current folder.'); } + } else { + $delresult = &mt('Archive file removed.'); } - } else { - $delwarning .= &mt('Archive file had unexpected item number in folder.'). - ' '.&mt('As a result the archive file has not been removed.'); } } $env{'form.cmd'} = $currcmd; @@ -5837,7 +5748,7 @@ END sub editing_js { my ($udom,$uname,$supplementalflag) = @_; - my %js_lt = &Apache::lonlocal::texthash( + my %lt = &Apache::lonlocal::texthash( p_mnf => 'Name of New Folder', t_mnf => 'New Folder', p_mnp => 'Name of New Page', @@ -5847,25 +5758,23 @@ sub editing_js { p_msb => 'Title for the Problem', p_mdb => 'Title for the Drop Box', p_mbb => 'Title for the Discussion Board', - p_mwp => 'Title for Web Page', + p_mwp => 'Title for Web Page', p_mab => "Enter user:domain for User's Personal Information Page", p_mab2 => 'Personal Information Page of ', p_mab_alrt1 => 'Not a valid user:domain', p_mab_alrt2 => 'Please enter both user and domain in the format user:domain', p_chn => 'New Title', p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!', - p_rmr2a => 'Remove', - p_rmr2b => '?', - p_rmr3a => 'Remove those', - p_rmr3b => 'items?', - p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".', - p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.', + p_rmr2a => 'Remove[_99]', + p_rmr2b => '?[_99]', + p_rmr3a => 'Remove those [_2]', + p_rmr3b => 'items?[_2]', p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!', p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.', - p_ctr2a => 'Cut', - p_ctr2b => '?', - p_ctr3a => 'Cut those', - p_ctr3b => 'items?', + p_ctr2a => 'Cut[_98]', + p_ctr2b => '?[_98]', + p_ctr3a => 'Cut those[_2]', + p_ctr3b => 'items?[_2]', 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', @@ -5878,7 +5787,6 @@ sub editing_js { noac => 'No actions selected.', ); - &js_escape(\%js_lt); my $crstype = &Apache::loncommon::course_type(); my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); my $main_container_page; @@ -5900,7 +5808,6 @@ sub editing_js { if (&Apache::lonnet::is_on_map($res)) { $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='. &HTML::Entities::encode($caller,'<>&"'); - $backtourl = &Apache::loncommon::escape_single($backtourl); } else { $backtourl = '/adm/navmaps'; } @@ -5923,7 +5830,7 @@ sub editing_js { return <$js_lt{'more'}'; + document.getElementById('more'+caller).innerHTML = '  $lt{'more'}'; } else { document.getElementById('more'+caller).innerHTML = ''; } @@ -6500,10 +6393,10 @@ function togglePick(caller,value) { function toggleCheckUncheck(caller,more) { if (more == 1) { - document.getElementById('more'+caller).innerHTML = '  $js_lt{'less'}'; + document.getElementById('more'+caller).innerHTML = '  $lt{'less'}'; document.getElementById('allfields'+caller).style.display='block'; } else { - document.getElementById('more'+caller).innerHTML = '  $js_lt{'more'}'; + document.getElementById('more'+caller).innerHTML = '  $lt{'more'}'; document.getElementById('allfields'+caller).style.display='none'; } resize_scrollbox('contentscroll','1','1'); @@ -6545,7 +6438,6 @@ function checkSubmits() { var doactions = multiActions(); var cutwarnings = 0; var remwarnings = 0; - var removalinfo = 0; if (doactions == 1) { var remidxlist = document.cumulativeactions.allremoveidx.value; if ((remidxlist != '') && (remidxlist != null)) { @@ -6560,11 +6452,6 @@ function checkSubmits() { remwarnings ++; } } - if (document.getElementById('confirm_removal_'+remidxs[i])) { - if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) { - removalinfo ++; - } - } } } } @@ -6663,19 +6550,14 @@ function checkSubmits() { } if (doactions == 1) { if (numchanges > 0) { - if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) { + if ((cutwarnings > 0) || (remwarnings > 0)) { if (remwarnings > 0) { - if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) { - return false; - } - } - if (removalinfo > 0) { - if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) { + if (!confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr3a"} '+remwarnings+' $lt{"p_rmr3b"}')) { return false; } } if (cutwarnings > 0) { - if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) { + if (!confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr3a"} '+cutwarnings+' $lt{"p_ctr3b"}')) { return false; } } @@ -6691,12 +6573,12 @@ function checkSubmits() { } } if ((dosettings == 1) && (doactions == 1)) { - alert("$js_lt{'noor'}"); + alert("$lt{'noor'}"); } else { if (dosettings == 1) { - alert("$js_lt{'noch'}"); + alert("$lt{'noch'}"); } else { - alert("$js_lt{'noac'}"); + alert("$lt{'noac'}"); } } return false; @@ -6811,19 +6693,13 @@ ENDINJECT sub dump_switchserver_js { my @hosts = @_; - my %js_lt = &Apache::lonlocal::texthash( + my %lt = &Apache::lonlocal::texthash( dump => 'Copying content to Authoring Space requires switching server.', swit => 'Switch server?', - ); - my %html_js_lt = &Apache::lonlocal::texthash( - swit => 'Switch server?', duco => 'Copying Content to Authoring Space', yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.', chos => 'Choose server', ); - &js_escape(\%js_lt); - &html_escape(\%html_js_lt); - &js_escape(\%html_js_lt); my $role = $env{'request.role'}; my $js = <<"ENDSWJS";