--- loncom/xml/lonxml.pm 2002/03/21 22:10:31 1.160 +++ loncom/xml/lonxml.pm 2002/03/22 17:52:20 1.161 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.160 2002/03/21 22:10:31 www Exp $ +# $Id: lonxml.pm,v 1.161 2002/03/22 17:52:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,14 +62,14 @@ package Apache::lonxml; use vars qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace); use strict; -use HTML::TokeParser; -use HTML::TreeBuilder; -use HTML::Entities; -use Safe; -use Safe::Hole; -use Math::Cephes qw(:trigs :hypers :bessels erf erfc); -use Math::Random qw(:all); -use Opcode; +use HTML::TokeParser(); +use HTML::TreeBuilder(); +use HTML::Entities(); +use Safe(); +use Safe::Hole(); +use Math::Cephes(); +use Math::Random(); +use Opcode(); sub register { my ($space,@taglist) = @_; @@ -90,15 +90,15 @@ sub deregister { } use Apache::Constants qw(:common); -use Apache::lontexconvert; -use Apache::style; -use Apache::run; -use Apache::londefdef; -use Apache::scripttag; -use Apache::edit; -use Apache::lonnet; -use Apache::File; -use Apache::loncommon; +use Apache::lontexconvert(); +use Apache::style(); +use Apache::run(); +use Apache::londefdef(); +use Apache::scripttag(); +use Apache::edit(); +use Apache::lonnet(); +use Apache::File(); +use Apache::loncommon(); #================================================== Main subroutine: xmlparse #debugging control, to turn on debugging modify the correct handler @@ -535,7 +535,7 @@ sub htmlclean { 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; unless ($full) { $output=~s/\<[\/]*(body|head|html)\>//gis; @@ -1093,17 +1093,21 @@ sub inserteditinfo { my ($result,$filecontents)=@_; $filecontents = &HTML::Entities::encode($filecontents); # my $editheader='Edit below
'; + my $buttons=(< + + +BUTTONS my $editfooter=(<
+ +$buttons +$buttons
- - - -
ENDFOOTER # $result=~s/(\]*\>)/$1$editheader/is; @@ -1182,7 +1186,7 @@ ENDNOTFOUND $filecontents=''; if ($ENV{'request.state'} ne 'published') { $filecontents=&createnewhtml(); - $ENV{'form.showmode'}='Edit'; #force edit mode + $ENV{'form.editmode'}='Edit'; #force edit mode } } else { unless ($ENV{'request.state'} eq 'published') { @@ -1190,7 +1194,7 @@ ENDNOTFOUND $filecontents=&htmlclean($filecontents,1); } } - if ($ENV{'form.showmode'} ne 'Edit') { + if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) { $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle); } } @@ -1199,7 +1203,7 @@ ENDNOTFOUND # Edit action? Insert editing commands # unless ($ENV{'request.state'} eq 'published') { - if ($ENV{'form.showmode'} eq 'Edit') { + if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) { $result=''; $result=&inserteditinfo($result,$filecontents); }