Diff for /loncom/interface/londocs.pm between versions 1.189 and 1.216

version 1.189, 2005/06/13 20:23:53 version 1.216, 2006/01/05 21:17:38
Line 166  sub dumpcourse { Line 166  sub dumpcourse {
  $crs=~s/\_/\//g;   $crs=~s/\_/\//g;
  foreach (keys %replacehash) {   foreach (keys %replacehash) {
     my $newfilename=$title.'/'.$replacehash{$_};      my $newfilename=$title.'/'.$replacehash{$_};
       $newfilename=~s/\.(\w+)$//;
       my $ext=$1;
     $newfilename=&clean($newfilename);      $newfilename=&clean($newfilename);
       $newfilename.='.'.$ext;
     my @dirs=split(/\//,$newfilename);      my @dirs=split(/\//,$newfilename);
     my $path='/home/'.$ca.'/public_html';      my $path='/home/'.$ca.'/public_html';
     my $makepath=$path;      my $makepath=$path;
Line 249  sub dumpcourse { Line 252  sub dumpcourse {
 # ------------------------------------------------------ Generate "export" button  # ------------------------------------------------------ Generate "export" button
   
 sub exportbutton {  sub exportbutton {
     return '';  
     return '</td><td bgcolor="#DDDDCC">'.      return '</td><td bgcolor="#DDDDCC">'.
             '<input type="submit" name="exportcourse" value="'.              '<input type="submit" name="exportcourse" value="'.
             &mt('Export Course to IMS').'" />'.              &mt('Export Course to IMS').'" />'.
             &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');      &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
 }  }
   
 sub exportcourse {  sub exportcourse {
Line 491  sub create_ims_store { Line 493  sub create_ims_store {
 ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.  ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
 '  xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.  '  xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
 '  http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".  '  http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
   '  <metadata>
       <schema></schema>
       <imsmd:lom>
         <imsmd:general>
           <imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier>
           <imsmd:title>
             <imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring>
           </imsmd:title>
         </imsmd:general>
       </imsmd:lom>
     </metadata>'."\n".
 '  <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".  '  <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
 '    <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.  '    <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
 ' structure="hierarchical">'."\n".  ' structure="hierarchical">'."\n".
 '      <title>'.$env{'request.'.$env{'request.course.id'}.'.description'}.'</title>'  '      <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'
     } else {      } else {
         $$outcome .= 'An error occurred opening the IMS manifest file.<br />'          $$outcome .= 'An error occurred opening the IMS manifest file.<br />'
 ;  ;
Line 542  sub build_package { Line 555  sub build_package {
     $count = 0;      $count = 0;
     my $imsresources;      my $imsresources;
     my $pkgdepth;      my $pkgdepth;
     my $included = 0;  
     while ($curRes = $it->next()) {      while ($curRes = $it->next()) {
         if ($curRes == $it->BEGIN_MAP()) {          if ($curRes == $it->BEGIN_MAP()) {
             $prevdepth = $depth;              $prevdepth = $depth;
Line 565  sub build_package { Line 577  sub build_package {
                 unless ($curRes->is_sequence()) {                  unless ($curRes->is_sequence()) {
                     $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';                      $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
                 }                  }
                 if (($depth <= $prevdepth) && ($count > 1) && ($included)) {                  my $step = $prevdepth - $depth;
                     print $ims_manifest "\n".'  </item>'."\n";                  if (($step >= 0) && ($count > 1)) {
                       while ($step >= 0) {
                           print $ims_manifest "\n".'  </item>'."\n";
                           $step --;
                       }
                 }                  }
                 $included = 1;  
                 $prevdepth = $depth;                  $prevdepth = $depth;
   
                 my $itementry =                  my $itementry =
Line 610  sub build_package { Line 625  sub build_package {
                     }                      }
                 }                  }
                 $pkgdepth = $depth;                  $pkgdepth = $depth;
             } else {  
                 $included = 0;  
             }              }
         }          }
     }      }
Line 646  sub process_content { Line 659  sub process_content {
     my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;      my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
     my $content_type;      my $content_type;
     my $message;      my $message;
 # find where user is author or co-author  
     my @uploads = ();      my @uploads = ();
     if ($curRes->is_sequence()) {      if ($curRes->is_sequence()) {
         $content_type = 'sequence';          $content_type = 'sequence';
Line 700  sub process_content { Line 712  sub process_content {
         if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'})  {          if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'})  {
             $canedit= 1;              $canedit= 1;
         }          }
   # only include problem code where current user is author
         if ($canedit) {          if ($canedit) {
             $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');              $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
         } else {          } else {
Line 748  sub replicate_content { Line 761  sub replicate_content {
         if ($copiedfile = Apache::File->new('>'.$destination)) {          if ($copiedfile = Apache::File->new('>'.$destination)) {
             my $content;              my $content;
             if ($caller eq 'resource') {              if ($caller eq 'resource') {
                 $content = &Apache::lonnet::getfile('/home/httpd/html/res/'.$url);                  my $respath =  $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
                   my $filepath = &Apache::lonnet::filelocation($respath,$url);
                   $content = &Apache::lonnet::getfile($filepath);
                 if ($content eq -1) {                  if ($content eq -1) {
                     $$message = 'Could not copy file '.$filename;                      $$message = 'Could not copy file '.$filename;
                 } else {                  } else {
                     &extract_media($content,$count,$tempexport,$href,'resource');                      &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource');
                     $repstatus = 'ok';                      $repstatus = 'ok';
                 }                  }
             } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {              } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
Line 760  sub replicate_content { Line 775  sub replicate_content {
                 $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);                  $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
                 if ($repstatus eq 'ok') {                  if ($repstatus eq 'ok') {
                     if ($url =~ /\.html?$/i) {                      if ($url =~ /\.html?$/i) {
                         &extract_media(\$content,$count,$tempexport,$href,'uploaded');                          &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded');
                     }                      }
                 } else {                  } else {
                     $$message = 'Could not render '.$url.' server message - '.$rtncode;                      $$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n";
                 }                  }
             } elsif ($caller eq 'noedit') {              } elsif ($caller eq 'noedit') {
 # Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this.   # Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. 
Line 775  sub replicate_content { Line 790  sub replicate_content {
             }              }
             close($copiedfile);              close($copiedfile);
         } else {          } else {
             $$message = 'Could not open destination file for '.$filename."\n";              $$message = 'Could not open destination file for '.$filename."<br />\n";
         }          }
     } else {      } else {
         $$message = 'Could not determine name of file for '.$symb."\n";          $$message = 'Could not determine name of file for '.$symb."<br />\n";
     }      }
     if ($repstatus eq 'ok') {      if ($repstatus eq 'ok') {
         $content_name = $count.'/'.$filename;          $content_name = 'resources/'.$count.'/'.$filename;
     }      }
     return $content_name;      return $content_name;
 }  }
   
 sub extract_media {  sub extract_media {
     my ($content,$count,$tempexport,$href,$caller) = @_;      my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
 # @$href will contain path to any embedded resources in the content.      my ($dirpath,$container);
 # For LON-CAPA problems this would be images. applets etc.       my %allfiles = ();
 # For uploaded HTML files this would be images etc.      my %codebase = ();
 # paths will be in the form $count/res/$file, and urls in the $content will be rewritten with the new paths.       if ($url =~ m-(.*/)([^/]+)$-) {
           $dirpath = $1;
           $container = $2;
       } else {
           $dirpath = $url;
           $container = '';
       }
       &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);
       foreach my $embed_file (keys(%allfiles)) {
           my $filename;
           if ($embed_file =~ m#([^/]+)$#) {
               $filename = $1;
           } else {
               $filename = $embed_file;
           }
           my $newname = 'res/'.$filename;
           my ($rtncode,$embed_content,$repstatus);
           my $embed_url;
           if ($embed_file =~ m-^/-) {
               $embed_url = $embed_file;           # points to absolute path
           } else {
               if ($embed_file =~ m-https?://-) {
                   next;                           # points to url
               } else {
                   $embed_url = $dirpath.$embed_file;  # points to relative path
               }
           }
           if ($caller eq 'resource') {
               my $respath =  $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';  
               my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url); 
               $embed_content = &Apache::lonnet::getfile($embed_path);
               unless ($embed_content eq -1) {
                   $repstatus = 'ok';
               }
           } elsif ($caller eq 'uploaded') {
               
               $repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
           }
           if ($repstatus eq 'ok') {
               my $destination = $tempexport.'/resources/'.$count.'/res';
               if (!-e "$destination") {
                   mkdir($destination,0755);
               }
               $destination .= '/'.$filename;
               my $copiedfile;
               if ($copiedfile = Apache::File->new('>'.$destination)) {
                   print $copiedfile $embed_content;
                   push @{$href}, 'resources/'.$count.'/res/'.$filename;
                   my $attrib_regexp = '';
                   if (@{$allfiles{$embed_file}} > 1) {
                       $attrib_regexp = join('|',@{$allfiles{$embed_file}});
                   } else {
                       $attrib_regexp = $allfiles{$embed_file}[0];
                   }
                   $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
                   if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
                       $$content =~ s#\Q$embed_file\E#$newname#gi;
                   }
               }
           } else {
               $$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n";
           }
       }
     return;      return;
 }  }
   
Line 812  sub store_template { Line 889  sub store_template {
                 close($storetemplate);                  close($storetemplate);
             }              }
             if ($content_type eq 'external') {              if ($content_type eq 'external') {
                 return $count.'/'.$content_type.'.html';                  return 'resources/'.$count.'/'.$content_type.'.html';
             } else {              } else {
                 return $count.'/'.$content_type.'.xml';                  return 'resources/'.$count.'/'.$content_type.'.xml';
             }              }
         }          }
     }      }
Line 1037  sub editor { Line 1114  sub editor {
                 if ($cmd eq 'del') {                  if ($cmd eq 'del') {
     my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);      my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
     if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&      if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
  ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library)$/)) {   ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
  &Apache::lonnet::removeuploadedurl($url);   &Apache::lonnet::removeuploadedurl($url);
     } else {      } else {
  &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]);   &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]);
Line 1138  sub editor { Line 1215  sub editor {
         $r->print('<table>');          $r->print('<table>');
         foreach (@Apache::lonratedt::order) {          foreach (@Apache::lonratedt::order) {
            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);             my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
      $name=&Apache::lonratsrv::qtescape($name);
      $url=&Apache::lonratsrv::qtescape($url);
            unless ($name) {  $name=(split(/\//,$url))[-1]; }             unless ($name) {  $name=(split(/\//,$url))[-1]; }
            unless ($name) { $idx++; next; }             unless ($name) { $idx++; next; }
            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));             $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
Line 1175  FOLDERINFO Line 1254  FOLDERINFO
 }  }
   
 sub process_file_upload {  sub process_file_upload {
     my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase) = @_;      my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
 # upload a file, if present  # upload a file, if present
     my $parseaction;      my $parseaction;
     if ($env{'form.parserflag'}) {     if ($env{'form.parserflag'}) {
         $parseaction = 'parse';          $parseaction = 'parse';
     }      }
     my $phase_status;      my $phase_status;
     my $folder=$env{'form.folder'};      my $folder=$env{'form.folder'};
     if ($folder eq '' || $folder eq 'supplemental') {      if ($folder eq '') {
         $folder='default';          $folder='default';
     }      }
     if ( ($folder=~/^$1/) || ($1 eq 'default') ) {      if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
         my $errtext='';          my $errtext='';
         my $fatal=0;          my $fatal=0;
         my $container='sequence';          my $container='sequence';
Line 1203  sub process_file_upload { Line 1282  sub process_file_upload {
             return 'failed';              return 'failed';
         }          }
         my $destination = 'docs/';          my $destination = 'docs/';
         if ($folder eq 'default') {          if ($folder =~ /^supplemental/) {
               $destination = 'supplemental/';
           }
           if (($folder eq 'default') || ($folder eq 'supplemental')) {
             $destination .= 'default/';              $destination .= 'default/';
         } elsif ($folder =~ /^default_(\d+)$/) {          } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
             $destination .=  $1.'/';              $destination .=  $2.'/';
         }          }
 # this is for a course, not a user, so set coursedoc flag  # this is for a course, not a user, so set coursedoc flag
 # probably the only place in the system where this should be "1"  # probably the only place in the system where this should be "1"
         my $newidx=&Apache::lonratedt::getresidx();          my $newidx=&Apache::lonratedt::getresidx();
         $destination .= $newidx;          $destination .= $newidx;
         my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,$parseaction,$allfiles,$codebase);          my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
    $parseaction,$allfiles,
    $codebase);
         my $ext='false';          my $ext='false';
         if ($url=~/^http\:\/\//) { $ext='true'; }          if ($url=~/^http\:\/\//) { $ext='true'; }
         $url=~s/\:/\&colon;/g;          $url=~s/\:/\&colon;/g;
Line 1227  sub process_file_upload { Line 1311  sub process_file_upload {
   
         $Apache::lonratedt::resources[$newidx]=          $Apache::lonratedt::resources[$newidx]=
                   $comment.':'.$url.':'.$ext.':normal:res';                    $comment.':'.$url.':'.$ext.':normal:res';
         $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=          $Apache::lonratedt::order[$#Apache::lonratedt::order+1]= $newidx;
                                                               $newidx;          ($errtext,$fatal)=&storemap($coursenum,$coursedom,
         ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);      $folder.'.'.$container);
         if ($fatal) {          if ($fatal) {
             $$upload_output .= '<p><font color="red">'.$errtext.'</font></p>';              $$upload_output .= '<p><font color="red">'.$errtext.'</font></p>';
             return 'failed';              return 'failed';
         } else {          } else {
             if ($parseaction eq 'parse') {              if ($parseaction eq 'parse') {
                 my $total_embedded = keys %{$allfiles};                  my $total_embedded = keys(%{$allfiles});
                 if ($total_embedded > 0) {                  if ($total_embedded > 0) {
                     my $num = 0;                      my $num = 0;
                     $$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />                      $$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />
Line 1247  sub process_file_upload { Line 1331  sub process_file_upload {
    <input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';     <input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
                     $$upload_output .= '<b>Upload embedded files</b>:<br />                      $$upload_output .= '<b>Upload embedded files</b>:<br />
    <table>';     <table>';
                     foreach my $embed_file (keys %{$allfiles}) {                      foreach my $embed_file (keys(%{$allfiles})) {
                         $$upload_output .= '<tr><td>'.$embed_file.                          $$upload_output .= '<tr><td>'.$embed_file.
           '<input name="embedded_item_'.$num.'" type="file">            '<input name="embedded_item_'.$num.'" type="file" />
            <input name="embedded_orig_'.$num.'" type="hidden" value="'.&Apache::lonnet::escape($embed_file).'"/>';             <input name="embedded_orig_'.$num.'" type="hidden" value="'.&Apache::lonnet::escape($embed_file).'" />';
                         my $attrib;                          my $attrib;
                         if (@{$$allfiles{$embed_file}} > 1) {                          if (@{$$allfiles{$embed_file}} > 1) {
                             $attrib = join(':',@{$$allfiles{$embed_file}});                              $attrib = join(':',@{$$allfiles{$embed_file}});
Line 1283  sub process_secondary_uploads { Line 1367  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'};
     my $destination = 'docs/';      my $destination = 'docs/';
     if ($folder eq 'default') {      if ($folder =~ /^supplemental/) {
           $destination = 'supplemental/';
       }
       if (($folder eq 'default') || ($folder eq 'supplemental')) {
         $destination .= 'default/';          $destination .= 'default/';
     } elsif ($folder =~ /^default_(\d+)$/) {      } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
         $destination .=  $1.'/';          $destination .=  $1.'/';
     }      }
     $destination .= $newidx;      $destination .= $newidx;
Line 1366  sub entryline { Line 1453  sub entryline {
                 'ct' => 'Cut',                  'ct' => 'Cut',
  'rn' => 'Rename',   'rn' => 'Rename',
  'cp' => 'Copy');   'cp' => 'Copy');
    my $nocopy=0;
           if ($url=~/\.(page|sequence)$/) {
       foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {
    my ($title,$url,$ext,$type)=split(/\:/,$_);
    if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
       $nocopy=1;
       last;
    }
       }
    }
           my $copylink='&nbsp;';
         if ($env{'form.pagepath'}) {          if ($env{'form.pagepath'}) {
              unless ($nocopy) {
                  $copylink=(<<ENDCOPY);
   <a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'>
   <font size="-2" color="#000099">$lt{'cp'}</font></a></td>
   ENDCOPY
               }
             $line.=(<<END);              $line.=(<<END);
 <form name="entry_$index" action="/adm/coursedocs" method="post">  <form name="entry_$index" action="/adm/coursedocs" method="post">
 <input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />  <input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />
Line 1390  sub entryline { Line 1494  sub entryline {
 <font size="-2" color="#550044">$lt{'ct'}</font></a>  <font size="-2" color="#550044">$lt{'ct'}</font></a>
 <a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'>  <a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'>
 <font size="-2" color="#009900">$lt{'rn'}</font></a>  <font size="-2" color="#009900">$lt{'rn'}</font></a>
 <a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'>  $copylink
 <font size="-2" color="#000099">$lt{'cp'}</font></a></td>  
 END  END
         } else {          } else {
              unless ($nocopy) {
                  $copylink=(<<ENDCOPY);
   <a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'>
   <font size="-2" color="#000099">$lt{'cp'}</font></a></td>
   ENDCOPY
               }
             $line.=(<<END);               $line.=(<<END); 
 <form name="entry_$index" action="/adm/coursedocs" method="post">  <form name="entry_$index" action="/adm/coursedocs" method="post">
 <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />  <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
Line 1416  END Line 1525  END
 <font size="-2" color="#550044">$lt{'ct'}</font></a>  <font size="-2" color="#550044">$lt{'ct'}</font></a>
 <a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'>  <a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'>
 <font size="-2" color="#009900">$lt{'rn'}</font></a>  <font size="-2" color="#009900">$lt{'rn'}</font></a>
 <a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'>  $copylink
 <font size="-2" color="#000099">$lt{'cp'}</font></a></td>  
 END  END
         }          }
     }      }
Line 1447  END Line 1555  END
     &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);      &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
  }   }
     }      }
     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;      $url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-;
     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {      if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
  my $symb=&Apache::lonnet::symbclean(   my $symb=&Apache::lonnet::symbclean(
           &Apache::lonnet::declutter('uploaded/'.            &Apache::lonnet::declutter('uploaded/'.
Line 1480  END Line 1588  END
  }   }
     }      }
     my $parameterset='&nbsp;';      my $parameterset='&nbsp;';
     if ($isfolder) {      if ($isfolder || $extension eq 'sequence') {
  my $foldername=&Apache::lonnet::escape($foldertitle);   my $foldername=&Apache::lonnet::escape($foldertitle);
  my $folderpath=$env{'form.folderpath'};   my $folderpath=$env{'form.folderpath'};
  if ($folderpath) { $folderpath.='&' };   if ($folderpath) { $folderpath.='&' };
Line 1514  END Line 1622  END
     }      }
     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.      $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
  '" border="0"></a></td>'.   '" border="0"></a></td>'.
         "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>";          "<td bgcolor='#FFFFBB'><a href=\"$url\">$title</a></td>";
     if (($allowed) && ($folder!~/^supplemental/)) {      if (($allowed) && ($folder!~/^supplemental/)) {
   my %lt=&Apache::lonlocal::texthash(    my %lt=&Apache::lonlocal::texthash(
        'hd' => 'Hidden',         'hd' => 'Hidden',
Line 1634  sub checkonthis { Line 1742  sub checkonthis {
   
   
 #  #
   # ----------------------------------------------------------------- List Symbs
   # 
   sub list_symbs {
      my $r=shift; 
      my $html=&Apache::lonxml::xmlbegin();
      $r->print($html.'<head><title>Symb List</title></head>'.
                 &Apache::loncommon::bodytag('Symb List'));
      my $navmap = Apache::lonnavmaps::navmap->new();
      $r->print("<pre>\n");
      foreach my $res ($navmap->retrieveResources()) {
          $r->print($res->compTitle()."\t".$res->symb()."\n");
      }
      $r->print("\n</pre>\n");
      $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
   }
   
   
   #
 # -------------------------------------------------------------- Verify Content  # -------------------------------------------------------------- Verify Content
 #   # 
 sub verifycontent {  sub verifycontent {
Line 1665  sub verifycontent { Line 1791  sub verifycontent {
      &mt('Return to DOCS').'</a>');       &mt('Return to DOCS').'</a>');
 }  }
   
   
 # -------------------------------------------------------------- Check Versions  # -------------------------------------------------------------- Check Versions
   
   sub devalidateversioncache {
       my $src=shift;
       &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
     &Apache::lonnet::clutter($src));
   }
   
 sub checkversions {  sub checkversions {
     my $r=shift;      my $r=shift;
     my $html=&Apache::lonxml::xmlbegin();      my $html=&Apache::lonxml::xmlbegin();
Line 1693  sub checkversions { Line 1826  sub checkversions {
  foreach (keys %hash) {   foreach (keys %hash) {
     if ($_=~/^ids\_(\/res\/.+)$/) {      if ($_=~/^ids\_(\/res\/.+)$/) {
  $newsetversions{$1}='mostrecent';   $newsetversions{$1}='mostrecent';
                   &devalidateversioncache($1);
     }      }
  }   }
     } elsif ($env{'form.setcurrent'}) {      } elsif ($env{'form.setcurrent'}) {
Line 1702  sub checkversions { Line 1836  sub checkversions {
  my $getvers=&Apache::lonnet::getversion($1);   my $getvers=&Apache::lonnet::getversion($1);
  if ($getvers>0) {   if ($getvers>0) {
     $newsetversions{$1}=$getvers;      $newsetversions{$1}=$getvers;
       &devalidateversioncache($1);
  }   }
     }      }
  }   }
Line 1712  sub checkversions { Line 1847  sub checkversions {
  my $src=$1;   my $src=$1;
  if (($env{$_}) && ($env{$_} ne $setversions{$src})) {   if (($env{$_}) && ($env{$_} ne $setversions{$src})) {
     $newsetversions{$src}=$env{$_};      $newsetversions{$src}=$env{$_};
       &devalidateversioncache($src);
  }   }
     }      }
  }   }
Line 1941  sub changewarning { Line 2077  sub changewarning {
  if (defined($env{'form.pagepath'})) {   if (defined($env{'form.pagepath'})) {
     $pathvar='pagepath';      $pathvar='pagepath';
     $path=&Apache::lonnet::escape($env{'form.pagepath'});      $path=&Apache::lonnet::escape($env{'form.pagepath'});
     $path.='&amp;symb='.&Apache::lonnet::escape($env{'form.pagesymb'});      $path.='&amp;pagesymb='.&Apache::lonnet::escape($env{'form.pagesymb'});
  }   }
  $url='/adm/coursedocs?'.$pathvar.'='.$path;   $url='/adm/coursedocs?'.$pathvar.'='.$path;
     }      }
Line 1967  sub handler { Line 2103  sub handler {
     return OK if $r->header_only;      return OK if $r->header_only;
   
 # --------------------------------------------- Initialize help topics for this  # --------------------------------------------- Initialize help topics for this
   foreach ('Adding_Course_Doc','Main_Course_Documents',      foreach ('Adding_Course_Doc','Main_Course_Documents',
            'Adding_External_Resource','Navigate_Content',       'Adding_External_Resource','Navigate_Content',
            'Adding_Folders','Docs_Overview', 'Load_Map',       'Adding_Folders','Docs_Overview', 'Load_Map',
            'Supplemental','Score_Upload_Form','Adding_Pages',       'Supplemental','Score_Upload_Form','Adding_Pages',
            'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',       'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
    'Check_Resource_Versions','Verify_Content') {       'Check_Resource_Versions','Verify_Content') {
       $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);   $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
   }      }
     # Composite help files      # Composite help files
     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(      $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
     'Docs_About_Syllabus,Docs_Editing_Templated_Pages');      'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
Line 1988  sub handler { Line 2124  sub handler {
   'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');    'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');      $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
   
   if ($env{'form.verify'}) {  # does this user have privileges to modify docs
       my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
   
     if ($allowed && $env{'form.verify'}) {
       &verifycontent($r);        &verifycontent($r);
   } elsif ($env{'form.versions'}) {    } elsif ($allowed && $env{'form.listsymbs'}) {
         &list_symbs($r);
     } elsif ($allowed && $env{'form.versions'}) {
       &checkversions($r);        &checkversions($r);
   } elsif ($env{'form.dumpcourse'}) {    } elsif ($allowed && $env{'form.dumpcourse'}) {
       &dumpcourse($r);        &dumpcourse($r);
   } elsif ($env{'form.exportcourse'}) {    } elsif ($allowed && $env{'form.exportcourse'}) {
       &exportcourse($r);        &exportcourse($r);
   } else {    } else {
 # is this a standard course?  # is this a standard course?
Line 2003  sub handler { Line 2144  sub handler {
     my $forcestandard = 0;      my $forcestandard = 0;
     my $forcesupplement;      my $forcesupplement;
     my $script='';      my $script='';
     my $allowed;  
     my $events='';      my $events='';
     my $showdoc=0;      my $showdoc=0;
     my $containertag;      my $containertag;
Line 2029  sub handler { Line 2169  sub handler {
     }      }
     unless ($showdoc) { # got called from remote      unless ($showdoc) { # got called from remote
        if (($env{'form.folder'}=~/^default_/) ||          if (($env{'form.folder'}=~/^default_/) || 
           ($env{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {            ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
            $forcestandard = 1;             $forcestandard = 1;
        }          } 
        $forcesupplement=($env{'form.folder'}=~/^supplemental_/);         $forcesupplement=($env{'form.folder'}=~/^supplemental_/);
   
 # does this user have privileges to post, etc?  
        $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});  
        if ($allowed) {          if ($allowed) { 
          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);           &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
          $script=&Apache::lonratedt::editscript('simple');            $script=&Apache::lonratedt::editscript('simple'); 
Line 2242  ENDNEWSCRIPT Line 2380  ENDNEWSCRIPT
   if ($allowed) {    if ($allowed) {
       if (($env{'form.uploaddoc.filename'}) &&                                               ($env{'form.cmd'}=~/^upload_(\w+)/)) {        if (($env{'form.uploaddoc.filename'}) &&                                               ($env{'form.cmd'}=~/^upload_(\w+)/)) {
 # Process file upload - phase one - upload and parse primary file.    # Process file upload - phase one - upload and parse primary file.  
           $upload_result = &process_file_upload(\$upload_output,$coursenum,$coursedom,\%allfiles,\%codebase);            $upload_result = &process_file_upload(\$upload_output,$coursenum,
    $coursedom,\%allfiles,
    \%codebase,$1);
           if ($upload_result eq 'phasetwo') {            if ($upload_result eq 'phasetwo') {
               $r->print($upload_output);                $r->print($upload_output);
           }            }
Line 2308  ENDNEWSCRIPT Line 2448  ENDNEWSCRIPT
                   my $saveresult;                    my $saveresult;
                   my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};                    my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
                   my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};                    my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
                   my $docuhome=$env{'course.'.$env{'request.course.id'}.'.home'};                    my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
                   my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,$docuhome,\$saveresult);  
               } else {                } else {
                   &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);                     &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus); 
               }                }
Line 2356  ENDNEWSCRIPT Line 2495  ENDNEWSCRIPT
        my %lt=&Apache::lonlocal::texthash(         my %lt=&Apache::lonlocal::texthash(
  'vc' => 'Verify Content',   'vc' => 'Verify Content',
  'cv' => 'Check/Set Resource Versions',   'cv' => 'Check/Set Resource Versions',
    'ls' => 'List Symbs',
   );    );
   
        my $folderpath=$env{'form.folderpath'};         my $folderpath=$env{'form.folderpath'};
Line 2390  $uploadtag Line 2530  $uploadtag
     <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}      <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
 $dumpbut  $dumpbut
 $exportbut  $exportbut
 </td></tr></table>  </td><!-- <td bgcolor="#DDDDCC">
       <input type="submit" name="listsymbs" value="$lt{'ls'}" />
   </td>--></tr></table>
 </form>  </form>
 ENDCOURSEVERIFY  ENDCOURSEVERIFY
        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',         $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
Line 2445  $uploadtag Line 2587  $uploadtag
 <input type="hidden" name="cmd" value="upload_default">  <input type="hidden" name="cmd" value="upload_default">
 <br />  <br />
 <nobr>  <nobr>
 $lt{'parse'}?  <label>$lt{'parse'}?
 <input type="checkbox" name="parserflag" />  <input type="checkbox" name="parserflag" />
   </label>
 </nobr>  </nobr>
 <br />  <br />
 <br />  <br />
Line 2491  $uploadtag Line 2634  $uploadtag
 value="$lt{'extr'}" /> $help{'Adding_External_Resource'}  value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/imsimportdocs" method="post" name="ims">  <br /><form action="/adm/imsimportdocs" method="post" name="ims">
 <input type="hidden" name="folder" value="$folder" />  <input type="hidden" name="folder" value="$folder" />
 <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />  <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
 </nobr>  </nobr>
Line 2501  ENDFORM Line 2644  ENDFORM
        $r->print('</td><td bgcolor="#DDDDDD">');         $r->print('</td><td bgcolor="#DDDDDD">');
        unless ($env{'form.pagepath'}) {         unless ($env{'form.pagepath'}) {
            $r->print(<<ENDFORM);             $r->print(<<ENDFORM);
 <form action="/adm/coursedocs" method="post" name="newfolder">  <br /><form action="/adm/coursedocs" method="post" name="newfolder">
 <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />  <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2510  onClick="javascript:makenewfolder(this.f Line 2653  onClick="javascript:makenewfolder(this.f
 value="$lt{'newf'}" />$help{'Adding_Folders'}  value="$lt{'newf'}" />$help{'Adding_Folders'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newpage">  <br /><form action="/adm/coursedocs" method="post" name="newpage">
 <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />  <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2519  onClick="javascript:makenewpage(this.for Line 2662  onClick="javascript:makenewpage(this.for
 value="$lt{'newp'}" />$help{'Adding_Pages'}  value="$lt{'newp'}" />$help{'Adding_Pages'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newsyl">  <br /><form action="/adm/coursedocs" method="post" name="newsyl">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail"   <input type=hidden name="importdetail" 
 value="Syllabus=/public/$coursedom/$coursenum/syllabus">  value="Syllabus=/public/$coursedom/$coursenum/syllabus">
Line 2528  value="Syllabus=/public/$coursedom/$cour Line 2671  value="Syllabus=/public/$coursedom/$cour
  $help{'Syllabus'}   $help{'Syllabus'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newnav">  <br /><form action="/adm/coursedocs" method="post" name="newnav">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail"   <input type=hidden name="importdetail" 
 value="Navigate Content=/adm/navmaps">  value="Navigate Content=/adm/navmaps">
Line 2537  value="Navigate Content=/adm/navmaps"> Line 2680  value="Navigate Content=/adm/navmaps">
 $help{'Navigate_Content'}  $help{'Navigate_Content'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newsmppg">  <br /><form action="/adm/coursedocs" method="post" name="newsmppg">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2545  $uploadtag Line 2688  $uploadtag
 onClick="javascript:makesmppage();" /> $help{'Simple Page'}  onClick="javascript:makesmppage();" /> $help{'Simple Page'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newsmpproblem">  <br /><form action="/adm/coursedocs" method="post" name="newsmpproblem">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2553  $uploadtag Line 2696  $uploadtag
 onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}  onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newexamupload">  <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2562  onClick="javascript:makeexamupload();" / Line 2705  onClick="javascript:makeexamupload();" /
 $help{'Score_Upload_Form'}  $help{'Score_Upload_Form'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newbul">  <br /><form action="/adm/coursedocs" method="post" name="newbul">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2571  onClick="javascript:makebulboard();" /> Line 2714  onClick="javascript:makebulboard();" />
 $help{'Bulletin Board'}  $help{'Bulletin Board'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newaboutme">  <br /><form action="/adm/coursedocs" method="post" name="newaboutme">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail"   <input type=hidden name="importdetail" 
 value="$plainname=/adm/$udom/$uname/aboutme">  value="$plainname=/adm/$udom/$uname/aboutme">
Line 2580  value="$plainname=/adm/$udom/$uname/abou Line 2723  value="$plainname=/adm/$udom/$uname/abou
 $help{'My Personal Info'}  $help{'My Personal Info'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newaboutsomeone">  <br /><form action="/adm/coursedocs" method="post" name="newaboutsomeone">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2600  $uploadtag Line 2743  $uploadtag
 onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}  onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="newexamupload">  <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
 $uploadtag  $uploadtag
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2643  ENDBLOCK Line 2786  ENDBLOCK
 <tr><td bgcolor="#DDDDDD">  <tr><td bgcolor="#DDDDDD">
 <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">  <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
 <input type="file" name="uploaddoc" size="40">  <input type="file" name="uploaddoc" size="40">
 <br />$lt{'comment'}:<br />  <br />
   <br />
   <nobr>
   <label>$lt{'parse'}?
   <input type="checkbox" name="parserflag" />
   </label>
   </nobr>
   <br /><br />
   $lt{'comment'}:<br />
 <textarea cols=50 rows=4 name='comment'>  <textarea cols=50 rows=4 name='comment'>
 </textarea>  </textarea>
 <br />  <br />
Line 2665  onClick="javascript:makenewfolder(this.f Line 2816  onClick="javascript:makenewfolder(this.f
 value="$lt{'newf'}" /> $help{'Adding_Folders'}  value="$lt{'newf'}" /> $help{'Adding_Folders'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="supnewext">  <br /><form action="/adm/coursedocs" method="post" name="supnewext">
 <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />  <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail" value="">  <input type=hidden name="importdetail" value="">
 <nobr>  <nobr>
Line 2674  onClick="javascript:makenewext('supnewex Line 2825  onClick="javascript:makenewext('supnewex
 value="$lt{'extr'}" /> $help{'Adding_External_Resource'}  value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="supnewsyl">  <br /><form action="/adm/coursedocs" method="post" name="supnewsyl">
 <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />  <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail"   <input type=hidden name="importdetail" 
 value="Syllabus=/public/$coursedom/$coursenum/syllabus">  value="Syllabus=/public/$coursedom/$coursenum/syllabus">
Line 2683  value="Syllabus=/public/$coursedom/$cour Line 2834  value="Syllabus=/public/$coursedom/$cour
 $help{'Syllabus'}  $help{'Syllabus'}
 </nobr>  </nobr>
 </form>  </form>
 <form action="/adm/coursedocs" method="post" name="subnewaboutme">  <br /><form action="/adm/coursedocs" method="post" name="subnewaboutme">
 <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />  <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
 <input type=hidden name="importdetail"   <input type=hidden name="importdetail" 
 value="$plainname=/adm/$udom/$uname/aboutme">  value="$plainname=/adm/$udom/$uname/aboutme">

Removed from v.1.189  
changed lines
  Added in v.1.216


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