version 1.348, 2004/11/30 22:57:16
|
version 1.363, 2005/03/16 13:24:15
|
Line 149 $Apache::lonxml::post_evaluate=1;
|
Line 149 $Apache::lonxml::post_evaluate=1;
|
$Apache::lonxml::warnings_error_header=''; |
$Apache::lonxml::warnings_error_header=''; |
|
|
sub xmlbegin { |
sub xmlbegin { |
my $output=''; |
my ($style)=@_; |
@htmlareafields=(); |
my $output=''; |
if ($ENV{'browser.mathml'}) { |
@htmlareafields=(); |
$output='<?xml version="1.0"?>' |
if ($ENV{'browser.mathml'}) { |
.'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>' |
$output='<?xml version="1.0"?>' |
.'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" ' |
#.'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'."\n" |
.'[<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">]>' |
# .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" ' |
|
|
|
# .'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">] >' |
|
.'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">' |
.'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' |
.'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' |
.'xmlns="http://www.w3.org/TR/REC-html40">'; |
.'xmlns="http://www.w3.org/1999/xhtml">'; |
} else { |
} else { |
$output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
$output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'; |
<html>'; |
} |
} |
if ($style eq 'encode') { |
return $output; |
$output=&HTML::Entities::encode($output,'<>&"'); |
|
} |
|
return $output; |
} |
} |
|
|
sub xmlend { |
sub xmlend { |
Line 173 sub xmlend {
|
Line 178 sub xmlend {
|
$mode='problem'; |
$mode='problem'; |
$status=$Apache::inputtags::status[-1]; |
$status=$Apache::inputtags::status[-1]; |
} |
} |
my $discussion=&Apache::lonfeedback::list_discussion($mode,$status); |
my $discussion; |
|
&Apache::loncommon::get_unprocessed_cgi |
|
($ENV{'query_string'},['LONCAPA_INTERNAL_no_discussion']); |
|
if (! exists($ENV{'form.LONCAPA_INTERNAL_no_discussion'}) || |
|
$ENV{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') { |
|
$discussion=&Apache::lonfeedback::list_discussion($mode,$status); |
|
} |
if ($target eq 'tex') { |
if ($target eq 'tex') { |
$discussion.='<tex>\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}</tex>'; |
$discussion.='<tex>\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}</tex>'; |
&Apache::lonxml::newparser($parser,\$discussion,''); |
&Apache::lonxml::newparser($parser,\$discussion,''); |
return ''; |
return ''; |
} else { |
} else { |
return $discussion.'</html>'; |
return $discussion.&Apache::loncommon::endbodytag(); |
} |
} |
} |
} |
|
|
Line 284 sub printtokenheader {
|
Line 295 sub printtokenheader {
|
} |
} |
} |
} |
|
|
sub fontsettings() { |
sub fontsettings { |
my $headerstring=''; |
my $headerstring=''; |
if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { |
if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { |
$headerstring.= |
$headerstring.= |
Line 353 sub xmlparse {
|
Line 364 sub xmlparse {
|
|
|
my @stack = (); |
my @stack = (); |
my @parstack = (); |
my @parstack = (); |
&initdepth; |
&initdepth(); |
|
&init_alarm(); |
my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars, |
my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars, |
$safeeval,\%style_for_target); |
$safeeval,\%style_for_target); |
|
|
Line 363 sub xmlparse {
|
Line 374 sub xmlparse {
|
} |
} |
&do_registered_ssi(); |
&do_registered_ssi(); |
if ($Apache::lonxml::counter_changed) { &store_counter() } |
if ($Apache::lonxml::counter_changed) { &store_counter() } |
|
if ($ENV{'form.return_only_error_and_warning_counts'}) { |
|
return "$errorcount:$warningcount"; |
|
} |
return $finaloutput; |
return $finaloutput; |
} |
} |
|
|
sub htmlclean { |
sub htmlclean { |
my ($raw,$full)=@_; |
my ($raw,$full)=@_; |
|
# Take care of CRLF etc |
|
|
my $tree = HTML::TreeBuilder->new; |
$raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs; |
$tree->ignore_unknown(0); |
$raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs; |
|
$raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs; |
$tree->parse($raw); |
$raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs; |
|
|
my $output= $tree->as_HTML(undef,' '); |
# Generate empty tags, remove wrong end tags |
|
$raw=~s/\<(br|hr|img|meta|allow|basefont)([^\>\/]*?)\>/\<$1$2 \/\>/gis; |
$output=~s/\<(br|hr|img|meta|allow)(.*?)\>/\<$1$2 \/\>/gis; |
$raw=~s/\<\/(br|hr|img|meta|allow|basefont)\>//gis; |
$output=~s/\<\/(br|hr|img|meta|allow)\>//gis; |
|
unless ($full) { |
unless ($full) { |
$output=~s/\<[\/]*(body|head|html)\>//gis; |
$raw=~s/\<[\/]*(body|head|html)\>//gis; |
} |
} |
|
# Make standard tags lowercase |
$tree = $tree->delete; |
foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m', |
|
'table','tr','td','th','p','br','hr','img','embed','font', |
return $output; |
'a','strong','center','title','basefont','li','ol','ul', |
|
'input','select','form','option','script','pre') { |
|
$raw=~s/\<$_\s*\>/\<$_\>/gis; |
|
$raw=~s/\<\/$_\s*\>/<\/$_\>/gis; |
|
$raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis; |
|
} |
|
return $raw; |
} |
} |
|
|
sub latex_special_symbols { |
sub latex_special_symbols { |
Line 781 sub default_homework_load {
|
Line 801 sub default_homework_load {
|
} |
} |
} |
} |
|
|
|
{ |
|
my $alarm_depth; |
|
sub init_alarm { |
|
alarm(0); |
|
$alarm_depth=0; |
|
} |
|
|
|
sub start_alarm { |
|
if ($alarm_depth<1) { |
|
my $old=alarm($Apache::lonnet::perlvar{'lonScriptTimeout'}); |
|
if ($old) { |
|
&Apache::lonxml::error("Cancelled an alarm of $old, this shouldn't occur."); |
|
} |
|
} |
|
$alarm_depth++; |
|
} |
|
|
|
sub end_alarm { |
|
$alarm_depth--; |
|
if ($alarm_depth<1) { alarm(0); } |
|
} |
|
} |
my $metamode_was; |
my $metamode_was; |
sub startredirection { |
sub startredirection { |
if (!$Apache::lonxml::redirection) { |
if (!$Apache::lonxml::redirection) { |
Line 1261 sub handler {
|
Line 1303 sub handler {
|
&Apache::loncommon::content_type($request,'text/html'); |
&Apache::loncommon::content_type($request,'text/html'); |
} |
} |
&Apache::loncommon::no_cache($request); |
&Apache::loncommon::no_cache($request); |
|
if ($ENV{'request.state'} eq 'published') { |
|
$request->set_last_modified(&Apache::lonnet::metadata($request->uri, |
|
'lastrevisiondate')); |
|
} |
$request->send_http_header; |
$request->send_http_header; |
|
|
return OK if $request->header_only; |
return OK if $request->header_only; |
Line 1338 ENDNOTFOUND
|
Line 1384 ENDNOTFOUND
|
if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) { |
if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) { |
my $displayfile=$request->uri; |
my $displayfile=$request->uri; |
$displayfile=~s/^\/[^\/]*//; |
$displayfile=~s/^\/[^\/]*//; |
$result='<html><body bgcolor="#FFFFFF">'. |
my $bodytag='<body bgcolor="#FFFFFF">'; |
|
if ($ENV{'environment.remote'} eq 'off') { |
|
$bodytag=&Apache::loncommon::bodytag(); |
|
} |
|
$result='<html>'.$bodytag. |
&Apache::lonxml::message_location().'<h3>'. |
&Apache::lonxml::message_location().'<h3>'. |
$displayfile. |
$displayfile. |
'</h3></body></html>'; |
'</h3></body></html>'; |
Line 1378 sub debug {
|
Line 1428 sub debug {
|
} |
} |
|
|
sub show_error_warn_msg { |
sub show_error_warn_msg { |
|
if ($ENV{'request.filename'} eq '/home/httpd/html/res/lib/templates/simpleproblem.problem' && |
|
&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'})) { |
|
return 1; |
|
} |
return (($Apache::lonxml::debug eq 1) || |
return (($Apache::lonxml::debug eq 1) || |
($ENV{'request.state'} eq 'construct') || |
($ENV{'request.state'} eq 'construct') || |
($Apache::lonhomework::browse eq 'F' |
($Apache::lonhomework::browse eq 'F' |
Line 1592 sub whichuser {
|
Line 1646 sub whichuser {
|
my ($passedsymb)=@_; |
my ($passedsymb)=@_; |
my ($symb,$courseid,$domain,$name,$publicuser); |
my ($symb,$courseid,$domain,$name,$publicuser); |
if (defined($ENV{'form.grade_symb'})) { |
if (defined($ENV{'form.grade_symb'})) { |
my $tmp_courseid=$ENV{'form.grade_courseid'}; |
my ($tmp_courseid)= |
my $allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid); |
&Apache::loncommon::get_env_multiple('form.grade_courseid'); |
if (!$allowed && |
my $allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid); |
exists($ENV{'request.course.sec'}) && |
if (!$allowed && |
$ENV{'request.course.sec'} !~ /^\s*$/) { |
exists($ENV{'request.course.sec'}) && |
$allowed=&Apache::lonnet::allowed('vgr',$ENV{'form.grade_courseid'}. |
$ENV{'request.course.sec'} !~ /^\s*$/) { |
'/'.$ENV{'request.course.sec'}); |
$allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid. |
} |
'/'.$ENV{'request.course.sec'}); |
if ($allowed) { |
|
$symb=$ENV{'form.grade_symb'}; |
|
$courseid=$ENV{'form.grade_courseid'}; |
|
$domain=$ENV{'form.grade_domain'}; |
|
$name=$ENV{'form.grade_username'}; |
|
} |
|
} else { |
|
if (!$passedsymb) { |
|
$symb=&Apache::lonnet::symbread(); |
|
} else { |
|
$symb=$passedsymb; |
|
} |
} |
$courseid=$ENV{'request.course.id'}; |
if ($allowed) { |
$domain=$ENV{'user.domain'}; |
($symb)=&Apache::loncommon::get_env_multiple('form.grade_symb'); |
$name=$ENV{'user.name'}; |
$courseid=$tmp_courseid; |
if ($name eq 'public' && $domain eq 'public') { |
($domain)=&Apache::loncommon::get_env_multiple('form.grade_domain'); |
if (!defined($ENV{'form.username'})) { |
($name)=&Apache::loncommon::get_env_multiple('form.grade_username'); |
$ENV{'form.username'}.=time.rand(10000000); |
return ($symb,$courseid,$domain,$name,$publicuser); |
} |
} |
$name.=$ENV{'form.username'}; |
} |
|
if (!$passedsymb) { |
|
$symb=&Apache::lonnet::symbread(); |
|
} else { |
|
$symb=$passedsymb; |
|
} |
|
$courseid=$ENV{'request.course.id'}; |
|
$domain=$ENV{'user.domain'}; |
|
$name=$ENV{'user.name'}; |
|
if ($name eq 'public' && $domain eq 'public') { |
|
if (!defined($ENV{'form.username'})) { |
|
$ENV{'form.username'}.=time.rand(10000000); |
} |
} |
|
$name.=$ENV{'form.username'}; |
} |
} |
return ($symb,$courseid,$domain,$name,$publicuser); |
return ($symb,$courseid,$domain,$name,$publicuser); |
} |
} |