Diff for /loncom/interface/londocs.pm between versions 1.484.2.48 and 1.578

version 1.484.2.48, 2013/12/31 15:20:31 version 1.578, 2014/03/09 15:49:48
Line 46  use Apache::lonsimplepage(); Line 46  use Apache::lonsimplepage();
 use HTML::Entities;  use HTML::Entities;
 use HTML::TokeParser;  use HTML::TokeParser;
 use GDBM_File;  use GDBM_File;
   use File::MMagic;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Cwd;  use Cwd;
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
Line 195  ENDJS Line 196  ENDJS
         } else {          } else {
             &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,              &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
                                                                    'dumpdocs',$cdom,$cnum);                                                                     'dumpdocs',$cdom,$cnum);
         }   }
         my @todump = &Apache::loncommon::get_env_multiple('form.archive');          my @todump = &Apache::loncommon::get_env_multiple('form.archive');
         my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,          my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
             %newcontent,%has_simpleprobs);              %newcontent,%has_simpleprobs);
Line 206  ENDJS Line 207  ENDJS
                 if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {                  if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
                     $tocopy{$1} = $name;                      $tocopy{$1} = $name;
                     $display{$item} = $1;                      $display{$item} = $1;
                     $lookup{$1} = $item;                      $lookup{$1} = $item; 
                 } elsif ($res eq 'lib/templates/simpleproblem.problem') {                  } elsif ($res eq 'lib/templates/simpleproblem.problem') {
                     $simpleproblems{$item} = {                      $simpleproblems{$item} = {
                                                 symb => $resources{$item},                                                  symb => $resources{$item},
Line 301  ENDJS Line 302  ENDJS
                 if ($contents{content}) {                  if ($contents{content}) {
                     $content .= '                      $content .= '
 <div class="LC_Box">  <div class="LC_Box">
 <h4 class="LC_hcell">Content</h4>'.  <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
 $contents{content}.'  $contents{content}.'
 </div>';  </div>';
                 }                  }
                 if ($contents{webreferences}) {                  if ($contents{webreferences}) {
                     $content .= '                      $content .= ' 
 <div class="LC_Box">  <div class="LC_Box">
 <h4 class="LC_hcell">Web References</h4>'.  <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
 $contents{webreferences}.'  $contents{webreferences}.'
 </div>';  </div>';
                 }                  }
Line 316  $contents{webreferences}.' Line 317  $contents{webreferences}.'
 </body>  </body>
 </html>  </html>
 ';  ';
                 $newcontent{'/'.$simplepages{$item}{res}} = $content;                  $newcontent{'/'.$simplepages{$item}{res}} = $content; 
             }              }
         }          }
         foreach my $item (keys(%tocopy)) {   foreach my $item (keys(%tocopy)) {
             unless ($item=~/\.(sequence|page)$/) {              unless ($item=~/\.(sequence|page)$/) {
                 my $currurlpath = $prefix.$item;                  my $currurlpath = $prefix.$item;
                 my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);                  my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
Line 350  $contents{webreferences}.' Line 351  $contents{webreferences}.'
                 if ($simpleproblems{$num}) {                  if ($simpleproblems{$num}) {
                     $newfilename=$title.'/'.$simpleproblems{$num}{'name'};                      $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
                 } else {                  } else {
                     $newfilename=$title.'/'.$replacehash{$item};              $newfilename=$title.'/'.$replacehash{$item};
                 }                  }
                 $newfilename=~s/\.(\w+)$//;          $newfilename=~s/\.(\w+)$//;
                my $ext=$1;          my $ext=$1;
                 $newfilename=&clean($newfilename);          $newfilename=&clean($newfilename);
                 $newfilename.='.'.$ext;          $newfilename.='.'.$ext;
                 my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});                  my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); 
                 if ($newrelpath ne $replacehash{$item}) {                  if ($newrelpath ne $replacehash{$item}) {
                     $replacehash{$item} = $newrelpath;                      $replacehash{$item} = $newrelpath;
                 }                  }
                 my @dirs=split(/\//,$newfilename);          my @dirs=split(/\//,$newfilename);
                 my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";          my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
                 my $makepath=$path;          my $makepath=$path;
                 my $fail;          my $fail;
                 my $origin;                  my $origin;
                 for (my $i=0;$i<$#dirs;$i++) {          for (my $i=0;$i<$#dirs;$i++) {
                     $makepath.='/'.$dirs[$i];      $makepath.='/'.$dirs[$i];
                     unless (-e $makepath) {      unless (-e $makepath) {
                         unless(mkdir($makepath,0755)) {          unless(mkdir($makepath,0755)) { 
                             $fail = &mt('Directory creation failed.');                              $fail = &mt('Directory creation failed.');
                         }                          }
                     }      }
                 }          }
                 if ($i == 0) {                  if ($i == 0) {
                     $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';              $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
                 } else {                  } else {
                     $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.                      $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
                                   '<span class="LC_fontsize_small" style="font-weight: bold;">'.                                    '<span class="LC_fontsize_small" style="font-weight: bold;">'.
                                   &mt('(dependency)').'</span>: ';                                    &mt('(dependency)').'</span>: ';
                 }                  }
                 if (-e $path.'/'.$newfilename) {                  if (-e $path.'/'.$newfilename) {
                     $fail = &mt('Destination already exists -- not overwriting.');                      $fail = &mt('Destination already exists -- not overwriting.'); 
                 } else {          } else {
                     if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {                      if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
                         if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||                          if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
                             ($item =~ /^simpleproblem_/)) {                              ($item =~ /^simpleproblem_/)) {
Line 404  $contents{webreferences}.' Line 405  $contents{webreferences}.'
                                         while (my $token = $parser->get_token) {                                          while (my $token = $parser->get_token) {
                                             if ($token->[0] eq 'S') {                                              if ($token->[0] eq 'S') {
                                                 if (($token->[1] eq 'resource') &&                                                  if (($token->[1] eq 'resource') &&
                                                     ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&                                                      ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && 
                                                     ($changes{$token->[2]->{'id'}})) {                                                      ($changes{$token->[2]->{'id'}})) {
                                                     my $id = $token->[2]->{'id'};                                                      my $id = $token->[2]->{'id'};
                                                     $updatedcontent .= '<'.$token->[1];                                                      $updatedcontent .= '<'.$token->[1];
                                                     foreach my $attrib (@{$token->[3]}) {                                                      foreach my $attrib (@{$token->[3]}) {
                                                        next unless ($attrib =~ /^(src|type|title|id)$/);                                                          next unless ($attrib =~ /^(src|type|title|id)$/);
                                                         if ($attrib eq 'src') {                                                          if ($attrib eq 'src') {
                                                             my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);                                                              my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); 
                                                             if ($file) {                                                              if ($file) {
                                                                 $updatedcontent .= ' '.$attrib.'="'.$file.'"';                                                                  $updatedcontent .= ' '.$attrib.'="'.$file.'"';
                                                             } else {                                                              } else {
                                                                 $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';                                                                  $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; 
                                                             }                                                              }
                                                         } else {                                                          } else {
                                                             $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';                                                              $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
Line 430  $contents{webreferences}.' Line 431  $contents{webreferences}.'
                                              }                                               }
                                          }                                           }
                                          print $fh $updatedcontent;                                           print $fh $updatedcontent;
                                     } else {                                      } else {  
                                         print $fh &Apache::lonclonecourse::rewritefile(                          print $fh &Apache::lonclonecourse::rewritefile(
                      &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),                       &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
                                                       (%replacehash,$crs => '')                                        (%replacehash,$crs => '')
                                                                                       );                                );
                                     }                                      }
                                 } else {                                  } else {
                                     print $fh                      print $fh
                                         &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);                                          &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
                                 }                  }
                             } else {                              } else {
                                 $fail = &mt('Source does not exist.');                                  $fail = &mt('Source does not exist.');  
                             }                              }
                         }                          }
                         $fh->close();                          $fh->close();
                     } else {              } else {
                         $fail = &mt('Could not write to destination.');          $fail = &mt('Could not write to destination.');
                     }                      }
                 }          }
                 my $text;                  my $text;
                 if ($fail) {          if ($fail) {
                     $text = '<span class="LC_error">'.&mt('fail').('&nbsp;'x3).$fail.'</span>';                      $text = '<span class="LC_error">'.&mt('fail').('&nbsp;'x3).$fail.'</span>';
                 } else {          } else {
                     $text = '<span class="LC_success">'.&mt('ok').'</span>';                      $text = '<span class="LC_success">'.&mt('ok').'</span>';
                 }                  }
                 if ($i == 0) {                  if ($i == 0) {
                     $result .= $text;                      $result .= $text;
                 } else {                  } else {
                     $depresult .= $text.'</li>';                      $depresult .= $text.'</li>';
                 }          }
             }              }
             $r->print($result);              $r->print($result);
             if ($depresult) {              if ($depresult) {
Line 476  $contents{webreferences}.' Line 477  $contents{webreferences}.'
             $r->rflush();              $r->rflush();
             my ($preamble,$formname);              my ($preamble,$formname);
             $formname = 'dumpdoc';              $formname = 'dumpdoc';
             unless ($home==1) {      unless ($home==1) {
                 $preamble = '<div class="LC_left_float">'.          $preamble = '<div class="LC_left_float">'.
                             '<fieldset><legend>'.              '<fieldset><legend>'.
                             &mt('Select the Authoring Space').                              &mt('Select the Authoring Space').
                             '</legend><select name="authorspace">';                              '</legend><select name="authorspace">';
             }      }
             my @orderspaces = ();              my @orderspaces = ();
             foreach my $key (sort(keys(%outhash))) {      foreach my $key (sort(keys(%outhash))) {
                 if ($key=~/^home_(.+)$/) {                  if ($key=~/^home_(.+)$/) {
                     if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {                      if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
                         unshift(@orderspaces,$1);                          unshift(@orderspaces,$1);
                     } else {                      } else {
                         push(@orderspaces,$1);                          push(@orderspaces,$1);
                     }                      }
                 }                  } 
             }              }
             if ($home>1) {              if ($home>1) {
                 $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';                  $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
             }              }
             foreach my $user (@orderspaces) {              foreach my $user (@orderspaces) {
                 if ($home==1) {   if ($home==1) {
                     $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';      $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
                 } else {   } else {
                     $preamble .= '<option value="'.$user.'">'.$user.' - '.      $preamble .= '<option value="'.$user.'">'.$user.' - '.
                                  &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';           &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
                 }          }
             }      }
             unless ($home==1) {      unless ($home==1) {
                 $preamble .= '</select></fieldset></div>'."\n";          $preamble .= '</select></fieldset></div>'."\n";
             }      }
             my $title=$origcrsdata{'description'};      my $title=$origcrsdata{'description'};
             $title=~s/[\/\s]+/\_/gs;      $title=~s/[\/\s]+/\_/gs;
             $title=&clean($title);      $title=&clean($title);
             $preamble .= '<div class="LC_left_float">'.      $preamble .= '<div class="LC_left_float">'.
                          '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.                           '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
                          '<input type="text" size="50" name="authorfolder" value="'.                           '<input type="text" size="50" name="authorfolder" value="'.
                          $title.'" />'.                           $title.'" />'.
                          '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";                           '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
             my %uploadedfiles;              my %uploadedfiles;
             &tiehash();      &tiehash();
             foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {      foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
                 my ($ext)=($file=~/\.(\w+)$/);          my ($ext)=($file=~/\.(\w+)$/);
 # FIXME Check supplemental here  # FIXME Check supplemental here
                 my $title=$hash{'title_'.$hash{          my $title=$hash{'title_'.$hash{
                                 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};                  'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
                 if (!$title) {          if (!$title) {
                     $title=$file;      $title=$file;
                 } else {          } else {
                     $title=~s|/|_|g;      $title=~s|/|_|g;
                 }          }
                 $title=~s/\.(\w+)$//;          $title=~s/\.(\w+)$//;
                 $title=&clean($title);          $title=&clean($title);
                 $title.='.'.$ext;          $title.='.'.$ext;
 #           $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"  #    $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
                 $uploadedfiles{$file} = $title;                  $uploadedfiles{$file} = $title;
             }      }
             &untiehash();      &untiehash();
             $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,              $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
                                                                  undef,undef,$preamble,$home,\%uploadedfiles));                                                                   undef,undef,$preamble,$home,\%uploadedfiles));
         }          }
