Diff for /loncom/interface/londocs.pm between versions 1.479 and 1.483

version 1.479, 2012/03/28 12:58:42 version 1.483, 2012/05/06 22:09:14
Line 437  sub log_docs { Line 437  sub log_docs {
 sub docs_change_log {  sub docs_change_log {
     my ($r)=@_;      my ($r)=@_;
     my $folder=$env{'form.folder'};      my $folder=$env{'form.folder'};
     $r->print(&Apache::loncommon::start_page('Course Document Change Log'));      my $js = '<script type="text/javascript">'."\n".
                '// <![CDATA['."\n".
                &Apache::loncommon::display_filter_js('docslog')."\n".
                &history_tab_js()."\n".
                '// ]]>'."\n".
                '</script>'."\n";
       $r->print(&Apache::loncommon::start_page('Course Document Change Log',$js));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));      $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
     my %docslog=&Apache::lonnet::dump('nohist_docslog',      my %docslog=&Apache::lonnet::dump('nohist_docslog',
                                       $env{'course.'.$env{'request.course.id'}.'.domain'},                                        $env{'course.'.$env{'request.course.id'}.'.domain'},
Line 461  sub docs_change_log { Line 467  sub docs_change_log {
     'randomorder'    => 'Randomly ordered',      'randomorder'    => 'Randomly ordered',
     'set'            => 'set to',      'set'            => 'set to',
     'del'            => 'deleted');      'del'            => 'deleted');
     $r->print(&Apache::loncommon::display_filter().      $r->print(&Apache::loncommon::display_filter('docslog').
               '<input type="hidden" name="folder" value="'.$folder.'" />'.                '<input type="hidden" name="folder" value="'.$folder.'" />'.
               '<input type="submit" value="'.&mt('Display').'" /></form>');                '<input type="submit" value="'.&mt('Display').'" /></form>');
     $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().      $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
Line 1120  sub process_file_upload { Line 1126  sub process_file_upload {
                     position   => $position,                      position   => $position,
                     phase      => $nextphase,                      phase      => $nextphase,
                     comment    => $comment,                      comment    => $comment,
                 );                   );
                   my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
                   my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx); 
                 $$upload_output = $showupload.                  $$upload_output = $showupload.
                                   &Apache::loncommon::decompress_form($mimetype,                                    &Apache::loncommon::decompress_form($mimetype,
                                       $archiveurl,'/adm/coursedocs',$noextract,                                        $archiveurl,'/adm/coursedocs',$noextract,
                                       \%archiveitems);                                        \%archiveitems,\@current);
             }              }
         }          }
     }      }
     return $nextphase;      return $nextphase;
 }  }
   
   sub get_dir_list {
       my ($url,$coursenum,$coursedom,$newidx) = @_;
       my ($destination,$dir_root) = &embedded_destination();
       my ($dirlistref,$listerror) =  
           &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
       my @dir_lines;
       my $dirptr=16384;
       if (ref($dirlistref) eq 'ARRAY') {
           foreach my $dir_line (sort
                             {
                                 my ($afile)=split('&',$a,2);
                                 my ($bfile)=split('&',$b,2);
                                 return (lc($afile) cmp lc($bfile));
                             } (@{$dirlistref})) {
               my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
               $filename =~ s/\s+$//;
               next if ($filename =~ /^\.\.?$/); 
               my $isdir = 0;
               if ($dirptr&$testdir) {
                   $isdir = 1;
               }
               push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
           }
       }
       return @dir_lines;
   }
   
 sub is_supplemental_title {  sub is_supplemental_title {
     my ($title) = @_;      my ($title) = @_;
     return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);      return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
Line 2403  sub handler { Line 2438  sub handler {
           my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};            my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
           my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};            my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
           my ($destination,$dir_root) = &embedded_destination();            my ($destination,$dir_root) = &embedded_destination();
           $r->print(&Apache::loncommon::modify_html_refs('coursedoc',$destination,            my $result = 
                                                          $docuname,$docudom,undef,                &Apache::loncommon::modify_html_refs('coursedoc',$destination,
                                                          $dir_root).                                                     $docuname,$docudom,undef,
                    &return_to_editor());                                                     $dir_root);
             $r->print($result.&return_to_editor());   
       } elsif ($env{'form.phase'} eq 'decompress_uploaded') {        } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
           $uploadphase = 'decompress_phase_one';            $uploadphase = 'decompress_phase_one';
           $r->print(&decompression_phase_one().            $r->print(&decompression_phase_one().
Line 2991  sub decompression_info { Line 3027  sub decompression_info {
     my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};      my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};      my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
     my $container='sequence';      my $container='sequence';
     my $hiddenelem;      my ($pathitem,$hiddenelem);
       my @hiddens = ('newidx','comment','position');
     if ($env{'form.pagepath'}) {      if ($env{'form.pagepath'}) {
         $container='page';          $container='page';
         $hiddenelem = '<input type="hidden" name="pagepath" value="'.$env{'form.pagepath'}.'" />'."\n";          $pathitem = 'pagepath';
     } else {      } else {
         $hiddenelem = '<input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" />'."\n";          $pathitem = 'folderpath';
     }  
     if ($env{'form.newidx'}) {  
         $hiddenelem .= '<input type="hidden" name="newidx" value="'.$env{'form.newidx'}.'" />'."\n";  
     }      }
     if ($env{'form.comment'}) {      unshift(@hiddens,$pathitem);
         $hiddenelem .= '<input type="hidden" name="comment" value="'.$env{'form.comment'}.'" />'."\n";      foreach my $item (@hiddens) {
           if ($env{'form.'.$item}) {
               $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
                              $env{'form.'.$item}.'" />'."\n";
           }
     }      }
     return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,      return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
             $hiddenelem);              $hiddenelem);
