--- loncom/xml/lonxml.pm 2001/08/07 16:54:14 1.106 +++ loncom/xml/lonxml.pm 2001/08/09 20:32:36 1.108 @@ -13,7 +13,7 @@ # 6/12,6/13 H. K. Ng # 6/16 Gerd Kortemeyer # 7/27 H. K. Ng -# 8/7 Gerd Kortemeyer +# 8/7,8/9 Gerd Kortemeyer package Apache::lonxml; use vars @@ -172,6 +172,8 @@ ENDPARM menu.currentStale=0; menu.clearbut(3,1); menu.switchbutton + (6,3,'catalog.gif','catalog','info','catalog_info()'); + menu.switchbutton (8,1,'eval.gif','evaluate','this','gopost("/adm/evaluate",currentURL)'); menu.switchbutton (8,2,'fdbk.gif','feedback','on this','gopost("/adm/feedback",currentURL)'); @@ -200,7 +202,7 @@ ENDPARM menu.clearbut(7,3); menu.menucltim=menu.setTimeout( 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+ - 'clearbut(9,1);clearbut(9,2);clearbut(9,3);', + 'clearbut(9,1);clearbut(9,2);clearbut(9,3);clearbut(6,3)', 2000); } @@ -284,19 +286,20 @@ sub xmlparse { } sub htmlclean { - my $raw=shift; + my ($raw,$full)=@_; my $tree = HTML::TreeBuilder->new; $tree->ignore_unknown(0); $tree->parse($raw); - my %emptyhash=(); - my $output= $tree->as_HTML(undef,' ',\%emptyhash), "\n"; + my $output= $tree->as_HTML(undef,' '); $output=~s/\<(br|hr|img)([^\>\/]*)\>/\<$1$2 \/\>/gis; $output=~s/\<\/(br|hr|img)\>//gis; - $output=~s/\<[\/]*(body|head|html)\>//gis; + unless ($full) { + $output=~s/\<[\/]*(body|head|html)\>//gis; + } $tree = $tree->delete; @@ -831,7 +834,9 @@ SIMPLECONTENT

- + +
ENDFOOTER $result=~s/(\]*\>)/$1$editheader/is; @@ -862,7 +867,7 @@ sub handler { # Edit action? Save file. # unless ($ENV{'request.state'} eq 'published') { - if ($ENV{'form.savethisfile'}) { + if (($ENV{'form.savethisfile'}) || ($ENV{'form.attemptclean'})) { &storefile($file,$ENV{'form.filecont'}); } } @@ -882,6 +887,11 @@ sub handler { ENDNOTFOUND $filecontents=''; } else { + unless ($ENV{'request.state'} eq 'published') { + if ($ENV{'form.attemptclean'}) { + $filecontents=&htmlclean($filecontents,1); + } + } $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle); }