Diff for /loncom/interface/londocs.pm between versions 1.310 and 1.314.2.3

version 1.310, 2008/09/04 17:50:47 version 1.314.2.3, 2008/12/21 15:48:43
Line 228  sub dumpcourse { Line 228  sub dumpcourse {
  my $title=$origcrsdata{'description'};   my $title=$origcrsdata{'description'};
  $title=~s/[\/\s]+/\_/gs;   $title=~s/[\/\s]+/\_/gs;
  $title=&clean($title);   $title=&clean($title);
  $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');   $r->print('<h3>'.&mt('Folder in Construction Space').'</h3>'
                    .'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
  &tiehash();   &tiehash();
  $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');   $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>'
                    .&Apache::loncommon::start_data_table()
                    .&Apache::loncommon::start_data_table_header_row()
                    .'<th>'.&mt('Internal Filename').'</th>'
                    .'<th>'.&mt('Title').'</th>'
                    .'<th>'.&mt('Save as ...').'</th>'
                    .&Apache::loncommon::end_data_table_header_row());
  foreach (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {   foreach (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
     $r->print('<tr><td>'.$_.'</td>');      $r->print(&Apache::loncommon::start_data_table_row()
                        .'<td>'.$_.'</td>');
     my ($ext)=($_=~/\.(\w+)$/);      my ($ext)=($_=~/\.(\w+)$/);
     my $title=$hash{'title_'.$hash{      my $title=$hash{'title_'.$hash{
  'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};   'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
Line 245  sub dumpcourse { Line 253  sub dumpcourse {
     $title=~s/\.(\w+)$//;      $title=~s/\.(\w+)$//;
     $title=&clean($title);      $title=&clean($title);
     $title.='.'.$ext;      $title.='.'.$ext;
     $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");      $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td>"
                        .&Apache::loncommon::end_data_table_row());
  }   }
  $r->print("</table>\n");   $r->print(&Apache::loncommon::end_data_table());
  &untiehash();   &untiehash();
  $r->print(   $r->print(
   '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump [_1] DOCS',$type).'" /></p></form>');    '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $type DOCS").'" /></p></form>');
     }      }
 }  }
   
Line 309  sub exportcourse { Line 318  sub exportcourse {
                 chdir $cwd;                  chdir $cwd;
                 $outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);                  $outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);
                 if ($copyresult) {                  if ($copyresult) {
                     $outcome .= 'The following errors occurred during export - '.$copyresult;                      $outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
                 }                  }
             } else {              } else {
                 $outcome = '<br />Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.<br />';                  $outcome = '<br />'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'<br />';
             }              }
         }          }
         $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));          $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
