Diff for /loncom/xml/lonxml.pm between versions 1.159 and 1.161

version 1.159, 2002/03/21 20:51:10 version 1.161, 2002/03/22 17:52:20
Line 62  package Apache::lonxml; Line 62  package Apache::lonxml;
 use vars   use vars 
 qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace);  qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace);
 use strict;  use strict;
 use HTML::TokeParser;  use HTML::TokeParser();
 use HTML::TreeBuilder;  use HTML::TreeBuilder();
 use HTML::Entities;  use HTML::Entities();
 use Safe;  use Safe();
 use Safe::Hole;  use Safe::Hole();
 use Math::Cephes qw(:trigs :hypers :bessels erf erfc);  use Math::Cephes();
 use Math::Random qw(:all);  use Math::Random();
 use Opcode;  use Opcode();
   
 sub register {  sub register {
   my ($space,@taglist) = @_;    my ($space,@taglist) = @_;
Line 90  sub deregister { Line 90  sub deregister {
 }  }
   
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::lontexconvert;  use Apache::lontexconvert();
 use Apache::style;  use Apache::style();
 use Apache::run;  use Apache::run();
 use Apache::londefdef;  use Apache::londefdef();
 use Apache::scripttag;  use Apache::scripttag();
 use Apache::edit;  use Apache::edit();
 use Apache::lonnet;  use Apache::lonnet();
 use Apache::File;  use Apache::File();
 use Apache::loncommon;  use Apache::loncommon();
   
 #==================================================   Main subroutine: xmlparse    #==================================================   Main subroutine: xmlparse  
 #debugging control, to turn on debugging modify the correct handler  #debugging control, to turn on debugging modify the correct handler
Line 319  sub registerurl { Line 319  sub registerurl {
     my $forcereg=shift;      my $forcereg=shift;
     my $target = shift;      my $target = shift;
     my $result = '';      my $result = '';
     if ($ENV{'request.publicaccess'}) {      if (($ENV{'request.publicaccess'}) || 
          ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html')) {
  return    return 
          '<script>function LONCAPAreg(){} function LONCAPAstale(){}</script>';           '<script>function LONCAPAreg(){} function LONCAPAstale(){}</script>';
     }      }
Line 534  sub htmlclean { Line 535  sub htmlclean {
   
     my $output= $tree->as_HTML(undef,' ');      my $output= $tree->as_HTML(undef,' ');
   
     $output=~s/\<(br|hr|img|meta|allow)([^\>\/]*)\>/\<$1$2 \/\>/gis;      $output=~s/\<(br|hr|img|meta|allow)(.*?)\>/\<$1$2 \/\>/gis;
     $output=~s/\<\/(br|hr|img|meta|allow)\>//gis;      $output=~s/\<\/(br|hr|img|meta|allow)\>//gis;
     unless ($full) {      unless ($full) {
        $output=~s/\<[\/]*(body|head|html)\>//gis;         $output=~s/\<[\/]*(body|head|html)\>//gis;
Line 1092  sub inserteditinfo { Line 1093  sub inserteditinfo {
       my ($result,$filecontents)=@_;        my ($result,$filecontents)=@_;
       $filecontents = &HTML::Entities::encode($filecontents);        $filecontents = &HTML::Entities::encode($filecontents);
 #      my $editheader='<a href="#editsection">Edit below</a><hr />';  #      my $editheader='<a href="#editsection">Edit below</a><hr />';
         my $buttons=(<<BUTTONS);
   <input type="submit" name="attemptclean" 
          value="Save and then attempt to clean HTML" />
   <input type="submit" name="savethisfile" value="Save this" />
   <input type="submit" name="viewmode" value="View" />
   BUTTONS
       my $editfooter=(<<ENDFOOTER);        my $editfooter=(<<ENDFOOTER);
 <hr />  <hr />
 <a name="editsection" />  <a name="editsection" />
 <form method="post">  <form method="post">
   <input type="hidden" name="editmode" value="Edit" />
   $buttons
 <textarea cols="80" rows="40" name="filecont">$filecontents</textarea>  <textarea cols="80" rows="40" name="filecont">$filecontents</textarea>
   $buttons
 <br />  <br />
 <input type="hidden" name="showmode" value="Edit" />  
 <input type="submit" name="attemptclean"   
        value="Save and then attempt to clean HTML" />  
 <input type="submit" name="savethisfile" value="Save this" />  
 <input type="submit" name="showmode" value="View" />  
 </form>  </form>
 ENDFOOTER  ENDFOOTER
 #      $result=~s/(\<body[^\>]*\>)/$1$editheader/is;  #      $result=~s/(\<body[^\>]*\>)/$1$editheader/is;
Line 1181  ENDNOTFOUND Line 1186  ENDNOTFOUND
     $filecontents='';      $filecontents='';
     if ($ENV{'request.state'} ne 'published') {      if ($ENV{'request.state'} ne 'published') {
       $filecontents=&createnewhtml();        $filecontents=&createnewhtml();
       $ENV{'form.showmode'}='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') {
Line 1189  ENDNOTFOUND Line 1194  ENDNOTFOUND
  $filecontents=&htmlclean($filecontents,1);   $filecontents=&htmlclean($filecontents,1);
       }        }
     }      }
     if ($ENV{'form.showmode'} ne 'Edit') {      if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {
       $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle);        $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle);
     }      }
   }    }
Line 1198  ENDNOTFOUND Line 1203  ENDNOTFOUND
 # 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.showmode'} eq 'Edit') {      if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) {
       $result='<html><body bgcolor="#FFFFFF"></body></html>';        $result='<html><body bgcolor="#FFFFFF"></body></html>';
       $result=&inserteditinfo($result,$filecontents);        $result=&inserteditinfo($result,$filecontents);
     }      }

Removed from v.1.159  
changed lines
  Added in v.1.161


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