version 1.313, 2004/03/23 00:47:48
|
version 1.316, 2004/04/12 22:55:59
|
Line 36
|
Line 36
|
# The C source of the Code may not be distributed by the Licensee |
# The C source of the Code may not be distributed by the Licensee |
# to any other parties under any circumstances. |
# to any other parties under any circumstances. |
# |
# |
# last modified 06/26/00 by Alexander Sakharuk |
|
# 11/6 Gerd Kortemeyer |
|
# 6/1/1 Gerd Kortemeyer |
|
# 2/21,3/13 Guy |
|
# 3/29,5/4 Gerd Kortemeyer |
|
# 5/26 Gerd Kortemeyer |
|
# 5/27 H. K. Ng |
|
# 6/2,6/3,6/8,6/9 Gerd Kortemeyer |
|
# 6/12,6/13 H. K. Ng |
|
# 6/16 Gerd Kortemeyer |
|
# 7/27 H. K. Ng |
|
# 8/7,8/9,8/10,8/11,8/15,8/16,8/17,8/18,8/20,8/23,8/24 Gerd Kortemeyer |
|
# Guy Albertelli |
|
# 9/26 Gerd Kortemeyer |
|
# Dec Guy Albertelli |
|
# YEAR=2002 |
|
# 1/1 Gerd Kortemeyer |
|
# 1/2 Matthew Hall |
|
# 1/3 Gerd Kortemeyer |
|
# |
|
|
|
package Apache::lonxml; |
package Apache::lonxml; |
use vars |
use vars |
qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode $errorcount $warningcount); |
qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $errorcount $warningcount); |
use strict; |
use strict; |
use HTML::LCParser(); |
use HTML::LCParser(); |
use HTML::TreeBuilder(); |
use HTML::TreeBuilder(); |
Line 141 $evaluate = 1;
|
Line 122 $evaluate = 1;
|
# stores the list of active tag namespaces |
# stores the list of active tag namespaces |
@namespace=(); |
@namespace=(); |
|
|
# if 0 all high ASCII characters will be encoded into HTML Entities |
|
$prevent_entity_encode=0; |
|
|
|
# has the dynamic menu been updated to know about this resource |
# has the dynamic menu been updated to know about this resource |
$Apache::lonxml::registered=0; |
$Apache::lonxml::registered=0; |
|
|
Line 517 sub inner_xmlparse {
|
Line 495 sub inner_xmlparse {
|
} |
} |
} |
} |
|
|
# Encode any high ASCII characters |
|
# if (!$Apache::lonxml::prevent_entity_encode) { |
|
# $result=&HTML::Entities::encode($result,"\200-\377"); |
|
# } |
|
if ($Apache::lonxml::redirection) { |
if ($Apache::lonxml::redirection) { |
$Apache::lonxml::outputstack['-1'] .= $result; |
$Apache::lonxml::outputstack['-1'] .= $result; |
} else { |
} else { |
Line 871 sub get_all_text_unbalanced {
|
Line 845 sub get_all_text_unbalanced {
|
} elsif ($token->[0] eq 'E') { |
} elsif ($token->[0] eq 'E') { |
$result.=$token->[2]; |
$result.=$token->[2]; |
} |
} |
if ($result =~ /(.*)\Q$tag\E(.*)/s) { |
if ($result =~ /(.*)\Q$tag\E(.*)/is) { |
&Apache::lonxml::debug('Got a winner with leftovers ::'.$2); |
&Apache::lonxml::debug('Got a winner with leftovers ::'.$2); |
&Apache::lonxml::debug('Result is :'.$1); |
&Apache::lonxml::debug('Result is :'.$1); |
$result=$1; |
$result=$1; |
Line 933 sub get_all_text {
|
Line 907 sub get_all_text {
|
} elsif ($token->[0] eq 'PI') { |
} elsif ($token->[0] eq 'PI') { |
$result.=$token->[2]; |
$result.=$token->[2]; |
} elsif ($token->[0] eq 'S') { |
} elsif ($token->[0] eq 'S') { |
if ($token->[1] =~ /^$tag$/i) { $depth++; } |
if ($token->[1] =~ /^\Q$tag\E$/i) { $depth++; } |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_ON$/i) { $Apache::lonxml::usestyle=1; } |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_ON$/) { $Apache::lonxml::usestyle=1; } |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_OFF$/i) { $Apache::lonxml::usestyle=0; } |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_OFF$/) { $Apache::lonxml::usestyle=0; } |
$result.=$token->[4]; |
$result.=$token->[4]; |
} elsif ($token->[0] eq 'E') { |
} elsif ($token->[0] eq 'E') { |
if ( $token->[1] =~ /^$tag$/i) { $depth--; } |
if ( $token->[1] =~ /^\Q$tag\E$/i) { $depth--; } |
#skip sending back the last end tag |
#skip sending back the last end tag |
if ($depth == 0 && exists($$style{'/'.$token->[1]}) && $Apache::lonxml::usestyle) { |
if ($depth == 0 && exists($$style{'/'.$token->[1]}) && $Apache::lonxml::usestyle) { |
my $string= |
my $string= |
Line 967 sub get_all_text {
|
Line 941 sub get_all_text {
|
#never found the end tag ran out of text, throw error send back blank |
#never found the end tag ran out of text, throw error send back blank |
&error('Never found end tag for <'.$tag. |
&error('Never found end tag for <'.$tag. |
'> current string <pre>'. |
'> current string <pre>'. |
&HTML::Entities::encode($result). |
&HTML::Entities::encode($result,'<>&"'). |
'</pre>'); |
'</pre>'); |
if ($gotfullstack) { |
if ($gotfullstack) { |
my $newstring='</'.$tag.'>'.$result; |
my $newstring='</'.$tag.'>'.$result; |
Line 985 sub get_all_text {
|
Line 959 sub get_all_text {
|
} elsif ($token->[0] eq 'PI') { |
} elsif ($token->[0] eq 'PI') { |
$result.=$token->[2]; |
$result.=$token->[2]; |
} elsif ($token->[0] eq 'S') { |
} elsif ($token->[0] eq 'S') { |
if ( $token->[1] =~ /^$tag$/i) { |
if ( $token->[1] =~ /^\Q$tag\E$/i) { |
$$pars[-1]->unget_token($token); last; |
$$pars[-1]->unget_token($token); last; |
} else { |
} else { |
$result.=$token->[4]; |
$result.=$token->[4]; |
} |
} |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_ON$/i) { $Apache::lonxml::usestyle=1; } |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_ON$/) { $Apache::lonxml::usestyle=1; } |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_OFF$/i) { $Apache::lonxml::usestyle=0; } |
if ($token->[1] =~ /^LONCAPA_INTERNAL_TURN_STYLE_OFF$/) { $Apache::lonxml::usestyle=0; } |
} elsif ($token->[0] eq 'E') { |
} elsif ($token->[0] eq 'E') { |
$result.=$token->[2]; |
$result.=$token->[2]; |
} |
} |
Line 1144 SIMPLECONTENT
|
Line 1118 SIMPLECONTENT
|
|
|
sub inserteditinfo { |
sub inserteditinfo { |
my ($result,$filecontents,$filetype)=@_; |
my ($result,$filecontents,$filetype)=@_; |
$filecontents = &HTML::Entities::encode($filecontents); |
$filecontents = &HTML::Entities::encode($filecontents,'<>&"'); |
# my $editheader='<a href="#editsection">Edit below</a><hr />'; |
# my $editheader='<a href="#editsection">Edit below</a><hr />'; |
my $xml_help = ''; |
my $xml_help = ''; |
if ($filetype eq 'html') { |
if ($filetype eq 'html') { |
Line 1329 sub debug {
|
Line 1303 sub debug {
|
$|=1; |
$|=1; |
my $request=$Apache::lonxml::request; |
my $request=$Apache::lonxml::request; |
if (!$request) { $request=Apache->request; } |
if (!$request) { $request=Apache->request; } |
$request->print('<font size="-2"><pre>DEBUG:'.&HTML::Entities::encode($_[0])."</pre></font>\n"); |
$request->print('<font size="-2"><pre>DEBUG:'.&HTML::Entities::encode($_[0],'<>&"')."</pre></font>\n"); |
} |
} |
} |
} |
|
|