Diff for /loncom/publisher/loncfile.pm between versions 1.91 and 1.99

version 1.91, 2008/12/19 14:01:16 version 1.99, 2009/05/26 16:29:56
Line 361  sub cleanDest { Line 361  sub cleanDest {
  my ($newpath)=($dest=~m|(.*)/|);   my ($newpath)=($dest=~m|(.*)/|);
  $newpath=&relativeDest($fn,$newpath,$uname);   $newpath=&relativeDest($fn,$newpath,$uname);
  if (! -d "$newpath") {   if (! -d "$newpath") {
     $request->print("<p><span class=\"LC_error\">".&mt('You have requested to create file in directory [_1] which doesn\'t exist. The requested directory path has been removed from the requested file name.','"'.&display($newpath).'"')."</span></p>");      $request->print('<p><span class="LC_error">'
                              .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested file name."
                                  ,'"'.&display($newpath).'"')
                              .'</span></p>');
     $dest=~s|.*/||;      $dest=~s|.*/||;
  }   }
     }      }
     if ($dest =~ /\.(\d+)\.(\w+)$/){      if ($dest =~ /\.(\d+)\.(\w+)$/){
  $request->print('<span class="LC_error">'   $request->print('<span class="LC_error">'
  .&mt('Bad filename [_1].<br /> <tt>(name).(number).(extension)</tt> not allowed. <br /> Removing the <tt>.number.</tt> from requested filename.',&display($dest))   .&mt('Bad filename [_1]','<span class="LC_filename">'.&display($dest).'</span>')
                           .'<br />'
                           .&mt('[_1](name).(number).(extension)[_2] not allowed.','<tt>','</tt>')
                           .'<br />'
                           .&mt('Removing the [_1].number.[_2] from requested filename.','<tt>','</tt>')
  .'</span>');   .'</span>');
  $dest =~ s/\.(\d+)(\.\w+)$/$2/;   $dest =~ s/\.(\d+)(\.\w+)$/$2/;
     }      }
Line 416  sub CloseForm1 { Line 423  sub CloseForm1 {
     my ($request,  $fn) = @_;      my ($request,  $fn) = @_;
     $request->print('<p><input type="submit" value="'.&mt('Continue').'" /></p></form>');      $request->print('<p><input type="submit" value="'.&mt('Continue').'" /></p></form>');
     $request->print('<form action="'.&url($fn).      $request->print('<form action="'.&url($fn).
     '" method="POST"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');      '" method="post"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');
 }  }
   
   
