version 1.716, 2025/01/03 02:10:55
|
version 1.717, 2025/01/04 01:34:57
|
Line 995 ENDJS
|
Line 995 ENDJS
|
'<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$file.'</span>'). |
'<span class="LC_filename">'.$desturl.'/'.$subdir.'/'.$file.'</span>'). |
'</p>'."\n"); |
'</p>'."\n"); |
} elsif (($src ne '') && ($dest ne '')) { |
} elsif (($src ne '') && ($dest ne '')) { |
if ($is_course_home) { |
my $ressrc = $docroot.$resurl.'/'.$file; |
if (&File::Copy::copy($src,$dest)) { |
my $ressrcmeta = $ressrc.'.meta'; |
$newfile{$file} = 1; |
my ($ext) = ($file =~ /\.(\w+)$/); |
} |
my $embstyle=&Apache::loncommon::fileembstyle($ext); |
} else { |
my ($getres,$getresmeta); |
if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file,$dest) eq 'ok') { |
if ($respublish) { |
$newfile{$file} = 1; |
if ($path eq '') { |
} |
if ((ref($resfiles{'/'}) eq 'HASH') && |
} |
(exists($resfiles{'/'}{$fname}))) { |
if ($newfile{$file}) { |
$getres = 1; |
my $gotmeta; |
$getresmeta = 1; |
if ($is_course_home) { |
|
if ((-e $src.'.meta') && (!-e $dest.'.meta')) { |
|
if (&File::Copy::copy($src.'.meta',$dest.'.meta')) { |
|
$gotmeta = 1; |
|
} |
|
} |
|
} else { |
|
if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file.'.meta',$dest.'.meta') eq 'ok') { |
|
$gotmeta = 1; |
|
} |
} |
|
} elsif ((ref($resfiles{$path}) eq 'HASH') && |
|
(exists($resfiles{$path}{$fname}))) { |
|
$getres = 1; |
|
$getresmeta = 1; |
} |
} |
if ($gotmeta) { |
} |
if (open(my $fh,'<',$dest.'.meta')) { |
if ($is_course_home) { |
my ($output,$now,$setsourceavail); |
my ($needpriv,$needprivmeta); |
$now = time; |
if ($respublish) { |
if (($file =~ /\.(xml|html|htm|xhtml|xhtm)$/i) || ($file =~ /$LONCAPA::assess_re/)) { |
if ($getres) { |
$setsourceavail = 1; |
if (&Apache::londiff::are_different_files($src,$ressrc)) { |
} |
$needpriv = 1; |
while (my $line=<$fh>) { |
if (&File::Copy::copy($ressrc,$dest)) { |
chomp($line); |
if ($embstyle eq 'ssi') { |
if ($line eq "<authorspace>$coursenum:$coursedom</authorspace>") { |
&crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd); |
$output .= "<authorspace>$ca:$cd</authorspace>\n"; |
|
} elsif ($line eq '<copyright>custom</copyright>') { |
|
$output .= "<copyright>$copyright</copyright>\n"; |
|
} elsif ($line =~ m{^<creationdate>\d+</creationdate>$}) { |
|
$output .= "<creationdate>$now</creationdate>\n"; |
|
} elsif ($line eq "<customdistributionfile>/res/$coursedom/$coursenum/default.rights</customdistributionfile>") { |
|
$output .= "<customdistributionfile>$customdistfile</customdistributionfile>\n"; |
|
} elsif ($line =~ m{^<sourceavail>(open|closed)</sourceavail>$}) { |
|
if ($setsourceavail) { |
|
$output .= "<sourceavail>$sourceavail</sourceavail>\n"; |
|
} |
} |
} elsif ($line eq "<domain>$coursedom</domain>") { |
} |
$output .= "<domain>$cd</domain>\n"; |
} else { |
} elsif ($line =~ m{^<lastrevisiondate>\d+</lastrevisiondate>$}) { |
if (&File::Copy::copy($src,$dest)) { |
$output .= "<lastrevisiondate>$now</lastrevisiondate>\n"; |
$newfile{$file} = 1; |
} elsif ($line =~ m{^<modifyinguser>$match_username:$match_domain</modifyinguser>$}) { |
if ($embstyle eq 'ssi') { |
$output .= "<modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser>\n"; |
&crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); |
} elsif ($line eq "<owner>$coursenum:$coursedom</owner>") { |
|
$output .= "<owner>$ca:$cd</owner>\n"; |
|
} elsif ($line =~ m{^<dependencies>(.+)</dependencies>$}) { |
|
my @deps = split(/\s*,\s*/,$1); |
|
my @newdeps; |
|
my $changed = 0; |
|
foreach my $dep (@deps) { |
|
if ($dep =~ m{^/res/$coursedom/$coursenum/(.+)$}) { |
|
my $rest = $1; |
|
push(@newdeps,"/res/$cd/$ca/$rest"); |
|
$checkdeps{$rest} = 1; |
|
$changed ++; |
|
} else { |
|
push(@newdeps,$dep); |
|
} |
|
} |
} |
if ($changed) { |
} |
$output .= '<dependencies>'.join(',',@newdeps).'</dependencies>'."\n"; |
} |
|
} else { |
|
$needpriv = 1; |
|
} |
|
if ($getresmeta) { |
|
if ((-e $src.'.meta') && (!-e $dest.'.meta')) { |
|
if (&Apache::londiff::are_different_files($src.'.meta',$ressrc.'.meta')) { |
|
if (&File::Copy::copy($ressrc.'.meta',$dest.'.meta')) { |
|
&crsres_fixup_meta($dest,$coursenum,$coursedom,$ca,$cd,$copyright, |
|
$customdistfile,$sourceavail,\%checkdeps); |
} |
} |
|
$needprivmeta = 1; |
} else { |
} else { |
$output .= "$line\n"; |
if (&File::Copy::copy($src.'.meta',$dest.'.meta')) { |
|
&crsres_fixup_meta($dest,$coursenum,$coursedom,$ca,$cd,$copyright, |
|
$customdistfile,$sourceavail,\%checkdeps); |
|
} |
} |
} |
} |
} |
close($fh); |
} |
if (open(my $fh,'>',$dest.'.meta')) { |
if ($getres) { |
print $fh $output; |
my $destresfile = $docroot.$destresurl.'/'.$subdir.'/'.$file; |
close($fh); |
if (-e $dest) { |
|
my $output = &Apache::lonpublisher::batchpublish($r,$dest,$destresfile,$nokeyref,1); |
} |
} |
} |
} |
|
} else { |
|
$needpriv = 1; |
|
if ((-e $src.'.meta') && (!-e $dest.'.meta')) { |
|
$needprivmeta = 1; |
|
} |
} |
} |
my ($ext) = ($file =~ /\.(\w+)$/); |
if ($needpriv) { |
my $embstyle=&Apache::loncommon::fileembstyle($ext); |
if (&File::Copy::copy($src,$dest)) { |
if ($embstyle eq 'ssi') { |
$newfile{$file} = 1; |
my $outstring=''; |
if ($embstyle eq 'ssi') { |
my $changes = 0; |
&crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); |
my @parser; |
} |
$parser[0]=HTML::LCParser->new($dest); |
} |
$parser[-1]->xml_mode(1); |
} |
my $token; |
if ($needprivmeta) { |
while (@parser) { |
if (&File::Copy::copy($src.'.meta',$dest.'.meta')) { |
while ($token=$parser[-1]->get_token) { |
&crsres_fixup_meta($dest,$coursenum,$coursedom,$ca,$cd,$copyright, |
if ($token->[0] eq 'S') { |
$customdistfile,$sourceavail,\%checkdeps); |
my $tag=$token->[1]; |
} |
my $lctag=lc($tag); |
} |
my %parms=%{$token->[2]}; |
} else { |
foreach my $type ('src','href','background','bgimg') { |
my ($needpriv,$needprivmeta); |
foreach my $key (keys(%parms)) { |
if ($respublish) { |
if ($key =~ /^$type$/i) { |
if ($getres) { |
next if (($lctag eq 'img') && ($type eq 'src') && |
&Apache::lonnet::repcopy($docroot.$resurl.'/'.$file); |
($parms{$key} =~ m{^data\:image/gif;base64,})); |
} |
if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
if ($getresmeta) { |
$parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si; |
&Apache::lonnet::repcopy($docroot.$resurl.'/'.$file.'.meta'); |
$changes ++; |
} |
} |
if (-e $docroot.$resurl.'/'.$file) { |
} |
if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file,$dest) eq 'ok') { |
} |
if (&Apache::londiff::are_different_files($docroot.$resurl.'/'.$file,$dest)) { |
} |
$needpriv = 1; |
# probably a <randomlabel> image type <label> |
if (&File::Copy::copy($docroot.$resurl.'/'.$file,$dest)) { |
# or a <image> tag inside <imageresponse> or <drawimage> |
if ($embstyle eq 'ssi') { |
if (($lctag eq 'label' && defined($parms{'description'})) |
&crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd); |
|| ($lctag eq 'image') || ($lctag eq 'import')) { |
|
my $next_token=$parser[-1]->get_token(); |
|
if ($next_token->[0] eq 'T') { |
|
$next_token->[1] =~ s/[\n\r\f]+//g; |
|
if ($next_token->[1] =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$next_token->[1] =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si; |
|
$changes ++; |
|
} |
|
} |
|
$parser[-1]->unget_token($next_token); |
|
} |
|
if ($lctag eq 'applet') { |
|
my $havecodebase=0; |
|
foreach my $key (keys(%parms)) { |
|
if (lc($key) eq 'codebase') { |
|
if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si; |
|
$changes ++; |
|
} |
|
$havecodebase = 1; |
|
} |
|
} |
|
unless ($havecodebase) { |
|
foreach my $key (keys(%parms)) { |
|
if ($key =~ /(archive|code|object)/i) { |
|
if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/si}; |
|
$changes ++; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
my $newparmstring=''; |
|
my $endtag=''; |
|
foreach my $parkey (keys(%parms)) { |
|
if ($parkey eq '/') { |
|
$endtag=' /'; |
|
} else { |
|
my $quote=($parms{$parkey}=~/\"/?"'":'"'); |
|
$newparmstring.=' '.$parkey.'='.$quote.$parms{$parkey}.$quote; |
|
} |
} |
} |
} |
if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; } |
} else { |
$outstring.='<'.$tag.$newparmstring.$endtag.'>'; |
if ($embstyle eq 'ssi') { |
if ($lctag eq 'm' || $lctag eq 'answer' || $lctag eq 'display' || |
&crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); |
$lctag eq 'tex') { |
|
$outstring.=&Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser); |
|
} elsif ($lctag eq 'script') { |
|
if ($parms{'type'} eq 'loncapa/perl') { |
|
$outstring.=&Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser); |
|
} else { |
|
my $needsupdate; |
|
my $script = &Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser); |
|
if ($script =~ m{\.addMediaSrc\((["'])((?!\1).+)\1\);}) { |
|
my $src = $2; |
|
if ($src =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$needsupdate = 1; |
|
} |
|
} |
|
if ($script =~ /\(document,\s*(['"])script\1,\s*\[([^\]]+)\]\);/s) { |
|
my $scriptslist = $2; |
|
my $needsupdate = 1; |
|
my @srcs = split(/\s*,\s*/,$scriptslist); |
|
foreach my $src (@srcs) { |
|
if ($src =~ /(["'])(?:(?!\1).)+\.js\1/) { |
|
my $quote = $1; |
|
my ($url) = ($src =~ m/\Q$quote\E([^$quote]+)\Q$quote\E/); |
|
if ($url =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$needsupdate = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ($script =~ m{loadScript\(\s*(['"])((?:(?!\1).)+\.js)\1,\s*function}is) { |
|
my $src = $2; |
|
if ($src =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$needsupdate = 1; |
|
} |
|
} |
|
if ($needsupdate) { |
|
$script =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/gsi}; |
|
$changes ++; |
|
} |
|
$outstring .= $script; |
|
} |
|
} |
} |
} elsif ($token->[0] eq 'E') { |
$newfile{$file} = 1; |
if ($token->[2]) { |
} |
unless ($token->[1] eq 'allow') { |
} |
$outstring.='</'.$token->[1].'>'; |
} else { |
} |
$needpriv = 1; |
|
} |
|
if (-e $docroot.$resurl.'/'.$file.'.meta') { |
|
if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file.'.meta',$dest.'.meta') eq 'ok') { |
|
if (&Apache::londiff::are_different_files($docroot.$resurl.'/'.$file.'.meta',$dest.'.meta')) { |
|
$needprivmeta = 1; |
|
if (&File::Copy::copy($docroot.$resurl.'/'.$file.'.meta',$dest.'.meta')) { |
|
&crsres_fixup_meta($dest,$coursenum,$coursedom,$ca,$cd,$copyright, |
|
$customdistfile,$sourceavail,\%checkdeps); |
} |
} |
} else { |
} else { |
$outstring.=$token->[1]; |
&crsres_fixup_meta($dest,$coursenum,$coursedom,$ca,$cd,$copyright, |
|
$customdistfile,$sourceavail,\%checkdeps); |
} |
} |
} |
} |
pop(@parser); |
} else { |
|
if (!-e $dest.'.meta') { |
|
$needprivmeta = 1; |
|
} |
} |
} |
if ($changes) { |
if ($getres) { |
if (open(my $fh,'>',$dest)) { |
my $destresfile = $docroot.$destresurl.'/'.$subdir.'/'.$file; |
print $fh $outstring; |
if (-e $dest) { |
close($fh); |
my $output = &Apache::lonpublisher::batchpublish($r,$dest,$destresfile,$nokeyref,1); |
|
#FIXME publish meta file also? |
} |
} |
} |
} |
|
} else { |
|
$needpriv = 1; |
|
if (!-e $dest.'.meta') { |
|
$needprivmeta = 1; |
|
} |
} |
} |
if ($respublish) { |
if ($needpriv) { |
my $destresfile = $docroot.$destresurl.'/'.$subdir.'/'.$file; |
if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file,$dest) eq 'ok') { |
if ($path eq '') { |
if ($embstyle eq 'ssi') { |
if ((ref($resfiles{'/'}) eq 'HASH') && |
&crsres_fixup($dest,$coursenum,$coursedom,$ca,$cd,$subdir); |
(exists($resfiles{'/'}{$fname}))) { |
|
my $output = &Apache::lonpublisher::batchpublish($r,$dest,$destresfile,$nokeyref,1); |
|
} |
} |
} elsif ((ref($resfiles{$path}) eq 'HASH') && |
$newfile{$file} = 1; |
(exists($resfiles{$path}{$fname}))) { |
} |
my $output = &Apache::lonpublisher::batchpublish($r,$dest,$destresfile,$nokeyref,1); |
} |
|
if ($needprivmeta) { |
|
if (&Apache::lonnet::repcopy_crsprivfile($srcurl.'/'.$file.'.meta',$dest.'.meta') eq 'ok') { |
|
&crsres_fixup_meta($dest,$coursenum,$coursedom,$ca,$cd,$copyright, |
|
$customdistfile,$sourceavail,\%checkdeps); |
} |
} |
} |
} |
} |
} |
Line 1506 sub courseresource_options {
|
Line 1434 sub courseresource_options {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub crsres_fixup_meta { |
|
my ($dest,$coursenum,$coursedom,$ca,$cd,$copyright,$customdistfile,$sourceavail,$checkdeps) = @_; |
|
return unless (ref($checkdeps) eq 'HASH'); |
|
if (open(my $fh,'<',$dest.'.meta')) { |
|
my ($output,$now,$setsourceavail); |
|
$now = time; |
|
if (($dest =~ /\.(xml|html|htm|xhtml|xhtm)$/i) || ($dest =~ /$LONCAPA::assess_re/)) { |
|
$setsourceavail = 1; |
|
} |
|
while (my $line=<$fh>) { |
|
chomp($line); |
|
if ($line eq "<authorspace>$coursenum:$coursedom</authorspace>") { |
|
$output .= "<authorspace>$ca:$cd</authorspace>\n"; |
|
} elsif ($line eq '<copyright>custom</copyright>') { |
|
$output .= "<copyright>$copyright</copyright>\n"; |
|
} elsif ($line =~ m{^<creationdate>\d+</creationdate>$}) { |
|
$output .= "<creationdate>$now</creationdate>\n"; |
|
} elsif ($line eq "<customdistributionfile>/res/$coursedom/$coursenum/default.rights</customdistributionfile>") { |
|
$output .= "<customdistributionfile>$customdistfile</customdistributionfile>\n"; |
|
} elsif ($line =~ m{^<sourceavail>(open|closed)</sourceavail>$}) { |
|
if ($setsourceavail) { |
|
$output .= "<sourceavail>$sourceavail</sourceavail>\n"; |
|
} |
|
} elsif ($line eq "<domain>$coursedom</domain>") { |
|
$output .= "<domain>$cd</domain>\n"; |
|
} elsif ($line =~ m{^<lastrevisiondate>\d+</lastrevisiondate>$}) { |
|
$output .= "<lastrevisiondate>$now</lastrevisiondate>\n"; |
|
} elsif ($line =~ m{^<modifyinguser>$match_username:$match_domain</modifyinguser>$}) { |
|
$output .= "<modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser>\n"; |
|
} elsif ($line eq "<owner>$coursenum:$coursedom</owner>") { |
|
$output .= "<owner>$ca:$cd</owner>\n"; |
|
} elsif ($line =~ m{^<dependencies>(.+)</dependencies>$}) { |
|
my @deps = split(/\s*,\s*/,$1); |
|
my @newdeps; |
|
my $changed = 0; |
|
foreach my $dep (@deps) { |
|
if ($dep =~ m{^/res/$coursedom/$coursenum/(.+)$}) { |
|
my $rest = $1; |
|
push(@newdeps,"/res/$cd/$ca/$rest"); |
|
$checkdeps->{$rest} = 1; |
|
$changed ++; |
|
} else { |
|
push(@newdeps,$dep); |
|
} |
|
} |
|
if ($changed) { |
|
$output .= '<dependencies>'.join(',',@newdeps).'</dependencies>'."\n"; |
|
} |
|
} else { |
|
$output .= "$line\n"; |
|
} |
|
} |
|
close($fh); |
|
if (open(my $fh,'>',$dest.'.meta')) { |
|
print $fh $output; |
|
close($fh); |
|
} |
|
} |
|
} |
|
|
|
sub crsres_fixup { |
|
my ($dest,$coursenum,$coursedom,$ca,$cd,$subdir) = @_; |
|
my $outstring=''; |
|
my $changes = 0; |
|
my @parser; |
|
$parser[0]=HTML::LCParser->new($dest); |
|
$parser[-1]->xml_mode(1); |
|
my $token; |
|
while (@parser) { |
|
while ($token=$parser[-1]->get_token) { |
|
if ($token->[0] eq 'S') { |
|
my $tag=$token->[1]; |
|
my $lctag=lc($tag); |
|
my %parms=%{$token->[2]}; |
|
foreach my $type ('src','href','background','bgimg') { |
|
foreach my $key (keys(%parms)) { |
|
if ($key =~ /^$type$/i) { |
|
next if (($lctag eq 'img') && ($type eq 'src') && |
|
($parms{$key} =~ m{^data\:image/gif;base64,})); |
|
if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si; |
|
$changes ++; |
|
} |
|
} |
|
} |
|
} |
|
# probably a <randomlabel> image type <label> |
|
# or a <image> tag inside <imageresponse> or <drawimage> |
|
if (($lctag eq 'label' && defined($parms{'description'})) |
|
|| ($lctag eq 'image') || ($lctag eq 'import')) { |
|
my $next_token=$parser[-1]->get_token(); |
|
if ($next_token->[0] eq 'T') { |
|
$next_token->[1] =~ s/[\n\r\f]+//g; |
|
if ($next_token->[1] =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$next_token->[1] =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si; |
|
$changes ++; |
|
} |
|
} |
|
$parser[-1]->unget_token($next_token); |
|
} |
|
if ($lctag eq 'applet') { |
|
my $havecodebase=0; |
|
foreach my $key (keys(%parms)) { |
|
if (lc($key) eq 'codebase') { |
|
if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/}si; |
|
$changes ++; |
|
} |
|
$havecodebase = 1; |
|
} |
|
} |
|
unless ($havecodebase) { |
|
foreach my $key (keys(%parms)) { |
|
if ($key =~ /(archive|code|object)/i) { |
|
if ($parms{$key} =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$parms{$key} =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/si}; |
|
$changes ++; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
my $newparmstring=''; |
|
my $endtag=''; |
|
foreach my $parkey (keys(%parms)) { |
|
if ($parkey eq '/') { |
|
$endtag=' /'; |
|
} else { |
|
my $quote=($parms{$parkey}=~/\"/?"'":'"'); |
|
$newparmstring.=' '.$parkey.'='.$quote.$parms{$parkey}.$quote; |
|
} |
|
} |
|
if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; } |
|
$outstring.='<'.$tag.$newparmstring.$endtag.'>'; |
|
if ($lctag eq 'm' || $lctag eq 'answer' || $lctag eq 'display' || |
|
$lctag eq 'tex') { |
|
$outstring.=&Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser); |
|
} elsif ($lctag eq 'script') { |
|
if ($parms{'type'} eq 'loncapa/perl') { |
|
$outstring.=&Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser); |
|
} else { |
|
my $needsupdate; |
|
my $script = &Apache::lonxml::get_all_text_unbalanced('/'.$lctag,\@parser); |
|
if ($script =~ m{\.addMediaSrc\((["'])((?!\1).+)\1\);}) { |
|
my $src = $2; |
|
if ($src =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$needsupdate = 1; |
|
} |
|
} |
|
if ($script =~ /\(document,\s*(['"])script\1,\s*\[([^\]]+)\]\);/s) { |
|
my $scriptslist = $2; |
|
my @srcs = split(/\s*,\s*/,$scriptslist); |
|
foreach my $src (@srcs) { |
|
if ($src =~ /(["'])(?:(?!\1).)+\.js\1/) { |
|
my $quote = $1; |
|
my ($url) = ($src =~ m/\Q$quote\E([^$quote]+)\Q$quote\E/); |
|
if ($url =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$needsupdate = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ($script =~ m{loadScript\(\s*(['"])((?:(?!\1).)+\.js)\1,\s*function}is) { |
|
my $src = $2; |
|
if ($src =~ m{^\Q/res/$coursedom/$coursenum/\E}si) { |
|
$needsupdate = 1; |
|
} |
|
} |
|
if ($needsupdate) { |
|
$script =~ s{^\Q/res/$coursedom/$coursenum/\E}{/res/$cd/$ca/$subdir/gsi}; |
|
$changes ++; |
|
} |
|
$outstring .= $script; |
|
} |
|
} |
|
} elsif ($token->[0] eq 'E') { |
|
if ($token->[2]) { |
|
unless ($token->[1] eq 'allow') { |
|
$outstring.='</'.$token->[1].'>'; |
|
} |
|
} |
|
} else { |
|
$outstring.=$token->[1]; |
|
} |
|
} |
|
pop(@parser); |
|
} |
|
if ($changes) { |
|
if (open(my $fh,'>',$dest)) { |
|
print $fh $outstring; |
|
close($fh); |
|
} |
|
} |
|
} |
|
|
sub group_import { |
sub group_import { |
my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_; |
my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_; |
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap, |
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap, |