--- loncom/xml/lonxml.pm 2003/05/16 20:51:25 1.254
+++ loncom/xml/lonxml.pm 2003/05/21 20:41:55 1.255
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.254 2003/05/16 20:51:25 albertel Exp $
+# $Id: lonxml.pm,v 1.255 2003/05/21 20:41:55 sakharuk 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'});
}
@@ -520,6 +520,12 @@ sub inner_xmlparse {
$Apache::lonxml::usestyle=0;
my $string=$$style_for_target{$token->[1]}.
'';
+##### LETS TRY VARIABLE INTERPOLATION (it may be stupid but at least it works)
+ my %localhash=%{$token->[2]};
+ foreach my $localkey (keys %localhash) {
+ $string=~s/\$$localkey/$localhash{$localkey}/g;
+ }
+#####
&Apache::lonxml::newparser($pars,\$string);
} else {
$result = &callsub("start_$token->[1]", $target, $token, $stack,
@@ -543,6 +549,14 @@ sub inner_xmlparse {
$Apache::lonxml::usestyle=0;
my $string=$$style_for_target{'/'.$token->[1]}.
'';
+##### LETS TRY VARIABLE INTERPOLATION (it may be stupid but at least it works)
+ my @localarray = split /;/, $$parstack[-1];
+ foreach my $localelement (@localarray) {
+ $localelement=~/my\s+\$([^=]+)=\"(.*)\"$/;
+ my ($whatchange,$tochange) = ($1,$2);
+ $string=~s/\$$whatchange/$tochange/g;
+ }
+#####
&Apache::lonxml::newparser($pars,\$string);
} else {
$result = &callsub("end_$token->[1]", $target, $token, $stack,
@@ -1182,37 +1196,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
@@ -1223,41 +1237,41 @@ 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 {