Diff for /loncom/publisher/lonupload.pm between versions 1.50 and 1.51

version 1.50, 2010/10/27 01:04:15 version 1.51, 2010/11/28 00:04:10
Line 70  Start page output Line 70  Start page output
   
 =item *  =item *
   
 output relevant interface phase (phaseone or phasetwo or phasethree)  output relevant interface phase (phaseone, phasetwo, phasethree or phasefour)
   
 =item *  =item *
   
Line 99  as overwriting an existing file). Line 99  as overwriting an existing file).
 Interface for handling secondary uploads of embedded objects  Interface for handling secondary uploads of embedded objects
 in an html file.  in an html file.
   
   =item phasefour()
   
   Interface for handling optional renaming of links to embedded
   objects. 
   
 =item upfile_store()  =item upfile_store()
   
 Store contents of uploaded file into temporary space.  Invoked  Store contents of uploaded file into temporary space.  Invoked
Line 351  sub check_extension { Line 356  sub check_extension {
             &Apache::lonnet::extract_embedded_items($target,\%allfiles,\%codebase);              &Apache::lonnet::extract_embedded_items($target,\%allfiles,\%codebase);
             if (keys(%allfiles) > 0) {              if (keys(%allfiles) > 0) {
                 my ($currentpath) = ($url =~ m{^(.+)/[^/]+$});                  my ($currentpath) = ($url =~ m{^(.+)/[^/]+$});
                 my $state = <<STATE;                  my $state = &embedded_form_elems('upload_embedded',$url,$mode);
     <input type="hidden" name="action"      value="upload_embedded" />                  my ($embedded,$num,$pathchg) = 
     <input type="hidden" name="mode"        value="$mode" />                      &Apache::loncommon::ask_for_embedded_content($action,$state,\%allfiles,
     <input type="hidden" name="phase"       value="three" />                                                                   \%codebase,
     <input type="hidden" name="filename" value="$url" />                                                                   {'error_on_invalid_names'   => 1,
 STATE                                                                    'ignore_remote_references' => 1,
                 my $embedded = &Apache::loncommon::ask_for_embedded_content($action,$state,\%allfiles,\%codebase,                                                                    'current_path'             => $currentpath});
                                       {'error_on_invalid_names'   => 1,  
                                        'ignore_remote_references' => 1,  
                                        'current_path'             => $currentpath});  
                 if ($embedded) {                  if ($embedded) {
                     $result .= '<h3>'.&mt('Reference Warning').'</h3>'.                      $result .= '<h3>'.&mt('Reference Warning').'</h3>';
                                '<p>'.&mt('Completed upload of the file. This file contained references to other files.').'</p>'.                      if ($num) {
                                '<p>'.&mt('Please select the locations from which the referenced files are to be uploaded.').'</p>'.                          $result .= '<p>'.&mt('Completed upload of the file.').' '.&mt('This file contained references to other files.').'</p>'.
                                $embedded;                                     '<p>'.&mt('Please select the locations from which the referenced files are to be uploaded.').'</p>'.
                 }                                     $embedded;
                 if ($mode eq 'testbank') {                          if ($mode eq 'testbank') {
                     $returnflag = 'embedded';                              $returnflag = 'embedded';
                     $result .=  '<p>'.&mt('Or [_1]continue[_2] the testbank import without these files','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';                              $result .=  '<p>'.&mt('Or [_1]continue[_2] the testbank import without these files.','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
                           }
                       } else {
                           $result .= '<p>'.&mt('Completed upload of the file.').'</p>'.$embedded;
                           if ($pathchg) {
                               if ($mode eq 'testbank') {
                                   $returnflag = 'embedded';
                                   $result .=  '<p>'.&mt('Or [_1]continue[_2] the testbank import without modifying the references(s).','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
                               }
                           }
                       }
                 }                  }
             }              }
         }          }
Line 389  STATE Line 401  STATE
   
 sub phasethree {  sub phasethree {
     my ($r,$fn,$uname,$udom,$mode) = @_;      my ($r,$fn,$uname,$udom,$mode) = @_;
       my $action = '/adm/upload'; 
       if ($mode eq 'testbank') {
           $action = '/adm/testbank';
       } elsif ($mode eq 'imsimport') {
           $action = '/adm/imsimport';
       }
       my $dir_root = '/home/'.$uname.'/public_html';
       my $url_root = '/priv/'.$uname;
       my $path = &File::Basename::dirname($fn);
       my $filename = &HTML::Entities::encode($env{'form.filename'},'<>&"');
       my $state = &embedded_form_elems('modify_orightml',$filename,$mode).
                   '<input type="hidden" name="phase" value="four" />';
       my ($result,$returnflag) = 
           &Apache::loncommon::upload_embedded($mode,$path,$uname,$udom,
                                               $dir_root,$url_root,undef,
                                               undef,undef,$state,$action);
       if ($mode ne 'imsimport' && $mode ne 'testbank') {
           $result .= '<br /><h3><a href="'.$url_root.$fn.'">'.
                     &mt('View main file').'</a></h3>'.
                     '<h3><a href="'.$url_root.$path.'">'.
                     &mt('Back to Directory').'</a></h3><br />';
       }
       return ($result,$returnflag);
   }
   
   sub embedded_form_elems {
       my ($action,$filename,$mode) = @_;
       return <<STATE;
       <input type="hidden" name="action" value="$action" />
       <input type="hidden" name="mode" value="$mode" />
       <input type="hidden" name="filename" value="$filename" />
   STATE
   }
   
   sub phasefour {
       my ($r,$fn,$uname,$udom,$mode) = @_;
       my $action = '/adm/upload';
       if ($mode eq 'testbank') {
           $action = '/adm/testbank';
       } elsif ($mode eq 'imsimport') {
           $action = '/adm/imsimport';
       }
     my $result;      my $result;
     my $dir_root = '/home/'.$uname.'/public_html';      my $dir_root = '/home/'.$uname.'/public_html';
     my $url_root = '/priv/'.$uname;      my $url_root = '/priv/'.$uname;
     my $base = &File::Basename::basename($fn);  
     my $path = &File::Basename::dirname($fn);      my $path = &File::Basename::dirname($fn);
     $result = &Apache::loncommon::upload_embedded($mode,$path,$uname,$udom,      $result .= &Apache::loncommon::modify_html_refs($mode,$path,
                                                   $dir_root,$url_root);                                $uname,$udom,$dir_root);
     if ($mode ne 'imsimport' && $mode ne 'testbank') {      if ($mode ne 'imsimport' && $mode ne 'testbank') {
         $result = '<br /><font size="+2"><a href="'.$url_root.$fn.'">'.          $result .= '<br /><h3><a href="'.$url_root.$fn.'">'.
                   &mt('View main file').'</a></font>'.                    &mt('View main file').'</a></h3>'.
                   '<br /><font size="+2"><a href="'.$url_root.$path.'">'.                    '<h3><a href="'.$url_root.$path.'">'.
                   &mt('Back to Directory').'</a></font><br />';                    &mt('Back to Directory').'</a></h3><br />';
     }      }
     return $result;      return $result;
 }  }
Line 490  function verifyForm() { Line 543  function verifyForm() {
                  .'</p>'                   .'</p>'
         );          );
     }      }
       if ($env{'form.phase'} eq 'four') {
     if ($env{'form.phase'} eq 'three') {          my $output = &phasefour($r,$fn,$uname,$udom,'author');
           $r->print($output);
       } elsif ($env{'form.phase'} eq 'three') {
         my $output = &phasethree($r,$fn,$uname,$udom,'author');          my $output = &phasethree($r,$fn,$uname,$udom,'author');
         $r->print($output);          $r->print($output);
     } elsif ($env{'form.phase'} eq 'two') {      } elsif ($env{'form.phase'} eq 'two') {

Removed from v.1.50  
changed lines
  Added in v.1.51


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