Line 563  sub recurse_html { Line 564  sub recurse_html {
                 } else {                  } else {
                     $relfile = $dependency;                      $relfile = $dependency;
                     $depurl = $currurlpath;                      $depurl = $currurlpath;
                     $depurl =~ s{[^/]+$}{};                       $depurl =~ s{[^/]+$}{};  
                     $depurl .= $dependency;                      $depurl .= $dependency;
                     ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});                      ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); 
                 }                  }
                 next if ($relfile eq '');                  next if ($relfile eq '');
                 my $newname = $replacehash->{$container};                  my $newname = $replacehash->{$container};
                 $newname =~ s{[^/]+$}{};                  $newname =~ s{[^/]+$}{};
                 $replacehash->{$newcontainer} = $newname.$relfile;                  $replacehash->{$newcontainer} = $newname.$relfile;
                 $deps->{$item}{$newcontainer} = 1;                  $deps->{$item}{$newcontainer} = 1;
                 my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});                  my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});  
                 my $depfile = &Apache::lonnet::filelocation('',$depurl);                  my $depfile = &Apache::lonnet::filelocation('',$depurl);
                 my $type = $mm->checktype_filename($depfile);                  my $type = $mm->checktype_filename($depfile);
                 if ($type eq 'text/html') {                  if ($type eq 'text/html') {
Line 666  $initialtext Line 667  $initialtext
 </html>  </html>
 END  END
                 $env{'form.output'}=$newhtml;                  $env{'form.output'}=$newhtml;
                 my $result =                  my $result = 
                     &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,                      &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                                                           'output',                                                            'output',
                                                           "$filepath/$residx/$fname.html");                                                            "$filepath/$residx/$fname.html");
