--- loncom/xml/lonxml.pm 2015/04/06 17:02:33 1.531.2.19 +++ loncom/xml/lonxml.pm 2015/02/22 18:40:18 1.552 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.531.2.19 2015/04/06 17:02:33 raeburn Exp $ +# $Id: lonxml.pm,v 1.552 2015/02/22 18:40:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -228,103 +228,8 @@ sub xmlend { return $discussion; } -sub tokeninputfield { - my $defhost=$Apache::lonnet::perlvar{'lonHostID'}; - $defhost=~tr/a-z/A-Z/; - return (< - function updatetoken() { - var comp=new Array; - var barcode=unescape(document.tokeninput.barcode.value); - comp=barcode.split('*'); - if (typeof(comp[0])!="undefined") { - document.tokeninput.codeone.value=comp[0]; - } - if (typeof(comp[1])!="undefined") { - document.tokeninput.codetwo.value=comp[1]; - } - if (typeof(comp[2])!="undefined") { - comp[2]=comp[2].toUpperCase(); - document.tokeninput.codethree.value=comp[2]; - } - document.tokeninput.barcode.value=''; - } - -
- - - - -
DocID Checkin
- - - - - - - -
Scan in Barcode
or Type in DocID - -* - -* - -
-
-
-ENDINPUTFIELD -} - -sub maketoken { - my ($symb,$tuname,$tudom,$tcrsid)=@_; - unless ($symb) { - $symb=&Apache::lonnet::symbread(); - } - unless ($tuname) { - $tuname=$env{'user.name'}; - $tudom=$env{'user.domain'}; - $tcrsid=$env{'request.course.id'}; - } - return &Apache::lonnet::checkout($symb,$tuname,$tudom,$tcrsid); -} - -sub printtokenheader { - my ($target,$token,$tsymb,$tcrsid,$tudom,$tuname)=@_; - unless ($token) { return ''; } - - my ($symb,$courseid,$domain,$name) = &Apache::lonnet::whichuser(); - unless ($tsymb) { - $tsymb=$symb; - } - unless ($tuname) { - $tuname=$name; - $tudom=$domain; - $tcrsid=$courseid; - } - - my $plainname=&Apache::loncommon::plainname($tuname,$tudom); - - if ($target eq 'web') { - my %idhash=&Apache::lonnet::idrget($tudom,($tuname)); - return - ''. - &mt('Checked out for').' '.$plainname. - '
'.&mt('User').': '.$tuname.' at '.$tudom. - '
'.&mt('ID').': '.$idhash{$tuname}. - '
'.&mt('CourseID').': '.$tcrsid. - '
'.&mt('Course').': '.$env{'course.'.$tcrsid.'.description'}. - '
'.&mt('DocID').': '.$token. - '
'.&mt('Time').': '.&Apache::lonlocal::locallocaltime().'
'; - } else { - return $token; - } -} - sub printalltags { - my $temp; - foreach $temp (sort keys %Apache::lonxml::alltags) { + foreach my $temp (sort(keys(%Apache::lonxml::alltags))) { &Apache::lonxml::debug("$temp -- ". join(',',@{ $Apache::lonxml::alltags{$temp} })); } @@ -463,8 +368,6 @@ sub inner_xmlparse { my $result; my $token; my $dontpop=0; - my $lastdontpop; - my $lastendtag; my $startredirection = $Apache::lonxml::redirection; while ( $#$pars > -1 ) { while ($token = $$pars['-1']->get_token) { @@ -560,29 +463,17 @@ sub inner_xmlparse { } $result = ''; - if ($token->[0] eq 'E') { - if ($dontpop) { - $lastdontpop = $token; - } else { - $lastendtag = $token->[1]; - &end_tag($stack,$parstack,$token); - } + if ($token->[0] eq 'E' && !$dontpop) { + &end_tag($stack,$parstack,$token); } $dontpop=0; - } + } if ($#$pars > -1) { pop @$pars; pop @Apache::lonxml::pwd; } } - if (($#$stack == 0) && ($stack->[0] eq 'physnet') && ($target eq 'web') && - ($lastendtag eq 'LONCAPA_INTERNAL_TURN_STYLE_ON')) { - if ((ref($lastdontpop) eq 'ARRAY') && ($lastdontpop->[1] eq 'physnet')) { - &end_tag($stack,$parstack,$lastdontpop); - } - } - # if ($target eq 'meta') { # $finaloutput.=&endredirection; # } @@ -1569,15 +1460,13 @@ SIMPLECONTENT sub verify_html { my ($filecontents)=@_; - my ($is_html,$is_xml,$is_physnet); + my ($is_html,$is_xml); if ($filecontents =~/(?:\<|\<\;)\?xml[^\<]*\?(?:\>|\>\;)/is) { $is_xml = 1; } elsif ($filecontents =~/(?:\<|\<\;)html(?:\s+[^\<]+|\s*)(?:\>|\>\;)/is) { $is_html = 1; - } elsif ($filecontents =~/(?:\<|\<\;)physnet[^\<]*(?:\>|\>\;)/is) { - $is_physnet = 1; } - unless ($is_xml || $is_html || $is_physnet) { + unless ($is_xml || $is_html) { return &mt('File does not have [_1] or [_2] starting tag','<html>','<?xml ?>'); } if ($is_html) { @@ -1682,7 +1571,7 @@ FULLPAGE } } elsif ($symb || $folderpath) { $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n"; - $initialize .= + $initialize .= &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle, undef,$folderpath,$uri)."\n"; } @@ -2239,6 +2128,7 @@ sub add_messages { sub get_param { my ($param,$parstack,$safeeval,$context,$case_insensitive, $noelide) = @_; + if ( ! $context ) { $context = -1; } my $args =''; if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; } @@ -2246,13 +2136,16 @@ sub get_param { $args=$Apache::lonxml::style_values.$args; } + if ($noelide) { - $args =~ s/'\$/'\\\$/g; +# $args =~ s/\\'/'/g; + $args =~ s/'\$/'\\\$/g; } if ( ! $args ) { return undef; } if ( $case_insensitive ) { if ($args =~ s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei) { + return &Apache::run::run("{$args;".'return $'.$param.'}', $safeeval); #' } else { @@ -2260,6 +2153,7 @@ sub get_param { } } else { if ( $args =~ /my .*\$\Q$param\E[,\)]/ ) { + return &Apache::run::run("{$args;".'return $'.$param.'}', $safeeval); #' } else {