Diff for /loncom/xml/lonxml.pm between versions 1.254 and 1.255

version 1.254, 2003/05/16 20:51:25 version 1.255, 2003/05/21 20:41:55
Line 421  sub xmlparse { Line 421  sub xmlparse {
        }         }
     }      }
  }   }
   #&printalltags();
  #&printalltags();  
  my @pars = ();   my @pars = ();
  my $pwd=$ENV{'request.filename'};   my $pwd=$ENV{'request.filename'};
  $pwd =~ s:/[^/]*$::;   $pwd =~ s:/[^/]*$::;
Line 441  sub xmlparse { Line 440  sub xmlparse {
   
  my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,   my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,
    $safeeval,\%style_for_target);     $safeeval,\%style_for_target);
   
  if ($ENV{'request.uri'}) {   if ($ENV{'request.uri'}) {
     &writeallows($ENV{'request.uri'});      &writeallows($ENV{'request.uri'});
  }   }
Line 520  sub inner_xmlparse { Line 520  sub inner_xmlparse {
     $Apache::lonxml::usestyle=0;      $Apache::lonxml::usestyle=0;
     my $string=$$style_for_target{$token->[1]}.      my $string=$$style_for_target{$token->[1]}.
       '<LONCAPA_INTERNAL_TURN_STYLE_ON />';        '<LONCAPA_INTERNAL_TURN_STYLE_ON />';
   ##### 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);      &Apache::lonxml::newparser($pars,\$string);
  } else {   } else {
   $result = &callsub("start_$token->[1]", $target, $token, $stack,    $result = &callsub("start_$token->[1]", $target, $token, $stack,
Line 543  sub inner_xmlparse { Line 549  sub inner_xmlparse {
     $Apache::lonxml::usestyle=0;      $Apache::lonxml::usestyle=0;
     my $string=$$style_for_target{'/'.$token->[1]}.      my $string=$$style_for_target{'/'.$token->[1]}.
       '<LONCAPA_INTERNAL_TURN_STYLE_ON />';        '<LONCAPA_INTERNAL_TURN_STYLE_ON />';
   ##### 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);      &Apache::lonxml::newparser($pars,\$string);
  } else {   } else {
   $result = &callsub("end_$token->[1]", $target, $token, $stack,    $result = &callsub("end_$token->[1]", $target, $token, $stack,
Line 1182  sub get_target { Line 1196  sub get_target {
 }  }
   
 sub handler {  sub handler {
   my $request=shift;      my $request=shift;
       
   my $target=&get_target();      my $target=&get_target();
       
   $Apache::lonxml::debug=0;      $Apache::lonxml::debug=0;
       
   if ($ENV{'browser.mathml'}) {      if ($ENV{'browser.mathml'}) {
     $request->content_type('text/xml');   $request->content_type('text/xml');
   } else {      } else {
     $request->content_type('text/html');   $request->content_type('text/html');
   }      }
   &Apache::loncommon::no_cache($request);      &Apache::loncommon::no_cache($request);
   $request->send_http_header;      $request->send_http_header;
       
   return OK if $request->header_only;      return OK if $request->header_only;
   
   
   my $file=&Apache::lonnet::filelocation("",$request->uri);      my $file=&Apache::lonnet::filelocation("",$request->uri);
 #  #
 # Edit action? Save file.  # Edit action? Save file.
 #  #
   unless ($ENV{'request.state'} eq 'published') {      unless ($ENV{'request.state'} eq 'published') {
       if (($ENV{'form.savethisfile'}) || ($ENV{'form.attemptclean'})) {   if (($ENV{'form.savethisfile'}) || ($ENV{'form.attemptclean'})) {
   &storefile($file,$ENV{'form.filecont'});      &storefile($file,$ENV{'form.filecont'});
       }   }
   }      }
   my %mystyle;      my %mystyle;
   my $result = '';      my $result = '';
   my $filecontents=&Apache::lonnet::getfile($file);      my $filecontents=&Apache::lonnet::getfile($file);
   if ($filecontents eq -1) {      if ($filecontents eq -1) {
     $result=(<<ENDNOTFOUND);   $result=(<<ENDNOTFOUND);
 <html>  <html>
 <head>  <head>
 <title>File not found</title>  <title>File not found</title>
Line 1223  sub handler { Line 1237  sub handler {
 </html>  </html>
 ENDNOTFOUND  ENDNOTFOUND
     $filecontents='';      $filecontents='';
     if ($ENV{'request.state'} ne 'published') {   if ($ENV{'request.state'} ne 'published') {
       $filecontents=&createnewhtml();      $filecontents=&createnewhtml();
       $ENV{'form.editmode'}='Edit'; #force edit mode      $ENV{'form.editmode'}='Edit'; #force edit mode
     }   }
   } else {      } else {
     unless ($ENV{'request.state'} eq 'published') {   unless ($ENV{'request.state'} eq 'published') {
       if ($ENV{'form.attemptclean'}) {      if ($ENV{'form.attemptclean'}) {
  $filecontents=&htmlclean($filecontents,1);   $filecontents=&htmlclean($filecontents,1);
       }      }
     }   }
     if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {   if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {
       $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,      $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,
   '',%mystyle);   '',%mystyle);
    }
     }      }
   }      
   
 #  #
 # Edit action? Insert editing commands  # Edit action? Insert editing commands
 #  #
   unless ($ENV{'request.state'} eq 'published') {      unless ($ENV{'request.state'} eq 'published') {
     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"><h3>'.$displayfile.      $result='<html><body bgcolor="#FFFFFF"><h3>'.$displayfile.
               '</h3></body></html>';   '</h3></body></html>';
       $result=&inserteditinfo($result,$filecontents);      $result=&inserteditinfo($result,$filecontents);
    }
     }      }
   }      
       writeallows($request->uri);
   writeallows($request->uri);      
   
       $request->print($result);
   $request->print($result);      
       return OK;
   return OK;  
 }  }
   
 sub display_title {  sub display_title {

Removed from v.1.254  
changed lines
  Added in v.1.255


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>