Line 691  END Line 692  END
                           removefrommap => \%removefrommap,                            removefrommap => \%removefrommap,
                           removeparam   => \%removeparam,                            removeparam   => \%removeparam,
                       );                        );
         my ($result,$msgsarray,$lockerror) =          my ($result,$msgsarray,$lockerror) = 
             &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);              &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
         if (keys(%import_errors) > 0) {          if (keys(%import_errors) > 0) {
             $fixuperrors =              $fixuperrors =
Line 1087  sub update_paste_buffer { Line 1088  sub update_paste_buffer {
     }      }
     &Apache::lonnet::appenv(\%addtoenv);      &Apache::lonnet::appenv(\%addtoenv);
     delete($env{'form.markcopy'});      delete($env{'form.markcopy'});
       return;
 }  }
   
 sub recurse_uploaded_maps {  sub recurse_uploaded_maps {
Line 1230  sub print_paste_buffer { Line 1232  sub print_paste_buffer {
             my $value = &mt('Paste to current folder');              my $value = &mt('Paste to current folder');
             if ($container eq 'page') {              if ($container eq 'page') {
                 $value = &mt('Paste to current page');                  $value = &mt('Paste to current page');
             }              } 
             $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.('&nbsp;'x2);              $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.('&nbsp;'x2);
         }          }
         $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'.('&nbsp;'x2);          $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.('&nbsp;'x2);
         if ($clipboardcount > 1) {          if ($clipboardcount > 1) {
             $buttons .=              $buttons .=
                 '<span style="text-decoration:line-through">'.('&nbsp;'x20).'</span>'.('&nbsp;'x2).                  '<span style="text-decoration:line-through">'.('&nbsp;'x20).'</span>'.('&nbsp;'x2).
Line 1401  function checkClipboard() { Line 1403  function checkClipboard() {
     if (document.pasteform.pasting.length > 1) {      if (document.pasteform.pasting.length > 1) {
         for (var i=0; i<document.pasteform.pasting.length; i++) {          for (var i=0; i<document.pasteform.pasting.length; i++) {
             document.pasteform.pasting[i].checked = true;              document.pasteform.pasting[i].checked = true;
         }          } 
     }      }
     return;      return;
 }  }
Line 1661  sub do_paste_from_buffer { Line 1663  sub do_paste_from_buffer {
                     next;                      next;
         }          }
                 if ($lockerr{$prefix}) {                  if ($lockerr{$prefix}) {
                     $lockerrs{$suffix} = $lockerr{$prefix};                      $lockerrs{$suffix} = $lockerr{$prefix};  
                 }                  }
             }              }
         }          }
