Diff for /loncom/interface/londocs.pm between versions 1.712 and 1.714

version 1.712, 2024/12/20 15:15:04 version 1.714, 2024/12/27 02:32:55
Line 48  use Apache::lonpublisher(); Line 48  use Apache::lonpublisher();
 use Apache::loncourserespicker();  use Apache::loncourserespicker();
 use HTML::Entities;  use HTML::Entities;
 use HTML::TokeParser;  use HTML::TokeParser;
   use HTML::LCParser;
 use GDBM_File;  use GDBM_File;
 use File::MMagic;  use File::MMagic;
 use File::Copy;  use File::Copy;
Line 722  ENDJS Line 723  ENDJS
         $r->print(&endContentScreen());          $r->print(&endContentScreen());
         return '';          return '';
     }      }
       my $is_course_home;
       my @ids=&Apache::lonnet::current_machine_ids();
       if (($coursehome ne '') && (grep(/^\Q$coursehome\E$/,@ids))) {
           $is_course_home = 1;
       }
     my %origcrsdata=&Apache::lonnet::coursedescription($env{'request.course.id'});      my %origcrsdata=&Apache::lonnet::coursedescription($env{'request.course.id'});
     my $exclude = &Apache::lonnet::priv_exclude();      my $exclude = &Apache::lonnet::priv_exclude();
     my $srcurl = "/priv/$coursedom/$coursenum";      my $srcurl = "/priv/$coursedom/$coursenum";