Line 924  sub group_import { Line 933  sub group_import {
             my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,              my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                                                 'output',$1.$2);                                                  'output',$1.$2);
             if ($result != m|^/uploaded/|) {              if ($result != m|^/uploaded/|) {
                 $errtext.='Map not saved: A network error occured when trying to save the new map. ';                  $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
                 $fatal = 2;                  $fatal = 2;
             }              }
             if ($fatal) {              if ($fatal) {
Line 1208  sub update_paste_buffer { Line 1217  sub update_paste_buffer {
 # Mark for copying  # Mark for copying
     my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);      my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
     if (&is_supplemental_title($title)) {      if (&is_supplemental_title($title)) {
           &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
  ($title) = &parse_supplemental_title($title);   ($title) = &parse_supplemental_title($title);
       } elsif ($env{'docs.markedcopy_supplemental'}) {
           &Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
     }      }
     $url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};      $url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
   
Line 1257  ENDPASTE Line 1269  ENDPASTE
 }  }
   
 sub do_paste_from_buffer {  sub do_paste_from_buffer {
     my ($coursenum,$coursedom) = @_;      my ($coursenum,$coursedom,$folder) = @_;
   
     return 0 if (!$env{'form.pastemarked'});      return 0 if (!$env{'form.pastemarked'});
   
Line 1267  sub do_paste_from_buffer { Line 1279  sub do_paste_from_buffer {
 # Maps need to be copied first  # Maps need to be copied first
     if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {      if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
  $title=&mt('Copy of').' '.$title;   $title=&mt('Copy of').' '.$title;
  my $newid=$$.time;          my $newid=$$.int(rand(100)).time;
  $url=~/^(.+)\.(\w+)$/;   my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
  my $newurl=$1.$newid.'.'.$2;          if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
               my $path = $1;
               my $prefix = $2;
               my $ancestor = $3;
               if (length($ancestor) > 10) {
                   $ancestor = substr($ancestor,-10,10);
               }
               $oldid = $path.$prefix.$ancestor;
           }
           my $counter = 0;
           my $newurl=$oldid.$newid.'.'.$ext;
           my $is_unique = &uniqueness_check($newurl);
           while (!$is_unique && $counter < 100) {
               $counter ++;
               $newid ++;
               $newurl = $oldid.$newid;
               $is_unique = &uniqueness_check($newurl);
           }
           if (!$is_unique) {
               if ($url=~/\.page$/) {
                   return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
               } else {
                   return &mt('Paste failed: an error occurred creating a unique URL for the folder');
               }
           }
  my $storefn=$newurl;   my $storefn=$newurl;
  $storefn=~s{^/\w+/$match_domain/$match_username/}{};   $storefn=~s{^/\w+/$match_domain/$match_username/}{};
  &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,   &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
Line 1299  sub do_paste_from_buffer { Line 1335  sub do_paste_from_buffer {
     $url       = &LONCAPA::map::qtunescape($url);      $url       = &LONCAPA::map::qtunescape($url);
 # Now insert the URL at the bottom  # Now insert the URL at the bottom
     my $newidx = &LONCAPA::map::getresidx($url);      my $newidx = &LONCAPA::map::getresidx($url);
       if ($env{'docs.markedcopy_supplemental'}) {
           if ($folder =~ /^supplemental/) {
               $title = $env{'docs.markedcopy_supplemental'};
           } else {
               (undef,undef,$title) = 
                   &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
           }
       } else {
           if ($folder=~/^supplemental/) {
              $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
                     $env{'user.domain'}.'___&&&___'.$title;
           }
       }
   
     $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';      $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
     push(@LONCAPA::map::order, $newidx);      push(@LONCAPA::map::order, $newidx);
 # Store the result  # Store the result
 }  }
   
   sub uniqueness_check {
       my ($newurl) = @_;
       my $unique = 1;
       foreach my $res (@LONCAPA::map::order) {
           my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
           $url=&LONCAPA::map::qtescape($url);
           if ($newurl eq $url) {
               $unique = 0;
               last;    
           }
       }
       return $unique;
   }
   
 my %parameter_type = ( 'randompick'     => 'int_pos',  my %parameter_type = ( 'randompick'     => 'int_pos',
        'hiddenresource' => 'string_yesno',         'hiddenresource' => 'string_yesno',
        'encrypturl'     => 'string_yesno',         'encrypturl'     => 'string_yesno',
Line 1419  sub editor { Line 1483  sub editor {
  }   }
           
  if ($env{'form.pastemarked'}) {   if ($env{'form.pastemarked'}) {
     &do_paste_from_buffer($coursenum,$coursedom);      &do_paste_from_buffer($coursenum,$coursedom,$folder);
     ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);      ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
     return $errtext if ($fatal);      return $errtext if ($fatal);
  }   }
Line 1878  END Line 1942  END
     my $ro_set=      my $ro_set=
     ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');      ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
  $rand_order_text ='   $rand_order_text ='
 <nobr><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></nobr>';     <span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';
     }      }
     if ($ispage) {      if ($ispage) {
         my $pagename=&escape($pagetitle);          my $pagename=&escape($pagetitle);
Line 1973  sub checkonthis { Line 2037  sub checkonthis {
     $r->rflush();      $r->rflush();
     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {      if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
        $r->print("\n<br />");         $r->print("\n<br />");
          if ($level==0) {
              $r->print("<br />");
          }
        for (my $i=0;$i<=$level*5;$i++) {         for (my $i=0;$i<=$level*5;$i++) {
            $r->print('&nbsp;');             $r->print('&nbsp;');
        }         }
Line 1982  sub checkonthis { Line 2049  sub checkonthis {
   my $result=&Apache::lonnet::repcopy(    my $result=&Apache::lonnet::repcopy(
                               &Apache::lonnet::filelocation('',$url));                                &Apache::lonnet::filelocation('',$url));
           if ($result eq 'ok') {            if ($result eq 'ok') {
              $r->print('<font color="green">'.&mt('ok').'</font>');               $r->print('<span class="LC_success">'.&mt('ok').'</span>');
              $r->rflush();               $r->rflush();
              &Apache::lonnet::countacc($url);               &Apache::lonnet::countacc($url);
              $url=~/\.(\w+)$/;               $url=~/\.(\w+)$/;
Line 1992  sub checkonthis { Line 2059  sub checkonthis {
                  for (my $i=0;$i<=$level*5;$i++) {                   for (my $i=0;$i<=$level*5;$i++) {
                      $r->print('&nbsp;');                       $r->print('&nbsp;');
                  }                   }
                  $r->print('- '.&mt('Rendering').': ');                   $r->print('- '.&mt('Rendering:').' ');
  my ($errorcount,$warningcount)=split(/:/,   my ($errorcount,$warningcount)=split(/:/,
        &Apache::lonnet::ssi_body($url,         &Apache::lonnet::ssi_body($url,
        ('grade_target'=>'web',         ('grade_target'=>'web',
Line 2001  sub checkonthis { Line 2068  sub checkonthis {
                      ($warningcount)) {                       ($warningcount)) {
      if ($errorcount) {       if ($errorcount) {
                         $r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.                          $r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
   $errorcount.' '.                            &mt('[quant,_1,error]',$errorcount).'</span>');
   &mt('error(s)').'</span> ');  
                      }                       }
      if ($warningcount) {       if ($warningcount) {
                         $r->print('<span class="LC_warning">'.                          $r->print('<span class="LC_warning">'.
   $warningcount.' '.                            &mt('[quant,_1,warning]',$warningcount).'</span>');
   &mt('warning(s)').'</span>');  
                      }                       }
                  } else {                   } else {
                      $r->print('<span class="LC_success">'.&mt('ok').'</span>');                       $r->print('<span class="LC_success">'.&mt('ok').'</span>');
Line 2025  sub checkonthis { Line 2090  sub checkonthis {
              $r->print('<span class="LC_error">'.&mt('connection down').'</span>');               $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
           } elsif ($result eq 'not_found') {            } elsif ($result eq 'not_found') {
       unless ($url=~/\$/) {        unless ($url=~/\$/) {
   $r->print('<span class="LC_error">'.&mt('not found').'</b></font>');    $r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
       } else {        } else {
   $r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');    $r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
       }        }
           } else {            } else {
              $r->print('<span class="LC_error">'.&mt('access denied').'</span>');               $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
           }            }
       }         }
    }      }
 }  }
   
   

Removed from v.1.310  
changed lines
  Added in v.1.314.2.3


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