[LON-CAPA-cvs] cvs: loncom /interface londocs.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Tue, 26 Jul 2005 16:41:46 -0000
raeburn Tue Jul 26 12:41:46 2005 EDT
Modified files:
/loncom/interface londocs.pm
Log:
IMS compliance. Update all references to embedded objects in .problem and .library LON-CAPA resources.
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.197 loncom/interface/londocs.pm:1.198
--- loncom/interface/londocs.pm:1.197 Tue Jul 26 09:30:34 2005
+++ loncom/interface/londocs.pm Tue Jul 26 12:41:43 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.197 2005/07/26 13:30:34 raeburn Exp $
+# $Id: londocs.pm,v 1.198 2005/07/26 16:41:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -782,16 +782,23 @@
$$message = 'Could not determine name of file for '.$symb."<br />\n";
}
if ($repstatus eq 'ok') {
- $content_name = $count.'/'.$filename;
+ $content_name = 'resources/'.$count.'/'.$filename;
}
return $content_name;
}
sub extract_media {
my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
+ my ($dirpath,$container);
my %allfiles = ();
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);
foreach my $embed_file (keys(%allfiles)) {
my $filename;
@@ -809,7 +816,7 @@
if ($embed_file =~ m-https?://-) {
next; # points to url
} else {
- $embed_url = $url.$embed_file; # points to relative path
+ $embed_url = $dirpath.$embed_file; # points to relative path
}
}
if ($caller eq 'resource') {
@@ -832,7 +839,7 @@
my $copiedfile;
if ($copiedfile = Apache::File->new('>'.$destination)) {
print $copiedfile $embed_content;
- push @{$href}, .'resources/'.$count.'/res/'.$filename;
+ push @{$href}, 'resources/'.$count.'/res/'.$filename;
my $attrib_regexp = '';
if (@{$allfiles{$embed_file}} > 1) {
$attrib_regexp = join('|',@{$allfiles{$embed_file}});
@@ -840,7 +847,7 @@
$attrib_regexp = $allfiles{$embed_file}[0];
}
$$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;
}
}
@@ -868,9 +875,9 @@
close($storetemplate);
}
if ($content_type eq 'external') {
- return $count.'/'.$content_type.'.html';
+ return 'resources/'.$count.'/'.$content_type.'.html';
} else {
- return $count.'/'.$content_type.'.xml';
+ return 'resources/'.$count.'/'.$content_type.'.xml';
}
}
}