Line 1700  sub do_paste_from_buffer { Line 1702  sub do_paste_from_buffer {
                     if ($newdocsdir eq '') {                      if ($newdocsdir eq '') {
                         $newdocsdir = 'default';                          $newdocsdir = 'default';
                     }                      }
                     if (($prefixchg{$suffix}) ||                      if (($prefixchg{$suffix}) || 
                         ($srcdom{$suffix} ne $coursedom) ||                           ($srcdom{$suffix} ne $coursedom) || 
                         ($srcnum{$suffix} ne $coursenum) ||                          ($srcnum{$suffix} ne $coursenum) ||
                         ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {                          ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
Line 1907  sub dbcopy { Line 1909  sub dbcopy {
     if (ref($dbref) eq 'HASH') {      if (ref($dbref) eq 'HASH') {
         if ($url =~ m{/(smppg|bulletinboard)$}) {          if ($url =~ m{/(smppg|bulletinboard)$}) {
             my $prefix = $1;              my $prefix = $1;
             if (($dbref->{'cdom'} =~ /^$match_domain$/) &&              if (($dbref->{'cdom'} =~ /^$match_domain$/) && 
                 ($dbref->{'cnum'} =~ /^$match_courseid$/)) {                  ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
                 my $db_name;                  my $db_name;
                 my $marker = (split(m{/},$url))[4];                  my $marker = (split(m{/},$url))[4];
Line 1942  sub dbcopy { Line 1944  sub dbcopy {
                         my $photo = $contents{'uploaded.photourl'};                          my $photo = $contents{'uploaded.photourl'};
                         my ($subdir,$fname) =                          my ($subdir,$fname) =
                             ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});                              ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
                         my $newphoto;                          my $newphoto; 
                         if ($fname ne '') {                          if ($fname ne '') {
                             my $content = &Apache::lonnet::getfile($photo);                              my $content = &Apache::lonnet::getfile($photo);
                             unless ($content eq '-1') {                              unless ($content eq '-1') {
                                 $env{'form.'.$suffix.'.photourl'} = $content;                                  $env{'form.'.$suffix.'.photourl'} = $content;
                                 $newphoto =                                  $newphoto = 
                                     &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");                                      &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
                                 delete($env{'form.'.$suffix.'.photourl'});                                  delete($env{'form.'.$suffix.'.photourl'});
                             }                              }
Line 2092  sub url_paste_fixups { Line 2094  sub url_paste_fixups {
             }              }
             next if ($token->[2]->{'type'} eq 'external');              next if ($token->[2]->{'type'} eq 'external');
             if ($token->[2]->{'type'} eq 'zombie') {              if ($token->[2]->{'type'} eq 'zombie') {
                 next if ($skip);                  next if ($skip);  
                 $zombies->{$oldurl}{$id} = $ressrc;                  $zombies->{$oldurl}{$id} = $ressrc;
                 $changed = 1;                  $changed = 1;
             } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {              } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
Line 2538  sub update_parameter { Line 2540  sub update_parameter {
                          'randomorder'    => {},                           'randomorder'    => {},
                       );                        );
         foreach my $which (keys(%allchecked)) {          foreach my $which (keys(%allchecked)) {
             $env{'form.all'.$which} =~ s/,$//;              $env{'form.all'.$which} =~ s/,$//;   
             if ($which eq 'randompick') {              if ($which eq 'randompick') {
                 foreach my $item (split(/,/,$env{'form.all'.$which})) {                  foreach my $item (split(/,/,$env{'form.all'.$which})) {
                     my ($res,$value) = split(/:/,$item);                      my ($res,$value) = split(/:/,$item);
Line 2565  sub update_parameter { Line 2567  sub update_parameter {
             foreach my $which (keys(%allchecked)) {              foreach my $which (keys(%allchecked)) {
                 if (($which eq 'randompick' || $which eq 'randomorder')) {                  if (($which eq 'randompick' || $which eq 'randomorder')) {
                     next if (!$is_map);                      next if (!$is_map);
                 }                  } 
                 my $oldvalue = 0;                  my $oldvalue = 0;
                 my $newvalue = 0;                  my $newvalue = 0;
                 if ($allchecked{$which}{$res}) {                  if ($allchecked{$which}{$res}) {
Line 3024  sub editor { Line 3026  sub editor {
                     if (@allidx > 0) {                      if (@allidx > 0) {
                         my $path;                          my $path;
                         if ($env{'form.folderpath'}) {                          if ($env{'form.folderpath'}) {
                             $path =                              $path = 
                                 &HTML::Entities::encode($env{'form.folderpath'},'<>&"');                                  &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
                         }                          }
                         if (@allidx > 1) {                          if (@allidx > 1) {
                             $to_show .=                              $to_show .= 
                                 &Apache::loncommon::continue_data_table_row().                                  &Apache::loncommon::continue_data_table_row().
                                 '<td colspan="2">&nbsp;</td>'.                                  '<td colspan="2">&nbsp;</td>'.
                                 '<td>'.                                  '<td>'.
Line 3172  sub process_file_upload { Line 3174  sub process_file_upload {
     }      }
     my $quotatype = 'unofficial';      my $quotatype = 'unofficial';
     if ($crstype eq 'Community') {      if ($crstype eq 'Community') {
         $quotatype = 'community';          $quotatype = 'community';    
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
         $quotatype = 'official';          $quotatype = 'official';
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
Line 3279  sub process_file_upload { Line 3281  sub process_file_upload {
                     $$upload_output .= &mt('No embedded items identified').'<br />';                      $$upload_output .= &mt('No embedded items identified').'<br />';
                 }                  }
                 $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';                  $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
             } elsif (&Apache::loncommon::is_archive_file($mimetype)) {              } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
                        ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
                 $nextphase = 'decompress_uploaded';                  $nextphase = 'decompress_uploaded';
                 my $position = scalar(@LONCAPA::map::order)-1;                  my $position = scalar(@LONCAPA::map::order)-1;
                 my $noextract = &return_to_editor();                  my $noextract = &return_to_editor();
Line 3354  sub entryline { Line 3357  sub entryline {
   
     $renametitle=~s/\\/\\\\/g;      $renametitle=~s/\\/\\\\/g;
     $renametitle=~s/\&quot\;/\\\"/g;      $renametitle=~s/\&quot\;/\\\"/g;
       $renametitle=~s/\&#39;/\\\'/g;
     $renametitle=~s/ /%20/g;      $renametitle=~s/ /%20/g;
     my $line=&Apache::loncommon::start_data_table_row();      my $line=&Apache::loncommon::start_data_table_row();
     my ($form_start,$form_end,$form_common,$form_param);      my ($form_start,$form_end,$form_common,$form_param);
Line 3644  $form_common."\n". Line 3648  $form_common."\n".
 $form_param."\n".  $form_param."\n".
 $form_common."\n".  $form_common."\n".
 '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.  '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.
 $form_end;  $form_end; 
         }          }
     } elsif ($supplementalflag && !$allowed) {      } elsif ($supplementalflag && !$allowed) {
         $url .= ($url =~ /\?/) ? '&amp;':'?';          $url .= ($url =~ /\?/) ? '&amp;':'?';
Line 3848  sub new_timebased_suffix { Line 3852  sub new_timebased_suffix {
         }          }
     }      }
     if ($freedlock ne 'ok') {      if ($freedlock ne 'ok') {
         $locknotfreed =          $locknotfreed = 
             '<div class="LC_error">'.              '<div class="LC_error">'.
             &mt('There was a problem removing a lockfile.').' ';              &mt('There was a problem removing a lockfile.').' ';
         if ($type eq 'paste') {          if ($type eq 'paste') {
Line 4247  ENDHEADERS Line 4251  ENDHEADERS
         return;          return;
     }      }
     $r->print(      $r->print(
         '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.         '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
         &Apache::loncommon::start_data_table().          &Apache::loncommon::start_data_table().
         &Apache::loncommon::start_data_table_header_row().          &Apache::loncommon::start_data_table_header_row().
         '<th>'.&mt('Resources').'</th>'.          '<th>'.&mt('Resources').'</th>'.
Line 4290  ENDHEADERS Line 4294  ENDHEADERS
                       $setversions{$linkurl},                        $setversions{$linkurl},
                       'set_version_'.$linkurl,                        'set_version_'.$linkurl,
                       {'select_form_order' => ['',1..$currentversion,'mostrecent'],                        {'select_form_order' => ['',1..$currentversion,'mostrecent'],
                        '' => '',                        '' => '',
                        'mostrecent' => &mt('most recent'),                        'mostrecent' => &mt('most recent'),
                        map {$_,$_} (1..$currentversion)}));                        map {$_,$_} (1..$currentversion)}));
             my $lastold=1;              my $lastold=1;
             for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {              for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                 my $url=$root.'.'.$prevvers.'.'.$extension;                  my $url=$root.'.'.$prevvers.'.'.$extension;
Line 4429  sub startContentScreen { Line 4433  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>&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Overview').'&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";          $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Overview').'&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
         $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";          $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
           $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Index').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Main Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";          $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Main Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
Line 4830  sub handler { Line 4835  sub handler {
                 'navc' => 'Table of Contents',                  'navc' => 'Table of Contents',
                 'sipa' => 'Simple Course Page',                  'sipa' => 'Simple Course Page',
                 'sipr' => 'Simple Problem',                  'sipr' => 'Simple Problem',
                 'webp' => 'Blank Web Page (editable)',                  'webp' => 'Blank Web Page (editable)', 
                 'drbx' => 'Drop Box',                  'drbx' => 'Drop Box',
                 'scuf' => 'External Scores (handgrade, upload, clicker)',                  'scuf' => 'External Scores (handgrade, upload, clicker)',
                 'bull' => 'Discussion Board',                  'bull' => 'Discussion Board',
Line 4846  sub handler { Line 4851  sub handler {
                 'title' => 'Title',                  'title' => 'Title',
                 'comment' => 'Comment',                  'comment' => 'Comment',
                 'parse' => 'Upload embedded images/multimedia files if HTML file',                  'parse' => 'Upload embedded images/multimedia files if HTML file',
   );                  'bb5'      => 'Blackboard 5',
                   'bb6'      => 'Blackboard 6',
                   'angel5'   => 'ANGEL 5.5',
                   'webctce4' => 'WebCT 4 Campus Edition',
           );
 # -----------------------------------------------------------------------------  # -----------------------------------------------------------------------------
  my $fileupload=(<<FIUP);   my $fileupload=(<<FIUP);
  $lt{'file'}:<br />   $lt{'file'}:<br />
Line 4877  CHBO Line 4886  CHBO
         $lt{'cms'}:&nbsp;           $lt{'cms'}:&nbsp; 
         <select name="source">          <select name="source">
         <option value="-1" selected="selected">$lt{'se'}</option>          <option value="-1" selected="selected">$lt{'se'}</option>
         <option value="bb5">Blackboard 5</option>          <option value="bb5">$lt{'bb5'}</option>
         <option value="bb6">Blackboard 6</option>          <option value="bb6">$lt{'bb6'}</option>
         <option value="angel5">ANGEL 5.5</option>          <option value="angel5">$lt{'angel5'}</option>
         <option value="webctce4">WebCT 4 Campus Edition</option>          <option value="webctce4">$lt{'webctce4'}</option>
         </select>          </select>
         <input type="hidden" name="folder" value="$imsfolder" />          <input type="hidden" name="folder" value="$imsfolder" />
         </p>          </p>
Line 5374  my %suporderhash = ( Line 5383  my %suporderhash = (
                    }                     }
                    &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);                     &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
                    undef($suppchanges);                     undef($suppchanges);
                }                 }  
            }             } 
         }          }
     } elsif ($supplementalflag) {      } elsif ($supplementalflag) {
         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,          my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
Line 5522  sub remove_archive { Line 5531  sub remove_archive {
     } else {      } else {
         my $currcmd = $env{'form.cmd'};          my $currcmd = $env{'form.cmd'};
         my $position = $env{'form.position'};          my $position = $env{'form.position'};
         if ($position > 0) {           if ($position > 0) {
             $env{'form.cmd'} = 'remove_'.$position;              $env{'form.cmd'} = 'remove_'.$position;
             my ($title,$url,@rrest) =               my ($title,$url,@rrest) = 
                 split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);                  split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
Line 5749  sub editing_js { Line 5758  sub editing_js {
                                           p_msb => 'Title for the Problem',                                            p_msb => 'Title for the Problem',
                                           p_mdb => 'Title for the Drop Box',                                            p_mdb => 'Title for the Drop Box',
                                           p_mbb => 'Title for the Discussion Board',                                            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_mab => "Enter user:domain for User's Personal Information Page",
                                           p_mab2 => 'Personal Information Page of ',                                            p_mab2 => 'Personal Information Page of ',
                                           p_mab_alrt1 => 'Not a valid user:domain',                                            p_mab_alrt1 => 'Not a valid user:domain',
Line 5863  function makewebpage(type) { Line 5872  function makewebpage(type) {
        formname = this.document.forms.newwebpage;         formname = this.document.forms.newwebpage;
    }     }
    if (title) {     if (title) {
        var webpage = formname.importdetail.value;         var webpage = formname.importdetail.value; 
        formname.importdetail.value = escape(title)+'='+webpage;         formname.importdetail.value = escape(title)+'='+webpage;
        formname.submit();         formname.submit();
    }     }
Line 6244  for (i = 0; i < currentLis.length; i++) Line 6253  for (i = 0; i < currentLis.length; i++)
   
 function hideAll(current, nav, data) {  function hideAll(current, nav, data) {
 unselectInactive(nav);  unselectInactive(nav);
 if (current) {  if (current) { 
     if (current.className == 'right'){      if (current.className == 'right'){
  current.className = 'right active'          current.className = 'right active'
     } else {      } else {
  current.className = 'active';          current.className = 'active';
     }      }
 }  }
 currentData = document.getElementById(data);  currentData = document.getElementById(data);
Line 6286  function showPage(current, pageId, nav, Line 6295  function showPage(current, pageId, nav,
  unselectInactive(nav);   unselectInactive(nav);
         if ((currstate == 'active') || (currstate == 'right active')) {          if ((currstate == 'active') || (currstate == 'right active')) {
             if (currstate == 'active') {              if (currstate == 'active') {
                 current.className = '';          current.className = '';
             } else {              } else {
                 current.className = 'right';                  current.className = 'right';
             }              }
             activeTab = '';              activeTab = ''; 
             toggleUpload();              toggleUpload();
             toggleMap();              toggleMap();
             resize_scrollbox('contentscroll','1','0');              resize_scrollbox('contentscroll','1','0');

Removed from v.1.484.2.48  
changed lines
  Added in v.1.578


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>