Line 581  sub Delete1 { Line 588  sub Delete1 {
   
     if( -e $fn) {      if( -e $fn) {
  $request->print('<input type="hidden" name="newfilename" value="'.   $request->print('<input type="hidden" name="newfilename" value="'.
  $fn.'"/>');   $fn.'" />');
         if (-d $fn) {          if (-d $fn) {
             unless (&empty_directory($fn,'Delete1')) {              unless (&empty_directory($fn,'Delete1')) {
                 $request->print('<h3>'.&mt('Only empty directories may be deleted.').'</h3>'.                  $request->print('<h3>'.&mt('Only empty directories may be deleted.').'</h3>'.
Line 711  sub NewDir1 { Line 718  sub NewDir1 {
  $request->print('</form>');   $request->print('</form>');
     } else {      } else {
  if ($mode eq 'testbank') {   if ($mode eq 'testbank') {
     $request->print('<input type="hidden" name="callingmode" value="testbank">');      $request->print('<input type="hidden" name="callingmode" value="testbank" />');
  } elsif ($mode eq 'imsimport') {   } elsif ($mode eq 'imsimport') {
     $request->print('<input type="hidden" name="callingmode" value="imsimport">');      $request->print('<input type="hidden" name="callingmode" value="imsimport" />');
  }   }
  $request->print('<input type="hidden" name="newfilename" value="'.   $request->print('<input type="hidden" name="newfilename" value="'.
  $newfilename.'" /><p>'.&mt('Make new directory').' '.   $newfilename.'" /><p>'.&mt('Make new directory').' '.
Line 726  sub NewDir1 { Line 733  sub NewDir1 {
 sub Decompress1 {  sub Decompress1 {
     my ($request, $user, $domain, $fn) = @_;      my ($request, $user, $domain, $fn) = @_;
     if( -e $fn) {      if( -e $fn) {
     $request->print('<input type="hidden" name="newfilename" value="'.$fn.'"/>');      $request->print('<input type="hidden" name="newfilename" value="'.$fn.'" />');
     $request->print('<p>'.&mt('Decompress').' '.&display($fn).'?</p>');      $request->print('<p>'.&mt('Decompress').' '.&display($fn).'?</p>');
     &CloseForm1($request, $fn);      &CloseForm1($request, $fn);
     } else {      } else {
Line 776  button which returns you to the driector Line 783  button which returns you to the driector
   
 sub NewFile1 {  sub NewFile1 {
     my ($request, $user, $domain, $fn, $newfilename) = @_;      my ($request, $user, $domain, $fn, $newfilename) = @_;
       return if (&filename_check($newfilename) ne 'ok');
   
     if ($env{'form.action'} =~ /new(.+)file/) {      if ($env{'form.action'} =~ /new(.+)file/) {
  my $extension=$1;   my $extension=$1;
   
         ##Informs User (name).(number).(extension) not allowed   
  if($newfilename =~ /\.(\d+)\.(\w+)$/){  
     $r->print('<span class="LC_error">'.$newfilename.  
       ' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').') '.  
       ' '.&mt('Not Allowed').'</span>');  
     return;  
  }  
  if($newfilename =~ /(\:\:\:|\&\&\&|\_\_\_)/){  
     $r->print('<span class="LC_error">'.$newfilename.  
       ' - '.&mt('Bad Filename').'<br />('.&mt('Must not include').' '.$1.') '.  
       ' '.&mt('Not Allowed').'</span>');  
     return;  
  }  
  if ($newfilename !~ /\Q.$extension\E$/) {   if ($newfilename !~ /\Q.$extension\E$/) {
     if ($newfilename =~ m|/[^/.]*\.(?:[^/.]+)$|) {      if ($newfilename =~ m|/[^/.]*\.(?:[^/.]+)$|) {
  #already has an extension strip it and add in expected one   #already has an extension strip it and add in expected one
Line 806  sub NewFile1 { Line 800  sub NewFile1 {
     if ($type eq 'error') {      if ($type eq 'error') {
  $request->print('</form>');   $request->print('</form>');
     } else {      } else {
           my $extension;
   
           if ($newfilename =~ m{[^/.]+\.([^/.]+)$}) {
               $extension = $1;
           }
   
           my @okexts = qw(xml html xhtml htm xhtm problem page sequence rights sty library js css txt);
           if (($extension eq '') || (!grep(/^\Q$extension\E/,@okexts))) {
               my $validexts = '.'.join(', .',@okexts);
               $request->print('<p class="LC_warning">'.
                   &mt('Invalid filename: ').&display($newfilename).'</p><p>'.
                   &mt('The name of the new file needs to end with an appropriate file extension to indicate the type of file to create.').'<br />'.
                   &mt('The following are valid extensions: [_1].',$validexts).
                   '</p></form><p>'.
    '<form name="fileaction" action="/adm/cfile" method="post">'.
                   '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.
    '<input type="hidden" name="action" value="newfile" />'.
           '<span class ="LC_nobreak">'.&mt('Enter a file name: ').'<input type="text" name="newfilename" value="Type Name Here" onfocus="if (this.value == '."'Type Name Here') this.value=''".'" />&nbsp;<input type="submit" value="Go" />'.
                   '</span></form></p>'.
                   '<p><form action="'.&url($fn).
                   '" method="post"><p><input type="submit" value="'.&mt('Cancel').'" /></form></p>');
               return;
           }
   
  $request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>');   $request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>');
  $request->print('</form>');   $request->print('</form>');
   
  $request->print('<form action="'.&url($newfilename).   $request->print('<form action="'.&url($newfilename).
  '" method="POST"><p><input type="submit" value="'.&mt('Continue').'" /></p></form>');   '" method="post"><p><input type="submit" value="'.&mt('Continue').'" /></p></form>');
  $request->print('<form action="'.&url($fn).   $request->print('<form action="'.&url($fn).
  '" method="POST"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');   '" method="post"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');
     }      }
       return;
   }
   
   sub filename_check {
       my ($newfilename) = @_;
       ##Informs User (name).(number).(extension) not allowed
       if($newfilename =~ /\.(\d+)\.(\w+)$/){
           $r->print('<span class="LC_error">'.$newfilename.
                     ' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').') '.
                     ' '.&mt('Not Allowed').'</span>');
           return;
       }
       if($newfilename =~ /(\:\:\:|\&\&\&|\_\_\_)/){
           $r->print('<span class="LC_error">'.$newfilename.
                     ' - '.&mt('Bad Filename').'<br />('.&mt('Must not include').' '.$1.') '.
                     ' '.&mt('Not Allowed').'</span>');
           return;
       }
       return 'ok'; 
 }  }
   
 =pod  =pod
Line 1350  function writeDone() { Line 1387  function writeDone() {
  $loaditem{'onload'} = "writeDone()";   $loaditem{'onload'} = "writeDone()";
     }      }
           
       # Breadcrumbs
       &Apache::lonhtmlcommon::clear_breadcrumbs();
       &Apache::lonhtmlcommon::add_breadcrumb({
           'text'  => 'Construction Space',
           'href'  => '', # FIXME Add link to /priv/[user]
       });
       &Apache::lonhtmlcommon::add_breadcrumb({
           'text'  => 'File Operation',
           'title' => 'Construction Space File Operation',
           'href'  => '',
       });
   
     $r->print(&Apache::loncommon::start_page('Construction Space File Operation',      $r->print(&Apache::loncommon::start_page('Construction Space File Operation',
      $js,       $js,
      {'add_entries' => \%loaditem,}));       {'add_entries' => \%loaditem,})
                .&Apache::lonhtmlcommon::breadcrumbs()
                .&Apache::loncommon::head_subbox(
                     &Apache::loncommon::CSTR_pageheader())
       );
       
     $r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');      $r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');
       
     if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {      if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
  $r->print('<h3><span class="LC_error">'.&mt('Co-Author').': '.$uname.' at '.$udom.          $r->print('<p class="LC_warning">'
   '</span></h3>');                   .&mt('Co-Author [_1]',$uname.':'.$udom)
                    .'</p>'
           );
     }      }
   
   

Removed from v.1.91  
changed lines
  Added in v.1.99


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