Line 754  ENDJS Line 760  ENDJS
                       &endContentScreen());                        &endContentScreen());
             return '';              return '';
         }          }
         my $is_course_home;  
         my @ids=&Apache::lonnet::current_machine_ids();  
         if (($coursehome ne '') && (grep(/^\Q$coursehome\E$/,@ids))) {  
             $is_course_home = 1;  
         }  
         my (%tocopy,%dirs_to_make,%files_to_copy);          my (%tocopy,%dirs_to_make,%files_to_copy);
         map { $tocopy{&unescape($_)} = 1; } &Apache::loncommon::get_env_multiple('form.copytouser');          map { $tocopy{&unescape($_)} = 1; } &Apache::loncommon::get_env_multiple('form.copytouser');
         if (keys(%tocopy)) {          if (keys(%tocopy)) {
             my (%subdirs,%files);              my (%subdirs,%files);
             &Apache::lonnet::recursedirs($home,1,undef,$exclude,0,0,$srcurl,'',\%subdirs,\%files);              &Apache::lonnet::recursedirs($is_course_home,1,undef,$exclude,0,0,$srcurl,'',\%subdirs,\%files);
             foreach my $possible (sort(keys(%tocopy))) {              foreach my $possible (sort(keys(%tocopy))) {
                 if ($possible =~ m{/$}) {                  if ($possible =~ m{/$}) {
                     my $possdir = $possible;                      my $possdir = $possible;
Line 804  ENDJS Line 805  ENDJS
             return '';              return '';
         }          }
         if (keys(%tocopy)) {          if (keys(%tocopy)) {
             my $mm = new File::MMagic;              my (%resdirs,%resfiles);
             my ($notopdir,%newdir,%newfile);              my $resurl = "/res/$coursedom/$coursenum";
               my $res_exclude = &Apache::lonnet::res_exclude();
               &Apache::lonnet::recursedirs($is_course_home,1,undef,$res_exclude,0,0,$resurl,'',\%resdirs,\%resfiles);
               my ($notopdir,%newdir,%newfile,%checkdeps);
             $r->print('<p>'.&mt('Copy to: [_1]',              $r->print('<p>'.&mt('Copy to: [_1]',
                                 '<span class="LC_filename">'.$desturl.'/'.$subdir.'</span>').                                  '<span class="LC_filename">'.$desturl.'/'.$subdir.'</span>').
                       '</p>'."\n");                        '</p>'."\n");
             unless ($is_course_home) {  
                 $r->print('<p class="LC_info>'.&mt("Session needs to be hosted on course's home server.").  
                           '</p>'.  
                           &endContentScreen());  
                 return '';  
             }  
             if (keys(%dirs_to_make)) {              if (keys(%dirs_to_make)) {
                 if ($is_course_home) {                  unless (-e $desttop.'/'.$subdir) {
                     unless (-e $desttop.'/'.$subdir) {                      mkdir($desttop.'/'.$subdir,0755);
                         mkdir($desttop.'/'.$subdir,0755);                  }
                     }                  if (-e $desttop.'/'.$subdir) {
                     if (-e $desttop.'/'.$subdir) {                      foreach my $dir (sort(keys(%dirs_to_make))) {
                         foreach my $dir (sort(keys(%dirs_to_make))) {                          my @dirs=split(/\//,$dir);
                             my @dirs=split(/\//,$dir);                          my $path="$desttop/$subdir";
                             my $path="$desttop/$subdir";                          my $makepath=$path;
                             my $makepath=$path;                          my $fail;
                             my $fail;                          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 = 1;
                                         $fail = 1;                                      last;
                                         last;                                  }
                                     }                                  if (($i == scalar(@dirs)-1) && (!$fail))  {
                                     if (($i == scalar(@dirs)-1) && (!$fail))  {                                      $newdir{$dir} = 1;
                                         $newdir{$dir} = 1;  
                                     }  
                                 }                                  }
                             }  
                             if ($fail) {  
                                 $r->print('<p class="LC_warning">'.&mt('Target directory: [_1] does not exist, and could not be created.',  
                                                                        '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$dir.'</span>').  
                                           '</p>'."\n");  
                             }                              }
                         }                          }
                     } else {                          if ($fail) {
                         $notopdir = 1;                              $r->print('<p class="LC_warning">'.&mt('Target directory: [_1] does not exist, and could not be created.',
                                                                      '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$dir.'</span>').
                                         '</p>'."\n");
                           }
                     }                      }
                   } else {
                       $notopdir = 1;
                 }                  }
             }              }
             if (keys(%files_to_copy)) {              if (keys(%files_to_copy)) {
                 if ($is_course_home) {                  unless (-e $desttop.'/'.$subdir) {
                     unless (-e $desttop.'/'.$subdir) {                      mkdir($desttop.'/'.$subdir,0755);
                         mkdir($desttop.'/'.$subdir,0755);                  }
                     }                  if (-e $desttop.'/'.$subdir) {
                     if (-e $desttop.'/'.$subdir) {                      my $num = 0;
                         my $num = 0;                      foreach my $file (keys(%files_to_copy)) {
                         foreach my $file (keys(%files_to_copy)) {                          my ($fail,$dup,$dir_is_file,$src,$dest,$path,$fname);
                             my ($fail,$dup,$dir_is_file,$src,$dest,$path,$fname);                          if ($file =~ m{/}) {
                             if ($file =~ m{/}) {                              ($path,$fname) = ($file =~ m{^(.+)/([^/]+)$});
                                 ($path,$fname) = ($file =~ m{^(.+)/([^/]+)$});                              if (-d "$desttop/$subdir/$path") {
                                 if (-d "$desttop/$subdir/$path") {                                  if (-e "$desttop/$subdir/$path/$fname") {
                                     if (-e "$desttop/$subdir/$path/$fname") {                                      $dup = 1;
                                         $dup = 1;  
                                     } else {  
                                         $src = "$srctop/$path/$fname";  
                                         $dest = "$desttop/$subdir/$path/$fname";  
                                     }  
                                 } elsif (-f "$desttop/$subdir/$path") {  
                                     $dir_is_file = 1;  
                                 } else {                                  } else {
                                     $fail = 1;                                      $src = "$srctop/$path/$fname";
                                       $dest = "$desttop/$subdir/$path/$fname";
                                 }                                  }
                             } elsif (-e "$desttop/$subdir/$file") {                              } elsif (-f "$desttop/$subdir/$path") {
                                 $dup = 1;                                  $dir_is_file = 1;
                             } else {                              } else {
                                 $src = "$srctop/$file";                                  $fail = 1;
                                 $dest = "$desttop/$subdir/$file";  
                                 $fname = $file;  
                             }                              }
                             if ($fail) {                          } elsif (-e "$desttop/$subdir/$file") {
                                 $r->print('<p class="LC_warning">'.&mt('Target directory: [_1] does not exist, and could not be created.',                              $dup = 1;
                                                                        '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$path.'</span>').                          } else {
                                           '</p>'."\n");                              $src = "$srctop/$file";
                             } elsif ($dup) {                              $dest = "$desttop/$subdir/$file";
                                 $r->print('<p class="LC_warning">'.&mt('Target file: [_1] already exists -- not overwriting.',                              $fname = $file;
                                                                        '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$file.'</span>').                          }
                                           '</p>'."\n");                          if ($fail) {
                             } elsif ($dir_is_file) {                              $r->print('<p class="LC_warning">'.&mt('Target directory: [_1] does not exist, and could not be created.',
                                 $r->print('<p class="LC_warning">'.&mt('Target directory: [_1] name is already in a use for a file -- not overwriting.',                                                                     '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$path.'</span>').
                                                                        '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$file.'</span>').                                        '</p>'."\n");
                                           '</p>'."\n");                          } elsif ($dup) {
                             } elsif (($src ne '') && ($dest ne '')) {                              $r->print('<p class="LC_warning">'.&mt('Target file: [_1] already exists -- not overwriting.',
                                                                      '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$file.'</span>').
                                         '</p>'."\n");
                           } elsif ($dir_is_file) {
                               $r->print('<p class="LC_warning">'.&mt('Target directory: [_1] name is already in a use for a file -- not overwriting.',
                                                                      '<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$file.'</span>').
                                         '</p>'."\n");
                           } elsif (($src ne '') && ($dest ne '')) {
                               if ($is_course_home) {
                                 if (&File::Copy::copy($src,$dest)) {                                  if (&File::Copy::copy($src,$dest)) {
                                     $newfile{$file} = 1;                                      $newfile{$file} = 1;
                                   }
                               } else {
                                   if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file,$dest) eq 'ok') {
                                       $newfile{$file} = 1;
                                   }
                               }
                               if ($newfile{$file}) {
                                   my $gotmeta;
                                   if ($is_course_home) {
                                     if ((-e $src.'.meta') && (!-e $dest.'.meta')) {                                      if ((-e $src.'.meta') && (!-e $dest.'.meta')) {
                                         if (&File::Copy::copy($src.'.meta',$dest.'.meta')) {                                          if (&File::Copy::copy($src.'.meta',$dest.'.meta')) {
 #FIXME set distribution/copyright to author's default instead of custom. set author to $ca:$cd instead of $cdom:$cnum                                              $gotmeta = 1;
                                         }                                          }
                                     }                                      }
                                     my ($ext) = ($file =~ /\.(\w+)$/);                                  } else {
                                     my $embstyle=&Apache::loncommon::fileembstyle($ext);                                      if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file.'.meta',$dest.'.meta') eq 'ok') {
                                     if ($embstyle eq 'ssi') {                                          $gotmeta = 1;
 #FIXME in any src or href attributes replace /res/$coursedom/$coursenum/ with /res/$cd/$ca/$subdir                                      }
                                   }
                                   if ($gotmeta) {
                                       if (open(my $fh,'<',$dest.'.meta')) {
                                           my ($output,$now);
                                           $now = time;
                                           while (my $line=<$fh>) {
                                               chomp($line);
                                               if ($line eq "<authorspace>$coursenum:$coursedom</authorspace>") {
                                                   $output .= "<authorspace>$ca:$cd</authorspace>\n";
                                               } elsif ($line eq '<copyright>custom</copyright>') {
                                                   $output .= "<copyright>default</copyright>\n";
                                               } elsif ($line =~ m{^<creationdate>\d+</creationdate>$}) {
                                                   $output .= "<creationdate>$now</creationdate>\n";
                                               } elsif ($line eq "<customdistributionfile>/res/$coursedom/$coursenum/default.rights</customdistributionfile>") {
                                                   $output .= "<customdistributionfile></customdistributionfile>\n";
                                               } elsif ($line eq "<domain>$coursedom</domain>") {
                                                   $output .= "<domain>$cd</domain>\n";
                                               } elsif ($line =~ m{^<lastrevisiondate>\d+</lastrevisiondate>$}) {
                                                   $output .= "<lastrevisiondate>$now</lastrevisiondate>\n";
                                               } elsif ($line =~ m{^<modifyinguser>$match_username:$match_domain</modifyinguser>$}) {
                                                   $output .= "<modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser>\n";
                                               } elsif ($line eq "<owner>$coursenum:$coursedom</owner>") {
                                                   $output .= "<owner>$ca:$cd</owner>\n";
                                               } elsif ($line =~ m{^<dependencies>(.+)</dependencies>$}) {
                                                   my @deps = split(/\s*,\s*/,$1);
                                                   my @newdeps;
                                                   my $changed = 0;
                                                   foreach my $dep (@deps) {
                                                       if ($dep =~ m{^/res/$coursedom/$coursenum/(.+)$}) {
                                                           my $rest = $1;
                                                           push(@newdeps,"/res/$cd/$ca/$rest");
                                                           $checkdeps{$rest} = 1;
                                                           $changed ++;
                                                       } else {
                                                           push(@newdeps,$dep);
                                                       }
                                                   }
                                                   if ($changed) {
                                                       $output .= '<dependencies>'.join(',',@newdeps).'</dependencies>'."\n";
                                                   }
                                               } else {
                                                   $output .= "$line\n";
                                               }
                                           }
                                           close($fh);
                                           if (open(my $fh,'>',$dest.'.meta')) {
                                               print $fh $output;
                                               close($fh);
                                           }
                                       }
                                   }
                                   my ($ext) = ($file =~ /\.(\w+)$/);
                                   my $embstyle=&Apache::loncommon::fileembstyle($ext);
                                   if ($embstyle eq 'ssi') {
                                       my $outstring='';
                                       my $changes = 0;
                                       my @parser;
                                       $parser[0]=HTML::LCParser->new($dest);
                                       $parser[-1]->xml_mode(1);
                                       my $token;
                                       while (@parser) {
                                           while ($token=$parser[-1]->get_token) {
                                               if ($token->[0] eq 'S') {
                                                   my $tag=$token->[1];
                                                   my $lctag=lc($tag);
                                                   my %parms=%{$token->[2]};
                                                   foreach my $type ('src','href','background','bgimg') {
                                                       foreach my $key (keys(%parms)) {
                                                           if ($key =~ /^$type$/i) {
                                                               next if (($lctag eq 'img') && ($type eq 'src') &&
                                                                        ($parms{$key} =~ m{^data\:image/gif;base64,}));
                                                               if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
                                                                   $parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si;
                                                                   $changes ++;
                                                               }
                                                           }
                                                       }
                                                   }
                                                   # probably a <randomlabel> image type <label>
                                                   # or a <image> tag inside <imageresponse> or <drawimage>
                                                   if (($lctag eq 'label' && defined($parms{'description'}))
                                                        || ($lctag eq 'image') || ($lctag eq 'import')) {
                                                       my $next_token=$parser[-1]->get_token();
                                                       if ($next_token->[0] eq 'T') {
                                                           $next_token->[1] =~ s/[\n\r\f]+//g;
                                                           if ($next_token->[1] =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
                                                               $next_token->[1] =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si;
                                                               $changes ++;
                                                           }
                                                       }
                                                       $parser[-1]->unget_token($next_token);
                                                   }
                                                   if ($lctag eq 'applet') {
                                                       my $havecodebase=0;
                                                       foreach my $key (keys(%parms)) {
                                                           if (lc($key) eq 'codebase') {
                                                               if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
                                                                   $parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si;
                                                                   $changes ++;
                                                               }
                                                               $havecodebase = 1;
                                                           }
                                                       }
                                                       unless ($havecodebase) {
                                                           foreach my $key (keys(%parms)) {
                                                               if ($key =~ /(archive|code|object)/i) {
                                                                   if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
                                                                       $parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/si};
                                                                       $changes ++;
                                                                   }
                                                               }
                                                           }
                                                       }
                                                   }
                                                   my $newparmstring='';
                                                   my $endtag='';
                                                   foreach my $parkey (keys(%parms)) {
                                                       if ($parkey eq '/') {
                                                           $endtag=' /';
                                                       } else {
                                                           my $quote=($parms{$parkey}=~/\"/?"'":'"');
                                                           $newparmstring.=' '.$parkey.'='.$quote.$parms{$parkey}.$quote;
                                                       }
                                                   }
                                                   if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; }
                                                   $outstring.='<'.$tag.$newparmstring.$endtag.'>';
                                                   if ($lctag eq 'm' || $lctag eq 'answer' || $lctag eq 'display' ||
                                                       $lctag eq 'tex') {
                                                       $outstring.=&Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser);
                                                   } elsif ($lctag eq 'script') {
                                                       if ($parms{'type'} eq 'loncapa/perl') {
                                                           $outstring.=&Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser);
                                                       } else {
                                                           my $needsupdate;
                                                           my $script = &Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser);
                                                           if ($script =~ m{\.addMediaSrc\((["'])((?!\1).+)\1\);}) {
                                                               my $src = $2;
                                                               if ($src =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
                                                                   $needsupdate = 1;
                                                               }
                                                           }
                                                           if ($script =~ /\(document,\s*(['"])script\1,\s*\[([^\]]+)\]\);/s) {
                                                               my $scriptslist = $2;
                                                               my $needsupdate = 1;
                                                               my @srcs = split(/\s*,\s*/,$scriptslist);
                                                               foreach my $src (@srcs) {
                                                                   if ($src =~ /(["'])(?:(?!\1).)+\.js\1/) {
                                                                       my $quote = $1;
                                                                       my ($url) = ($src =~ m/\Q$quote\E([^$quote]+)\Q$quote\E/);
                                                                       if ($url =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
                                                                           $needsupdate = 1;
                                                                       }
                                                                   }
                                                               }
                                                           }
                                                           if ($script =~ m{loadScript\(\s*(['"])((?:(?!\1).)+\.js)\1,\s*function}is) {
                                                               my $src = $2;
                                                               if ($src =~ m{^\Q/res/$coursedom/$coursenum/\E}si) {
                                                                   $needsupdate = 1;
                                                               }
                                                           }
                                                           if ($needsupdate) {
                                                               $script =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/gsi};
                                                               $changes ++;
                                                           }
                                                           $outstring .= $script;
                                                       }
                                                   }
                                               } elsif ($token->[0] eq 'E') {
                                                   if ($token->[2]) {
                                                       unless ($token->[1] eq 'allow') {
                                                           $outstring.='</'.$token->[1].'>';
                                                       }
                                                   }
                                               } else {
                                                   $outstring.=$token->[1];
                                               }
                                           }
                                           pop(@parser);
                                       }
                                       if ($changes) {
                                           if (open(my $fh,'>',$dest)) {
                                               print $fh $outstring;
                                               close($fh);
                                           }
                                     }                                      }
                                 }                                  }
                             }                              }
                         }                          }
                     } else {  
                         $notopdir = 1;  
                     }                      }
                   } else {
                       $notopdir = 1;
                 }                  }
             }              }
             if ($notopdir) {              if ($notopdir) {
Line 928  ENDJS Line 1118  ENDJS
                           '</p>'."\n".                            '</p>'."\n".
                           '<ul><li>'.join('</li><li>',sort(keys(%newfile))).'</li></ul></p>'."\n");                            '<ul><li>'.join('</li><li>',sort(keys(%newfile))).'</li></ul></p>'."\n");
             }              }
               if (keys(%checkdeps)) {
                   my %missingdep;
                   foreach my $depfile (sort(keys(%checkdeps))) {
                       unless (-e "$desttop/$depfile") {
                           $missingdep{$depfile} = 1;
                       }
                   }
                   if (keys(%missingdep)) {
                       $r->print('<p>'.&mt('You may also need to copy the following missing dependencies for files copied to [_1]:',
                                           '<span class="LC_filename">'.$desturl.'/'.$subdir.'</span>').
                             '</p>'."\n".
                             '<ul><li>'.join('</li><li>',sort(keys(%missingdep))).'</li></ul></p>'."\n");
                   }
               }
         } else {          } else {
             $r->print('<p>'.&mt('No currently existing files or directories in Course Authoring Space selected for copying').'</p>');              $r->print('<p>'.&mt('No currently existing files or directories in Course Authoring Space selected for copying').'</p>');
             $r->print(&endContentScreen());              $r->print(&endContentScreen());
Line 938  ENDJS Line 1142  ENDJS
         my $chkname = 'copytouser';          my $chkname = 'copytouser';
         my $context = 'crsauthored';          my $context = 'crsauthored';
         my (%subdirs,%files,@dirs_by_depth,@files_by_depth,%parent,%children,%hierarchy,@checked_maps);          my (%subdirs,%files,@dirs_by_depth,@files_by_depth,%parent,%children,%hierarchy,@checked_maps);
         &Apache::lonnet::recursedirs($home,1,undef,$exclude,0,0,$srcurl,'',\%subdirs,\%files);          &Apache::lonnet::recursedirs($is_course_home,1,undef,$exclude,0,0,$srcurl,'',\%subdirs,\%files,1);
         foreach my $key (keys(%subdirs)) {          foreach my $key (keys(%subdirs)) {
             next if (($key eq '/') || ($key eq ''));              next if (($key eq '/') || ($key eq ''));
             my @items = split(/\//,$key);              my @items = split(/\//,$key);
Line 962  ENDJS Line 1166  ENDJS
             }              }
             if (ref($files{$path}) eq 'HASH') {              if (ref($files{$path}) eq 'HASH') {
                 foreach my $file (keys(%{$files{$path}})) {                  foreach my $file (keys(%{$files{$path}})) {
                     $files_by_depth[$depth]{$path}{$file} = 1;                      $files_by_depth[$depth]{$path}{$file} = $files{$path}{$file};
                 }                  }
             }              }
         }          }
         my ($info,$display,$onsubmit,$togglebuttons,$disabled);          my ($info,$display,$onsubmit,$togglebuttons,$disabled);
           my (%resdirs,%resfiles);
           my $resurl = "/res/$coursedom/$coursenum";
           my $resexclude = &Apache::lonnet::res_exclude();
           &Apache::lonnet::recursedirs($is_course_home,1,undef,$resexclude,0,0,$resurl,'',\%resdirs,\%resfiles);
         if ($readonly) {          if ($readonly) {
             $disabled = ' disabled="disabled"';              $disabled = ' disabled="disabled"';
         }          }
Line 996  ENDJS Line 1204  ENDJS
         $display .= &Apache::loncommon::start_data_table()."\n".          $display .= &Apache::loncommon::start_data_table()."\n".
                     &Apache::loncommon::start_data_table_header_row().                      &Apache::loncommon::start_data_table_header_row().
                     '<th>'.&mt('Copy?').'</th>'.                      '<th>'.&mt('Copy?').'</th>'.
                     '<th>'.&mt('Title').'</th>'.                      '<th>'.&mt('Name').'</th>'.
                       '<th>'.&mt('Last modified').'</th>'.
                       '<th>'.&mt('Published?').'</th>'.
                     &Apache::loncommon::end_data_table_header_row()."\n";                      &Apache::loncommon::end_data_table_header_row()."\n";
         $count = &recurse_crsauthored(0,\@dirs_by_depth,\@files_by_depth,'/',$startcount,          $count = &recurse_crsauthored(0,\@dirs_by_depth,\@files_by_depth,'/',$startcount,
                                       $count,\$display,\%parent,\%children,$readonly,                                        $count,\$display,\%parent,\%children,$readonly,
                                       $formname,$chkname,\$lastcontainer);                                        $formname,$chkname,\$lastcontainer,\%resfiles);
         $display .= &Apache::loncommon::end_data_table().'</fieldset>';          $display .= &Apache::loncommon::end_data_table().'</fieldset>';
         unless ($readonly) {          unless ($readonly) {
             $display .= '</div><div style="padding:0;clear:both;margin:0;border:0"></div>'.              $display .= '</div><div style="padding:0;clear:both;margin:0;border:0"></div>'.
Line 1017  ENDJS Line 1227  ENDJS
   
 sub recurse_crsauthored {  sub recurse_crsauthored {
     my ($currdepth,$dirs_by_depth,$files_by_depth,$currpath,$startcount,$count,$displayref,      my ($currdepth,$dirs_by_depth,$files_by_depth,$currpath,$startcount,$count,$displayref,
         $parent,$children,$readonly,$formname,$chkname,$lastcontainerref) = @_;          $parent,$children,$readonly,$formname,$chkname,$lastcontainerref,$resfilesref) = @_;
     return $count unless ((ref($dirs_by_depth) eq 'ARRAY') && (ref($files_by_depth) eq 'ARRAY'));      return $count unless ((ref($dirs_by_depth) eq 'ARRAY') && (ref($files_by_depth) eq 'ARRAY') &&
                             (ref($resfilesref) eq 'HASH'));
     my ($disabled,$hasdirs,$hasfiles,%unique,%dirs,%files);      my ($disabled,$hasdirs,$hasfiles,%unique,%dirs,%files);
     if ((ref($dirs_by_depth->[$currdepth]) eq 'HASH') &&      if ((ref($dirs_by_depth->[$currdepth]) eq 'HASH') &&
         (ref($dirs_by_depth->[$currdepth]{$currpath}) eq 'HASH')) {          (ref($dirs_by_depth->[$currdepth]{$currpath}) eq 'HASH')) {
Line 1064  sub recurse_crsauthored { Line 1275  sub recurse_crsauthored {
             for (my $i=0; $i<$currdepth; $i++) {              for (my $i=0; $i<$currdepth; $i++) {
                 $$displayref .= "$whitespace\n";                  $$displayref .= "$whitespace\n";
             }              }
             $$displayref .= '<img '.$icon.' />&nbsp;'.$item.'</td>'.              $$displayref .= '<img '.$icon.' />&nbsp;'.$item.'</td><td>&nbsp;</td><td>&nbsp;</td>'.
                             &Apache::loncommon::end_data_table_row()."\n";                              &Apache::loncommon::end_data_table_row()."\n";
             $count = &recurse_crsauthored($deeper,$dirs_by_depth,$files_by_depth,$newpath,              $count = &recurse_crsauthored($deeper,$dirs_by_depth,$files_by_depth,$newpath,
                                           $startcount,$count,$displayref,$parent,$children,                                            $startcount,$count,$displayref,$parent,$children,
                                           $readonly,$formname,$chkname,$lastcontainerref);                                            $readonly,$formname,$chkname,$lastcontainerref,$resfilesref);
         }          }
         if ($hasfiles && exists($files{$item})) {          if ($hasfiles && exists($files{$item})) {
             $count ++;              $count ++;
Line 1092  sub recurse_crsauthored { Line 1303  sub recurse_crsauthored {
             } else {              } else {
                 $showpath = "/$currpath/";                  $showpath = "/$currpath/";
             }              }
               my ($published,$lastmod);
               if ((ref($resfilesref->{$currpath})) && (exists($resfilesref->{$currpath}{$item}))) {
                   $published = '<img src="'.$location.'/navmap.correct.gif" alt="'.&mt('yes').'" />';
               } else {
                   $published = '<img src="'.$location.'/navmap.wrong.gif" alt="'.&mt('no').'" />';
               }
             $$displayref .= &Apache::loncommon::start_data_table_row().              $$displayref .= &Apache::loncommon::start_data_table_row().
                             '<td><input type="checkbox" name="'.$chkname.'" value="'.&escape($showpath.$item).'" '.                              '<td><input type="checkbox" name="'.$chkname.'" value="'.&escape($showpath.$item).'" '.
                             'onclick="javascript:checkResource(document.'.$formname.','."'$currelem'".')" '.                              'onclick="javascript:checkResource(document.'.$formname.','."'$currelem'".')" '.
Line 1100  sub recurse_crsauthored { Line 1317  sub recurse_crsauthored {
                 $$displayref .= "$whitespace\n";                  $$displayref .= "$whitespace\n";
             }              }
             $$displayref .= '<img '.$icon.$alttext.' />&nbsp;'.$item.'</td>'.              $$displayref .= '<img '.$icon.$alttext.' />&nbsp;'.$item.'</td>'.
                               '<td>'.&Apache::lonlocal::locallocaltime($files{$item}).'</td>'.
                               '<td style="text-align: center;">'.$published.'</td>'.
                             &Apache::loncommon::end_data_table_row()."\n";                              &Apache::loncommon::end_data_table_row()."\n";
         }          }
     }      }

Removed from v.1.712  
changed lines
  Added in v.1.714


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