Diff for /loncom/interface/londocs.pm between versions 1.306 and 1.319

version 1.306, 2008/05/22 17:47:33 version 1.319, 2008/12/11 14:55:15
Line 26 Line 26
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
   
   
 package Apache::londocs;  package Apache::londocs;
   
 use strict;  use strict;
Line 53  my %alreadyseen=(); Line 55  my %alreadyseen=();
   
 my $hadchanges;  my $hadchanges;
   
 # Available help topics  
   
 my %help=();  my %help=();
   
 # Mapread read maps into LONCAPA::map:: global arrays   
 # @order and @resources, determines status  
 # sets @order - pointer to resources in right order  
 # sets @resources - array with the resources with correct idx  
 #  
   
 sub mapread {  sub mapread {
     my ($coursenum,$coursedom,$map)=@_;      my ($coursenum,$coursedom,$map)=@_;
Line 81  sub storemap { Line 78  sub storemap {
     return ($errtext,0);      return ($errtext,0);
 }  }
   
 # ----------------------------------------- Return hash with valid author names  
   
 sub authorhosts {  sub authorhosts {
     my %outhash=();      my %outhash=();
Line 116  sub authorhosts { Line 113  sub authorhosts {
     }      }
     return ($home,$other,%outhash);      return ($home,$other,%outhash);
 }  }
 # ------------------------------------------------------ Generate "dump" button  
   
 sub dumpbutton {  sub dumpbutton {
     my ($home,$other,%outhash)=&authorhosts();      my ($home,$other,%outhash)=&authorhosts();
Line 141  sub clean { Line 138  sub clean {
     $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;      $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
     return $title;      return $title;
 }  }
 # -------------------------------------------------------- Actually dump course  
   
   
 sub dumpcourse {  sub dumpcourse {
     my ($r) = @_;      my ($r) = @_;
Line 228  sub dumpcourse { Line 226  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 251  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>');
     }      }
 }  }
   
 # ------------------------------------------------------ Generate "export" button  
   
 sub exportbutton {  sub exportbutton {
     my $type = &Apache::loncommon::course_type();      my $type = &Apache::loncommon::course_type();
Line 264  sub exportbutton { Line 271  sub exportbutton {
     &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'</div>';      &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'</div>';
 }  }
   
   
   
 sub exportcourse {  sub exportcourse {
     my $r=shift;      my $r=shift;
     my $type = &Apache::loncommon::course_type();      my $type = &Apache::loncommon::course_type();
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 818  sub extract_media { Line 827  sub extract_media {
         $dirpath = $url;          $dirpath = $url;
         $container = '';          $container = '';
     }      }
     &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);      &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
     foreach my $embed_file (keys(%allfiles)) {      foreach my $embed_file (keys(%allfiles)) {
         my $filename;          my $filename;
         if ($embed_file =~ m#([^/]+)$#) {          if ($embed_file =~ m#([^/]+)$#) {
Line 902  sub store_template { Line 911  sub store_template {
     }      }
 }  }
   
 # Imports the given (name, url) resources into the course  
 # coursenum, coursedom, and folder must precede the list  
 sub group_import {  sub group_import {
     my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;      my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
   
Line 924  sub group_import { Line 932  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 949  sub group_import { Line 957  sub group_import {
 }  }
   
 sub breadcrumbs {  sub breadcrumbs {
     my ($where)=@_;      my ($where,$allowed,$type)=@_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     my (@folders);      my (@folders);
     if ($env{'form.pagepath'}) {      if ($env{'form.pagepath'}) {
Line 966  sub breadcrumbs { Line 974  sub breadcrumbs {
     my $is_random_order=0;      my $is_random_order=0;
     while (@folders) {      while (@folders) {
  my $folder=shift(@folders);   my $folder=shift(@folders);
  my $foldername=shift(@folders);      my $foldername=shift(@folders);
  if ($folderpath) {$folderpath.='&';}   if ($folderpath) {$folderpath.='&';}
  $folderpath.=$folder.'&'.$foldername;   $folderpath.=$folder.'&'.$foldername;
  my $url='/adm/coursedocs?folderpath='.   my $url='/adm/coursedocs?folderpath='.
Line 982  sub breadcrumbs { Line 990  sub breadcrumbs {
             if ($2) { $ishidden=1; }              if ($2) { $ishidden=1; }
             if ($3) { $isencrypted=1; }              if ($3) { $isencrypted=1; }
     if ($4 ne '') { $is_random_order = 1; }      if ($4 ne '') { $is_random_order = 1; }
               if ($folder eq 'supplemental') {
                   if ($allowed) {
                       $name = &mt('Supplemental '.$type.' Documents');
                   } else {
                       $name = &mt($type.' Documents');
                   }
               }
     &Apache::lonhtmlcommon::add_breadcrumb(      &Apache::lonhtmlcommon::add_breadcrumb(
       {'href'=>$url.$cpinfo,        {'href'=>$url.$cpinfo,
        'title'=>$name,         'title'=>$name,
Line 1058  sub log_docs { Line 1073  sub log_docs {
 }  }
   
   
 #  
 # Docs Change Log  
 #  
 sub docs_change_log {  sub docs_change_log {
     my ($r)=@_;      my ($r)=@_;
     my $folder=$env{'form.folder'};      my $folder=$env{'form.folder'};
Line 1201  sub update_paste_buffer { Line 1216  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 1250  ENDPASTE Line 1268  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 1292  sub do_paste_from_buffer { Line 1310  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
Line 1370  sub handle_edit_cmd { Line 1402  sub handle_edit_cmd {
 }  }
   
 sub editor {  sub editor {
     my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;      my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
   
     my $container= ($env{'form.pagepath'}) ? 'page'      my $container= ($env{'form.pagepath'}) ? 'page'
                            : 'sequence';                             : 'sequence';
Line 1387  sub editor { Line 1419  sub editor {
     }      }
           
     my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=      my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
  &breadcrumbs($folder);   &breadcrumbs($folder,$allowed,$type);
     $r->print($breadcrumbtrail);      $r->print($breadcrumbtrail);
           
 # ------------------------------------------------------------ Process commands  # ------------------------------------------------------------ Process commands
Line 1412  sub editor { Line 1444  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 1489  sub editor { Line 1521  sub editor {
  $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');   $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
     }      }
     $r->print("\n</table>\n");      $r->print("\n</table>\n");
           if ($allowed) {
     &print_paste_buffer($r,$container);          &print_paste_buffer($r,$container);
       }
     return;      return;
 }  }
   
Line 1571  sub process_file_upload { Line 1604  sub process_file_upload {
   
                     $$upload_output .=                       $$upload_output .= 
  'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.   'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
  &ask_for_embedded_content('/adm/coursedocs',   &Apache::loncommon::ask_for_embedded_content(
   $state,$allfiles,$codebase);                              '/adm/coursedocs',$state,$allfiles,$codebase);
                 } else {                  } else {
                     $$upload_output .= 'No embedded items identified<br />';                      $$upload_output .= 'No embedded items identified<br />';
                 }                  }
Line 1582  sub process_file_upload { Line 1615  sub process_file_upload {
     return $phase_status;      return $phase_status;
 }  }
   
 sub ask_for_embedded_content {  
     my ($actionurl,$state,$allfiles,$codebase,$args)=@_;  
     my $upload_output = '  
    <form name="upload_embedded" action="'.$actionurl.'"  
                   method="post" enctype="multipart/form-data">';  
     $upload_output .= $state;  
     $upload_output .= '<b>Upload embedded files</b>:<br />'.  
  &Apache::loncommon::start_data_table();  
   
     my $num = 0;  
     foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%{$allfiles})) {  
  $upload_output .= &Apache::loncommon::start_data_table_row().  
     '<td>'.$embed_file.'</td><td>';  
  if ($args->{'ignore_remote_references'}  
     && $embed_file =~ m{^\w+://}) {  
     $upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>';  
  } elsif ($args->{'error_on_invalid_names'}  
     && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) {  
       
     $upload_output.='<span class="LC_warning">'.&mt("Invalid characters").'</span>';  
       
  } else {  
   
     $upload_output .='  
            <input name="embedded_item_'.$num.'" type="file" value="bob" />  
            <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';  
     my $attrib = join(':',@{$$allfiles{$embed_file}});  
     $upload_output .=  
  "\n\t\t".  
  '<input name="embedded_attrib_'.$num.'" type="hidden" value="'.  
  $attrib.'" />';  
     if (exists($$codebase{$embed_file})) {  
  $upload_output .=   
     "\n\t\t".  
     '<input name="codebase_'.$num.'" type="hidden" value="'.  
     &escape($$codebase{$embed_file}).'" />';  
     }  
  }  
  $upload_output .= '</td>'.&Apache::loncommon::end_data_table_row();  
  $num++;  
     }  
     $upload_output .= &Apache::loncommon::end_data_table().'<br />  
    <input type ="hidden" name="number_embedded_items" value="'.$num.'" />  
    <input type ="submit" value="'.&mt('Upload Listed Files').'" />  
    '.&mt('(only files for which a location has been provided will be uploaded)').'  
    </form>';  
     return $upload_output;  
 }  
   
 sub process_secondary_uploads {  sub process_secondary_uploads {
     my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;      my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
     my $folder=$env{'form.folder'};      my $folder=$env{'form.folder'};
Line 1919  END Line 1903  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 1979  ENDPARMS Line 1963  ENDPARMS
     return $line;      return $line;
 }  }
   
 # ---------------------------------------------------------------- tie the hash  =pod
   
   =item tiehash()
   
   tie the hash
   
   =cut
   
 sub tiehash {  sub tiehash {
     my ($mode)=@_;      my ($mode)=@_;
Line 2005  sub untiehash { Line 1995  sub untiehash {
     return OK;      return OK;
 }  }
   
 # --------------------------------------------------------------- check on this  
   
   
 sub checkonthis {  sub checkonthis {
     my ($r,$url,$level,$title)=@_;      my ($r,$url,$level,$title)=@_;
Line 2014  sub checkonthis { Line 2005  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 2023  sub checkonthis { Line 2017  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 2033  sub checkonthis { Line 2027  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 2042  sub checkonthis { Line 2036  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 2066  sub checkonthis { Line 2058  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>');
           }            }
       }         }
    }      }
 }  }
   
   
 #  
 # ----------------------------------------------------------------- List Symbs  =pod
 #   
   =item list_symbs()
   
   List Symbs
   
   =cut
   
 sub list_symbs {  sub list_symbs {
     my ($r) = @_;      my ($r) = @_;
   
Line 2096  sub list_symbs { Line 2094  sub list_symbs {
 }  }
   
   
 #  
 # -------------------------------------------------------------- Verify Content  
 #   
 sub verifycontent {  sub verifycontent {
     my ($r) = @_;      my ($r) = @_;
     my $type = &Apache::loncommon::course_type();      my $type = &Apache::loncommon::course_type();
Line 2129  sub verifycontent { Line 2125  sub verifycontent {
 }  }
   
   
 # -------------------------------------------------------------- Check Versions  
   
 sub devalidateversioncache {  sub devalidateversioncache {
     my $src=shift;      my $src=shift;
     &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.      &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
Line 2433  sub changewarning { Line 2427  sub changewarning {
 $help{'Caching'}.'</span></h3></form>'."\n\n");  $help{'Caching'}.'</span></h3></form>'."\n\n");
 }  }
   
 # =========================================== Breadcrumbs for special functions  
   
 sub init_breadcrumbs {  sub init_breadcrumbs {
     my ($form,$text)=@_;      my ($form,$text)=@_;
Line 2449  sub init_breadcrumbs { Line 2442  sub init_breadcrumbs {
     bug=>'Instructor Interface'});      bug=>'Instructor Interface'});
 }  }
   
 # ================================================================ Main Handler  
   
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
Line 2513  sub handler { Line 2508  sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['folderpath','pagepath',      ['folderpath','pagepath',
      'pagesymb']);       'pagesymb']);
   # No folderpath, no pagepath, see if we have something stored
       if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
           &Apache::loncommon::restore_course_settings('docs_folderpath',
                                                 {'folderpath' => 'scalar'});
       }
       if (!$env{'form.folderpath'}) {
           &Apache::loncommon::restore_course_settings('docs_folderpath',
                                                 {'pagepath' => 'scalar'});
       }
       if ($env{'form.pagepath'}) {
          $env{'form.folderpath'}='';
       }
       if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
           $env{'form.folderpath'} = 'supplemental&'.
                                     &escape(&mt('Supplemental '.$type.' Documents')).'&'.
                                     $env{'form.folderpath'};
       }
       &Apache::loncommon::store_course_settings('docs_folderpath',
                                                   {'pagepath' => 'scalar',
                                                    'folderpath' => 'scalar'});
     if ($env{'form.folderpath'}) {      if ($env{'form.folderpath'}) {
  my (@folderpath)=split('&',$env{'form.folderpath'});   my (@folderpath)=split('&',$env{'form.folderpath'});
  $env{'form.foldername'}=&unescape(pop(@folderpath));   $env{'form.foldername'}=&unescape(pop(@folderpath));
Line 2563  sub handler { Line 2578  sub handler {
     }      }
 # -------------------------------------------------------------------- Body tag  # -------------------------------------------------------------------- Body tag
     $script = '<script type="text/javascript">'."\n".$script."\n".'</script>';      $script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
    my @brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
     $r->print(&Apache::loncommon::start_page("$type Documents", $script,      $r->print(&Apache::loncommon::start_page("$type Documents", $script,
      {'force_register' => $showdoc,}).       {'force_register' => $showdoc, bread_crumbs => @brcrum}).
       &Apache::loncommon::help_open_menu('','',273,'RAT'));        &Apache::loncommon::help_open_menu('','',273,'RAT'));
       
   my %allfiles = ();    my %allfiles = ();
Line 2774  ENDCOURSEVERIFY Line 2790  ENDCOURSEVERIFY
        }         }
        $hadchanges=0;         $hadchanges=0;
        my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
    $upload_output);     $upload_output,$type);
        if ($error) {         if ($error) {
    $r->print('<p><span class="LC_error">'.$error.'</span></p>');     $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }         }
Line 3020  ENDBLOCK Line 3036  ENDBLOCK
    $folder='supplemental';     $folder='supplemental';
        }         }
        if ($folder =~ /^supplemental$/ &&         if ($folder =~ /^supplemental$/ &&
    $env{'form.folderpath'} =~ /^default\&/) {     (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
    $env{'form.folderpath'}='supplemental&'.            $env{'form.folderpath'} = 'supplemental&'.
        &escape(&mt('Supplemental '.$type.' Documents'));                                      &escape(&mt('Supplemental '.$type.' Documents'));
        }         }
        my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed);         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
        if ($error) {         if ($error) {
    $r->print('<p><span class="LC_error">'.$error.'</span></p>');     $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }         }
Line 3334  ENDNEWSCRIPT Line 3350  ENDNEWSCRIPT
 }  }
 1;  1;
 __END__  __END__
   
   
   =head1 NAME
   
   Apache::londocs.pm
   
   =head1 SYNOPSIS
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   =head1 SUBROUTINES
   
   =over
   
   =item %help=()
   
   Available help topics
   
   =item mapread()
   
   Mapread read maps into LONCAPA::map:: global arrays 
   @order and @resources, determines status
   sets @order - pointer to resources in right order
   sets @resources - array with the resources with correct idx
   
   =item authorhosts()
   
   Return hash with valid author names
   
   =item dumpbutton()
   
   Generate "dump" button
   
   =item clean()
   
   =item dumpcourse()
   
       Actually dump course
   
   
   =item exportbutton()
   
       Generate "export" button
   
   =item exportcourse()
   
   =item create_ims_store()
   
   =item build_package()
   
   =item get_dependencies()
   
   =item process_content()
   
   =item replicate_content()
   
   =item extract_media()
   
   =item store_template()
   
   =item group_import()
   
       Imports the given (name, url) resources into the course
       coursenum, coursedom, and folder must precede the list
   
   =item breadcrumbs()
   
   =item log_docs()
   
   =item docs_change_log()
   
   =item update_paste_buffer()
   
   =item print_paste_buffer()
   
   =item do_paste_from_buffer()
   
   =item update_parameter()
   
   =item handle_edit_cmd()
   
   =item editor()
   
   =item process_file_upload()
   
   =item process_secondary_uploads()
   
   =item is_supplemental_title()
   
   =item parse_supplemental_title()
   
   =item entryline()
   
   =item tiehash()
   
   =item untiehash()
   
   =item checkonthis()
   
   check on this
   
   =item verifycontent()
   
   Verify Content
   
   =item devalidateversioncache() & checkversions()
   
   Check Versions
   
   =item mark_hash_old()
   
   =item is_hash_old()
   
   =item changewarning()
   
   =item init_breadcrumbs()
   
   Breadcrumbs for special functions
   
   =back
   
   =cut

Removed from v.1.306  
changed lines
  Added in v.1.319


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