Diff for /loncom/xml/lonxml.pm between versions 1.492 and 1.493

version 1.492, 2009/04/13 20:15:44 version 1.493, 2009/04/13 20:42:32
Line 1504  SIMPLECONTENT Line 1504  SIMPLECONTENT
   return $filecontents;    return $filecontents;
 }  }
   
   sub createnewjs {
       my $filecontents=(<<SIMPLECONTENT);
   <script type="text/javascript" language="Javascript">
   
   </script>
   SIMPLECONTENT
       return $filecontents;
   }
   
 sub verify_html {  sub verify_html {
     my ($filecontents)=@_;      my ($filecontents)=@_;
     if ($filecontents!~/(?:\<|\&lt\;)(?:html|xml)[^\<]*(?:\>|\&gt\;)/is) {      if ($filecontents!~/(?:\<|\&lt\;)(?:html|xml)[^\<]*(?:\>|\&gt\;)/is) {
Line 1679  sub get_target { Line 1688  sub get_target {
   
 sub handler {  sub handler {
     my $request=shift;      my $request=shift;
       
     my $target=&get_target();      my $target=&get_target();
       
     $Apache::lonxml::debug=$env{'user.debug'};      $Apache::lonxml::debug=$env{'user.debug'};
           
     &Apache::loncommon::content_type($request,'text/html');      &Apache::loncommon::content_type($request,'text/html');
Line 1697  sub handler { Line 1705  sub handler {
   
     my $file=&Apache::lonnet::filelocation("",$request->uri);      my $file=&Apache::lonnet::filelocation("",$request->uri);
     my $filetype;      my $filetype;
     if ($file =~ /\.sty$/) {      if ($file =~ /\.(sty|css|js|txt)$/) {
  $filetype='sty';   $filetype=$1;
     } else {      } else {
  $filetype='html';   $filetype='html';
     }      }
   
 #  #
 # Edit action? Save file.  # Edit action? Save file.
 #  #
Line 1730  ENDNOTFOUND Line 1739  ENDNOTFOUND
  if ($env{'request.state'} ne 'published') {   if ($env{'request.state'} ne 'published') {
     if ($filetype eq 'sty') {      if ($filetype eq 'sty') {
  $filecontents=&createnewsty();   $filecontents=&createnewsty();
     } else {              } elsif ($filetype eq 'js') {
                   $filecontents=&createnewjs();
               } elsif (($filetype ne 'css') && ($filetype ne 'txt')) {
  $filecontents=&createnewhtml();   $filecontents=&createnewhtml();
     }      }
     $env{'form.editmode'}='Edit'; #force edit mode      $env{'form.editmode'}='Edit'; #force edit mode
Line 1746  ENDNOTFOUND Line 1757  ENDNOTFOUND
     ['editmode']);      ['editmode']);
  }   }
  if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) {   if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) {
     &Apache::structuretags::reset_problem_globals();              if ($filetype eq 'html' || $filetype eq 'sty') {
     $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,          &Apache::structuretags::reset_problem_globals();
  '',%mystyle);          $result = &Apache::lonxml::xmlparse($request,$target,
                                                       $filecontents,'',%mystyle);
     # .html files may contain <problem> or <Task> need to clean      # .html files may contain <problem> or <Task> need to clean
     # up if it did      # up if it did
     &Apache::structuretags::reset_problem_globals();          &Apache::structuretags::reset_problem_globals();
     &Apache::lonhomework::finished_parsing();          &Apache::lonhomework::finished_parsing();
               } else {
                   $result = $filecontents;
               }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['rawmode']);      ['rawmode']);
     if ($env{'form.rawmode'}) { $result = $filecontents; }      if ($env{'form.rawmode'}) { $result = $filecontents; }
     if ($filetype eq 'sty') {      if ($filetype ne 'html') {
                   my $nochgview = 1; 
  my $controls =   my $controls =
     ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls()      ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls($nochgview)
                                            : '';                                             : '';
  my %options = ('bgcolor' => '#FFFFFF');                  if ($filetype ne 'sty') {
  $result =                       $result =~ s/</&lt;/g;
     &Apache::loncommon::start_page(undef,undef,\%options).                      $result =~ s/>/&gt;/g;
     $controls.                      $result = '<table class="LC_sty_begin">'.
     $result.                                '<tr><td><b><pre>'.$result.
     &Apache::loncommon::end_page();                                '</pre></b></td></tr></table>';
     }                  }
                   if ($env{'environment.remote'} eq 'off') {
                       my %options = ('bgcolor' => '#FFFFFF');
       $result = 
           &Apache::loncommon::start_page(undef,undef,\%options).
           $controls.
           $result.
           &Apache::loncommon::end_page();
                   } else {
                       $result = $controls.$result;
                   }
               }
  }   }
     }      }
   
Line 1800  ENDNOTFOUND Line 1827  ENDNOTFOUND
  &Apache::lonxml::message_location().   &Apache::lonxml::message_location().
  $edit_info.   $edit_info.
  &Apache::loncommon::end_page();   &Apache::loncommon::end_page();
  }          }
     }      }
     if ($filetype eq 'html') { &writeallows($request->uri); }      if ($filetype eq 'html') { &writeallows($request->uri); }
           

Removed from v.1.492  
changed lines
  Added in v.1.493


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