Line 3016  sub decompression_phase_one { Line 3054  sub decompression_phase_one {
         $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});          $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
     } else {      } else {
         my $file = $1;          my $file = $1;
         $output = &Apache::loncommon::process_decompression($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem);          $output = 
         if ($env{'form.archivedelete'}) {              &Apache::loncommon::process_decompression($docudom,$docuname,$file,
             my $map = $env{'form.folder'}.'.'.$container;                                                        $destination,$dir_root,
             my ($delwarning,$delresult);                                                        $hiddenelem);
             my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);          if ($env{'form.autoextract_camtasia'}) {
             if ($fatal) {              $output .= &remove_archive($docudom,$docuname,$container);
                 if ($container eq 'page') {  
                     $delwarning = &mt('An error occurred retrieving the contents of the current page.');  
                 } 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.');  
             } else {  
                 my $currcmd = $env{'form.cmd'};  
                 $env{'form.cmd'} = 'del_'.$env{'form.position'};  
                 if (&handle_edit_cmd($docuname,$docudom)) {  
                     ($errtext,$fatal) = &storemap($docuname,$docudom,$map);  
                     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'} = $currcmd;  
                 $delresult = &mt('Archive file removed after extracting files.');  
             }  
             if ($delwarning) {  
                 $output .= '<p class="LC_warning">'.  
                            $delwarning.  
                            '</p>';  
             }  
             if ($delresult) {  
                 $output .= '<p class="LC_info">'.  
                            $delresult.  
                            '</p>';  
             }  
         }          }
     }      }
     if ($error) {      if ($error) {
Line 3069  sub decompression_phase_one { Line 3075  sub decompression_phase_one {
 sub decompression_phase_two {  sub decompression_phase_two {
     my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=      my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
         &decompression_info();          &decompression_info();
     my $output =       my $output;
       if ($env{'form.archivedelete'}) {
           $output = &remove_archive($docudom,$docuname,$container);
       }
       $output .= 
         &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,          &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
                                                     $destination,$dir_root,$hiddenelem);                                                      $destination,$dir_root,$hiddenelem);
     return $output;      return $output;
 }  }
   
   sub remove_archive {
       my ($docudom,$docuname,$container) = @_;
       my $map = $env{'form.folder'}.'.'.$container;
       my ($output,$delwarning,$delresult,$url);
       my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
       if ($fatal) {
           if ($container eq 'page') {
               $delwarning = &mt('An error occurred retrieving the contents of the current page.');
           } 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.');
       } else {
           my $currcmd = $env{'form.cmd'};
           my $position = $env{'form.position'};
           if ($position > 0) { 
               $env{'form.cmd'} = 'del_'.$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);
                   if ($fatal) {
                       if ($container eq 'page') {
                           $delwarning = &mt('An error occurred updating the contents of the current page.');
                       } else {
                           $delwarning = &mt('An error occurred updating the contents of the current folder.');
                       }
                   } else {
                       $delresult = &mt('Archive file removed.');
                   }
               }
           }
           $env{'form.cmd'} = $currcmd;
       }
       if ($delwarning) {
           $output = '<p class="LC_warning">'.
                      $delwarning.
                      '</p>';
       }
       if ($delresult) {
           $output .= '<p class="LC_info">'.
                      $delresult.
                      '</p>';
       }
       return $output;
   }
   
 sub generate_admin_options {  sub generate_admin_options {
   my ($help_ref,$env_ref) = @_;    my ($help_ref,$env_ref) = @_;
   my %lt=&Apache::lonlocal::texthash(    my %lt=&Apache::lonlocal::texthash(
Line 3121  sub generate_edit_table { Line 3178  sub generate_edit_table {
         $activetab = $env{'form.active'};          $activetab = $env{'form.active'};
     }      }
     my $backicon = $iconpath.'clickhere.gif';      my $backicon = $iconpath.'clickhere.gif';
     my $backtext = &mt('Back to Overview');      my $backtext = &mt('To Overview');
     $form = '<div class="LC_Box" style="margin:0;">'.      $form = '<div class="LC_Box" style="margin:0;">'.
              '<ul id="navigation'.$tid.'" class="LC_TabContent">'.               '<ul id="navigation'.$tid.'" class="LC_TabContent">'.
              '<li class="goback">'.               '<li class="goback">'.
Line 3315  newWindow = window.open("","IMSimport"," Line 3372  newWindow = window.open("","IMSimport","
 newWindow.location.href = newlocation;  newWindow.location.href = newlocation;
 }  }
   
   
 function finishpick() {  function finishpick() {
 var title=this.document.forms.extimport.title.value;  var title=this.document.forms.extimport.title.value;
 var url=this.document.forms.extimport.url.value;  var url=this.document.forms.extimport.url.value;
Line 3532  function toContents(jumpto) { Line 3588  function toContents(jumpto) {
 ENDNEWSCRIPT  ENDNEWSCRIPT
 }  }
   
   sub history_tab_js {
       return <<"ENDHIST";
   function toggleHistoryDisp(choice) {
       document.docslogform.docslog.value = choice;
       document.docslogform.submit();
       return;
   }
   
   ENDHIST
   }
   
 sub resize_contentdiv_js {  sub resize_contentdiv_js {
     my ($tabidstr) = @_;      my ($tabidstr) = @_;
     my $viewport_js = &Apache::loncommon::viewport_geometry_js();      my $viewport_js = &Apache::loncommon::viewport_geometry_js();

Removed from v.1.479  
changed lines
  Added in v.1.483


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