version 1.168, 2013/09/30 13:44:16
|
version 1.176, 2023/11/07 12:26:01
|
Line 30 package Apache::scripttag;
|
Line 30 package Apache::scripttag;
|
|
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::loncommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonxml(); |
use Apache::lonxml(); |
use Apache::londefdef(); |
use Apache::londefdef(); |
Line 118 sub start_script {
|
Line 119 sub start_script {
|
} elsif ($target eq "edit" ) { |
} elsif ($target eq "edit" ) { |
#&Apache::run::run($bodytext,$safeeval); |
#&Apache::run::run($bodytext,$safeeval); |
#$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />"; |
#$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />"; |
my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser); |
my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser); |
$result=&Apache::edit::tag_start($target,$token,'Script'); |
$result=&Apache::edit::tag_start($target,$token,'Script'); |
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4); |
|
|
my $depth = $Apache::lonxml::curdepth; |
|
$result.='<span id="LC_edit_problem_codemirror">'; |
|
my $nocodemirror = &Apache::loncommon::nocodemirror(); |
|
unless ($nocodemirror) { |
|
# only show button if codemirror activated |
|
$result.='<input type="button" id="fitsize'.$depth.'" value="'.&mt("Dynamic size"). |
|
'" onclick="autosize(\''.$depth.'\')" />'; |
|
} |
|
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4).'</span>'; |
|
|
|
unless ($nocodemirror) { |
|
$result.='<script type="text/javascript"> |
|
var cm'.$depth.' = CodeMirror.fromTextArea(document.getElementById("homework_edit_'.$depth.'"), |
|
{ |
|
mode: "perl", |
|
lineWrapping: true, |
|
lineNumbers: true, |
|
tabSize: 4, |
|
indentUnit: 4, |
|
autoCloseBrackets: true, |
|
styleActiveLine: true, |
|
|
|
extraKeys: { |
|
"Tab": "indentMore", |
|
"Shift-Tab": "indentLess" |
|
} |
|
}); |
|
if(sessionStorage.getItem("autosized_'.$depth.'") != null) { |
|
document.getElementById("fitsize'.$depth.'").value = "'.&mt("Fixed size").'"; |
|
cm'.$depth.'.setSize("","auto"); |
|
} |
|
</script>'; |
|
} |
|
|
|
|
} elsif ($target eq 'meta') { |
} elsif ($target eq 'meta') { |
my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser); |
my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser); |
} |
} |
Line 141 sub start_script {
|
Line 177 sub start_script {
|
} |
} |
} |
} |
} elsif (($type eq 'text/javascript') && ($bodytext ne '')) { |
} elsif (($type eq 'text/javascript') && ($bodytext ne '')) { |
if ($url =~ m{^\Q/uploaded/$cdom/$cnum/docs/\E}) { |
if ($url =~ m{^\Q/uploaded/$cdom/$cnum/\E(docs|supplemental)/}) { |
|
if ($bodytext =~ m{\.addMediaSrc\((["'])((?!\1).)+\1\);}) { |
|
my $quote = $1; |
|
if ($bodytext =~ m{\Q.addMediaSrc($quote\E([^$quote]+)\Q$quote)\E}) { |
|
my $fname = $1; |
|
my $cleanhref = |
|
&Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum); |
|
if ($cleanhref) { |
|
&Apache::lonxml::extlink($cleanhref); |
|
} |
|
} |
|
} |
if ($bodytext =~ m{\.set\w+(Src|Swf)\(["']}i) { |
if ($bodytext =~ m{\.set\w+(Src|Swf)\(["']}i) { |
my @srcs = split(/\.set/,$bodytext); |
my @srcs = split(/\.set/,$bodytext); |
if (scalar(@srcs) > 1) { |
if (scalar(@srcs) > 1) { |
Line 149 sub start_script {
|
Line 196 sub start_script {
|
if ($item =~ m{^(FlashPlayerSwf|MediaSrc|XMPSrc|ConfigurationSrc|PosterImageSrc)\((['"])(?:(?!\2).)+\2\)}is) { |
if ($item =~ m{^(FlashPlayerSwf|MediaSrc|XMPSrc|ConfigurationSrc|PosterImageSrc)\((['"])(?:(?!\2).)+\2\)}is) { |
my $srctype = $1; |
my $srctype = $1; |
my $quote = $2; |
my $quote = $2; |
|
|
my ($fname) = ($item =~ m{^\Q$srctype($quote\E([^$quote]+)\Q$quote)\E}); |
my ($fname) = ($item =~ m{^\Q$srctype($quote\E([^$quote]+)\Q$quote)\E}); |
my $cleanhref = &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum); |
my $cleanhref = |
|
&Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum); |
if ($cleanhref) { |
if ($cleanhref) { |
&Apache::lonxml::extlink($cleanhref); |
&Apache::lonxml::extlink($cleanhref); |
|
if ($srctype eq 'ConfigurationSrc') { |
|
if ($cleanhref =~ m{^(.+/)configuration_express\.xml$}) { |
|
# |
|
# Camtasia 8.1: express_show/spritesheet.png needed, and included in zip archive. |
|
# Not referenced directly in <main>.html or <main>_player.html files, |
|
# so call lonxml::extlink() here to include httpref for the uploaded file. |
|
# (where <main> is name user gave to file/archive). |
|
# |
|
|
|
my $spritesheet = $1.'express_show/spritesheet.png'; |
|
if (&Apache::lonnet::repcopy_userfile($spritesheet) eq 'ok') { |
|
&Apache::lonxml::extlink($spritesheet); |
|
} |
|
} |
|
# |
|
# Camtasia 8.4: express_show/spritesheet.min.css needed, and included in zip archive. |
|
# Not referenced directly in <main>.html or <main>_player.html files, |
|
# so call lonxml::extlink() here to include httpref for the uploaded file. |
|
# (where <main> is name user gave to file/archive). |
|
# |
|
my $spritesheet_css = $1.'express_show/spritesheet.min.css'; |
|
if (&Apache::lonnet::repcopy_userfile($spritesheet_css) eq 'ok') { |
|
&Apache::lonxml::extlink($spritesheet_css); |
|
} |
|
} elsif ($srctype eq 'PosterImageSrc') { |
|
if ($fname =~ m{^(.+)_First_Frame\.png$}) { |
|
my $prefix = $1; |
|
my ($path) = ($cleanhref =~ m{^(.+/)\Q$fname\E}); |
|
# |
|
# Camtasia 8.1: <main>_Thumbnails.png needed, and included in zip archive. |
|
# Not referenced directly in <main>.html or <main>_player.html files, |
|
# so call lonxml::extlink() here to include httpref for the uploaded file |
|
# (where <main> is name user gave to file/archive). |
|
# |
|
my $thumbnail = $path.$prefix.'_Thumbnails.png'; |
|
if (&Apache::lonnet::repcopy_userfile($thumbnail) eq 'ok') { |
|
&Apache::lonxml::extlink($thumbnail); |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
if ($bodytext =~ /\(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 ($fname) = ($src =~ m/\Q$quote\E([^$quote]+)\Q$quote\E/); |
|
my $cleanhref = |
|
&Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum); |
|
if ($cleanhref) { |
|
&Apache::lonxml::extlink($cleanhref); |
|
} |
|
} |
|
} |
|
} |
|
if ($bodytext =~ m{loadScript\(\s*(['"])((?:(?!\1).)+\.js)\1,\s*function}is) { |
|
my $fname = $2; |
|
if ($fname) { |
|
my $cleanhref = |
|
&Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum); |
|
if ($cleanhref) { |
|
&Apache::lonxml::extlink($cleanhref); |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 254 sub start_scriptlib {
|
Line 366 sub start_scriptlib {
|
$result= |
$result= |
&Apache::edit::tag_start($target,$token,'New Script Functions'). |
&Apache::edit::tag_start($target,$token,'New Script Functions'). |
&Apache::edit::editline($token->[1],$bodytext,'scriptlib',40). |
&Apache::edit::editline($token->[1],$bodytext,'scriptlib',40). |
&Apache::edit::browse(undef,'textnode'). |
&Apache::edit::browse_or_search(undef,'textnode'). |
$error.'</td></tr>'. |
$error.'</td></tr>'. |
&Apache::edit::end_table(); |
&Apache::edit::end_table(); |
} |
} |
Line 506 sub start_import {
|
Line 618 sub start_import {
|
my $location=$token->[1]; |
my $location=$token->[1]; |
$location=~s/^\s*//s; |
$location=~s/^\s*//s; |
$location=~s/\s*$//s; |
$location=~s/\s*$//s; |
|
my $crsonly = join(',',(&Apache::loncommon::filecategorytypes('Problem'), |
|
&Apache::loncommon::filecategorytypes('Library'))); |
$result.=&Apache::edit::editline($location,$bodytext,'',40); |
$result.=&Apache::edit::editline($location,$bodytext,'',40); |
$result.=&Apache::edit::browse(undef,'textnode'); |
$result.=&Apache::edit::browse_or_search(undef,'textnode',undef,undef,$crsonly); |
$result.= ' <label>'.&mt('Import as:'). |
$result.= ' <span class="LC_nobreak"><label>'.&mt('Import as:'). |
'<select name="importmode_'.$Apache::lonxml::curdepth.'">'; |
'<select name="importmode_'.$Apache::lonxml::curdepth.'">'; |
my %options=&Apache::lonlocal::texthash('' => 'as standard library', |
my %options=&Apache::lonlocal::texthash('' => 'as standard library', |
'problem' => 'as problem', |
'problem' => 'as problem', |
Line 520 sub start_import {
|
Line 634 sub start_import {
|
} |
} |
$result.='>'.$options{$option}.'</option>'; |
$result.='>'.$options{$option}.'</option>'; |
} |
} |
$result.='</select></label>'; |
$result.='</select></label></span>'; |
#FIXME this need to convert $bodytext to be a contruction space reference |
#FIXME this need to convert $bodytext to be a contruction space reference |
#my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); |
#my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); |
#$result.="Click<a href=\"$location\">here</a> to edit<br />" |
#$result.="Click<a href=\"$location\">here</a> to edit<br />" |
Line 569 sub end_storetc {
|
Line 683 sub end_storetc {
|
|
|
sub start_physnet { |
sub start_physnet { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $bodytext = '/adm/includes/physnet.sty'; |
my $bodytext = '/res/adm/includes/physnet.sty'; |
my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); |
my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); |
my $cbistyletext=&Apache::lonnet::getfile($location); |
my $cbistyletext=&Apache::lonnet::getfile($location); |
|
|
%$style = (%$style,&Apache::style::styleparser($target,$cbistyletext)); |
%$style = (%$style,&Apache::style::styleparser($target,$cbistyletext)); |
$$parser['-1']->unget_token($token); |
if (keys(%$style) && (($target eq 'web') || ($target eq 'tex'))) { |
|
$$parser['-1']->unget_token($token); |
|
} |
# if ( defined($$style{'physnet'}) ) { |
# if ( defined($$style{'physnet'}) ) { |
# &Apache::lonxml::newparser($parser,\$$style{'physnet'}); |
# &Apache::lonxml::newparser($parser,\$$style{'physnet'}); |
# } |
# } |