Diff for /loncom/interface/londocs.pm between versions 1.197 and 1.202

version 1.197, 2005/07/26 13:30:34 version 1.202, 2005/08/30 14:36:46
Line 155  sub dumpcourse { Line 155  sub dumpcourse {
  my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});   my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
  $r->print('<h3>'.&mt('Copying Files').'</h3>');   $r->print('<h3>'.&mt('Copying Files').'</h3>');
  my $title=$env{'form.authorfolder'};   my $title=$env{'form.authorfolder'};
    my ($ext)=($title=~s/\.(\w+)$//);
  $title=&clean($title);   $title=&clean($title);
    $title.='.'.$ext;
  my %replacehash=();   my %replacehash=();
  foreach (keys %env) {   foreach (keys %env) {
     if ($_=~/^form\.namefor\_(.+)/) {      if ($_=~/^form\.namefor\_(.+)/) {
Line 251  sub dumpcourse { Line 253  sub dumpcourse {
 sub exportbutton {  sub exportbutton {
     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 490  sub create_ims_store { Line 492  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 541  sub build_package { Line 554  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 564  sub build_package { Line 576  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 609  sub build_package { Line 624  sub build_package {
                     }                      }
                 }                  }
                 $pkgdepth = $depth;                  $pkgdepth = $depth;
             } else {  
                 $included = 0;  
             }              }
         }          }
     }      }
Line 645  sub process_content { Line 658  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 699  sub process_content { Line 711  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 782  sub replicate_content { Line 795  sub replicate_content {
         $$message = 'Could not determine name of file for '.$symb."<br />\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 ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;      my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
       my ($dirpath,$container);
     my %allfiles = ();      my %allfiles = ();
     my %codebase = ();      my %codebase = ();
     $url =~ s#([^/]+)$##;      if ($url =~ m-(.*/)([^/]+)$-) {
           $dirpath = $1;
           $container = $2;
       } else {
           $dirpath = $url;
           $container = '';
       }
     &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);      &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);
     foreach my $embed_file (keys(%allfiles)) {      foreach my $embed_file (keys(%allfiles)) {
         my $filename;          my $filename;
Line 809  sub extract_media { Line 829  sub extract_media {
             if ($embed_file =~ m-https?://-) {              if ($embed_file =~ m-https?://-) {
                 next;                           # points to url                  next;                           # points to url
             } else {              } else {
                 $embed_url = $url.$embed_file;  # points to relative path                  $embed_url = $dirpath.$embed_file;  # points to relative path
             }              }
         }          }
         if ($caller eq 'resource') {          if ($caller eq 'resource') {
Line 832  sub extract_media { Line 852  sub extract_media {
             my $copiedfile;              my $copiedfile;
             if ($copiedfile = Apache::File->new('>'.$destination)) {              if ($copiedfile = Apache::File->new('>'.$destination)) {
                 print $copiedfile $embed_content;                  print $copiedfile $embed_content;
                 push @{$href}, .'resources/'.$count.'/res/'.$filename;                  push @{$href}, 'resources/'.$count.'/res/'.$filename;
                 my $attrib_regexp = '';                  my $attrib_regexp = '';
                 if (@{$allfiles{$embed_file}} > 1) {                  if (@{$allfiles{$embed_file}} > 1) {
                     $attrib_regexp = join('|',@{$allfiles{$embed_file}});                      $attrib_regexp = join('|',@{$allfiles{$embed_file}});
Line 840  sub extract_media { Line 860  sub extract_media {
                     $attrib_regexp = $allfiles{$embed_file}[0];                      $attrib_regexp = $allfiles{$embed_file}[0];
                 }                  }
                 $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;                  $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
                 if ($caller eq 'resource' && $url =~ /\.(problem|library)$/) {                  if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
                     $$content =~ s#\Q$embed_file\E#$newname#gi;                      $$content =~ s#\Q$embed_file\E#$newname#gi;
                 }                  }
             }              }
Line 868  sub store_template { Line 888  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';
             }              }
         }          }
     }      }

Removed from v.1.197  
changed lines
  Added in v.1.202


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