Diff for /loncom/interface/londocs.pm between versions 1.475 and 1.476

version 1.475, 2012/01/29 19:50:53 version 1.476, 2012/01/31 23:47:15
Line 1109  sub process_file_upload { Line 1109  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)) {
                   $nextphase = 'decompress_uploaded';
                   my $position = scalar(@LONCAPA::map::order)-1;
                   my $noextract = &return_to_editor();
                   my $archiveurl = &HTML::Entities::encode($url,'<>&"');
                   my %archiveitems = (
                       folderpath => $env{'form.folderpath'},
                       pagepath   => $env{'form.pagepath'},
                       cmd        => $nextphase,
                       newidx     => $newidx,
                       position   => $position,
                       phase      => $nextphase,
                   ); 
                   $$upload_output = $showupload.
                                     &Apache::loncommon::decompress_form($mimetype,
                                         $archiveurl,'/adm/coursedocs',$noextract,
                                         \%archiveitems);
             }              }
         }          }
     }      }
Line 2363  sub handler { Line 2380  sub handler {
                                                          $docuname,$docudom,undef,                                                           $docuname,$docudom,undef,
                                                          $dir_root).                                                           $dir_root).
                    &return_to_editor());                     &return_to_editor());
         } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
             $uploadphase = 'decompress_phase_one';
             $r->print(&decompression_phase_one().
                       &return_to_editor());
         } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
             $uploadphase = 'decompress_phase_two';
             $r->print(&decompression_phase_two().
                       &return_to_editor());
       }        }
   }    }
   
Line 2933  sub return_to_editor { Line 2958  sub return_to_editor {
            '</a></p>';             '</a></p>';
 }  }
   
   sub decompression_info {
       my ($destination,$dir_root) = &embedded_destination();
       my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
       my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
       my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
       my $container='sequence';
       my $hiddenelem;
       if ($env{'form.pagepath'}) {
           $container='page';
           $hiddenelem = '<input type="hidden" name="pagepath" value="'.$env{'form.pagepath'}.'" />'."\n";
       } else {
           $hiddenelem = '<input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" />'."\n";
       }
       if ($env{'form.newidx'}) {
           $hiddenelem .= '<input type="hidden" name="newidx" value="'.$env{'form.newidx'}.'" />'."\n";
       }
       return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
               $hiddenelem);
   }
   
   sub decompression_phase_one {
       my ($dir,$file,$warning,$error,$output);
       my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
           &decompression_info();
       if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/docs/\E(?:default|supplemental|\d+).*/([^/]+)$}) {
           $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
       } else {
           my $file = $1;
           $output = &Apache::loncommon::process_decompression($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem);
           if ($env{'form.archivedelete'}) {
               my $map = $env{'form.folder'}.'.'.$container;
               my ($delwarning,$delresult);
               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'};
                   $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) {
           $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
                      $error.'</p>'."\n";
       }
       if ($warning) {
           $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
       }
       return $output;
   }
   
   sub decompression_phase_two {
       my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
           &decompression_info();
       my $output = 
           &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
                                                       $destination,$dir_root,$hiddenelem);
       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(

Removed from v.1.475  
changed lines
  Added in v.1.476


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