--- loncom/xml/lonxml.pm 2003/05/03 21:09:03 1.251
+++ loncom/xml/lonxml.pm 2003/05/22 21:05:01 1.257
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.251 2003/05/03 21:09:03 albertel Exp $
+# $Id: lonxml.pm,v 1.257 2003/05/22 21:05:01 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -421,8 +421,7 @@ sub xmlparse {
}
}
}
-
- #&printalltags();
+#&printalltags();
my @pars = ();
my $pwd=$ENV{'request.filename'};
$pwd =~ s:/[^/]*$::;
@@ -441,6 +440,7 @@ sub xmlparse {
my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,
$safeeval,\%style_for_target);
+
if ($ENV{'request.uri'}) {
&writeallows($ENV{'request.uri'});
}
@@ -521,6 +521,7 @@ sub inner_xmlparse {
my $string=$$style_for_target{$token->[1]}.
'';
&Apache::lonxml::newparser($pars,\$string);
+ $Apache::lonxml::style_values=$$parstack[-1];
} else {
$result = &callsub("start_$token->[1]", $target, $token, $stack,
$parstack, $pars, $safeeval, $style_for_target);
@@ -544,6 +545,7 @@ sub inner_xmlparse {
my $string=$$style_for_target{'/'.$token->[1]}.
'';
&Apache::lonxml::newparser($pars,\$string);
+ $Apache::lonxml::style_values=$$parstack[-1];
} else {
$result = &callsub("end_$token->[1]", $target, $token, $stack,
$parstack, $pars,$safeeval, $style_for_target);
@@ -553,10 +555,14 @@ sub inner_xmlparse {
}
#evaluate variable refs in result
if ($result ne "") {
+ my $extras;
+ if (!$Apache::lonxml::usestyle) {
+ $extras=$Apache::lonxml::style_values;
+ }
if ( $#$parstack > -1 ) {
- $result=&Apache::run::evaluate($result,$safeeval,$$parstack[-1]);
+ $result=&Apache::run::evaluate($result,$safeeval,$extras.$$parstack[-1]);
} else {
- $result= &Apache::run::evaluate($result,$safeeval,'');
+ $result= &Apache::run::evaluate($result,$safeeval,$extras);
}
}
if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
@@ -1129,6 +1135,7 @@ sub inserteditinfo {
&Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols',
undef,undef,600)
.'';
+ my $titledisplay=&display_title();
my $buttons=(<
@@ -1146,6 +1153,7 @@ $buttons
$buttons
+$titledisplay
ENDFOOTER
# $result=~s/(\
]*\>)/$1$editheader/is;
$result=~s/(\<\/body\>)/$editfooter/is;
@@ -1180,37 +1188,37 @@ sub get_target {
}
sub handler {
- my $request=shift;
-
- my $target=&get_target();
-
- $Apache::lonxml::debug=0;
-
- if ($ENV{'browser.mathml'}) {
- $request->content_type('text/xml');
- } else {
- $request->content_type('text/html');
- }
- &Apache::loncommon::no_cache($request);
- $request->send_http_header;
-
- return OK if $request->header_only;
+ my $request=shift;
+
+ my $target=&get_target();
+
+ $Apache::lonxml::debug=0;
+
+ if ($ENV{'browser.mathml'}) {
+ $request->content_type('text/xml');
+ } else {
+ $request->content_type('text/html');
+ }
+ &Apache::loncommon::no_cache($request);
+ $request->send_http_header;
+
+ return OK if $request->header_only;
- my $file=&Apache::lonnet::filelocation("",$request->uri);
+ my $file=&Apache::lonnet::filelocation("",$request->uri);
#
# Edit action? Save file.
#
- unless ($ENV{'request.state'} eq 'published') {
- if (($ENV{'form.savethisfile'}) || ($ENV{'form.attemptclean'})) {
- &storefile($file,$ENV{'form.filecont'});
- }
- }
- my %mystyle;
- my $result = '';
- my $filecontents=&Apache::lonnet::getfile($file);
- if ($filecontents eq -1) {
- $result=(<
File not found
@@ -1221,40 +1229,54 @@ sub handler {
ENDNOTFOUND
$filecontents='';
- if ($ENV{'request.state'} ne 'published') {
- $filecontents=&createnewhtml();
- $ENV{'form.editmode'}='Edit'; #force edit mode
- }
- } else {
- unless ($ENV{'request.state'} eq 'published') {
- if ($ENV{'form.attemptclean'}) {
- $filecontents=&htmlclean($filecontents,1);
- }
- }
- if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {
- $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,
- '',%mystyle);
+ if ($ENV{'request.state'} ne 'published') {
+ $filecontents=&createnewhtml();
+ $ENV{'form.editmode'}='Edit'; #force edit mode
+ }
+ } else {
+ unless ($ENV{'request.state'} eq 'published') {
+ if ($ENV{'form.attemptclean'}) {
+ $filecontents=&htmlclean($filecontents,1);
+ }
+ }
+ if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {
+ $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,
+ '',%mystyle);
+ }
}
- }
-
+
#
# Edit action? Insert editing commands
#
- unless ($ENV{'request.state'} eq 'published') {
- if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) {
- my $displayfile=$request->uri;
- $displayfile=~s/^\/[^\/]*//;
- $result=''.$displayfile.
- '
';
- $result=&inserteditinfo($result,$filecontents);
+ unless ($ENV{'request.state'} eq 'published') {
+ if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) {
+ my $displayfile=$request->uri;
+ $displayfile=~s/^\/[^\/]*//;
+ $result=''.$displayfile.
+ '
';
+ $result=&inserteditinfo($result,$filecontents);
+ }
}
- }
-
- writeallows($request->uri);
-
- $request->print($result);
-
- return OK;
+
+ writeallows($request->uri);
+
+
+ $request->print($result);
+
+ return OK;
+}
+
+sub display_title {
+ my $result;
+ if ($ENV{'request.state'} eq 'construct') {
+ my $title=&Apache::lonnet::gettitle();
+ if (!defined($title) || $title eq '') {
+ $title = $ENV{'request.filename'};
+ $title = substr($title, rindex($title, '/') + 1);
+ }
+ $result = "";
+ }
+ return $result;
}
sub debug {
@@ -1292,7 +1314,7 @@ sub error {
sub warning {
$warningcount++;
- if ($ENV{'request.state'} eq 'construct') {
+ if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) {
print "WARNING:".join('
',@_)."
\n";
}
}