--- loncom/publisher/loncleanup.pm 2005/05/28 01:32:33 1.1 +++ loncom/publisher/loncleanup.pm 2005/05/28 02:18:03 1.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to cleanup XML files # -# $Id: loncleanup.pm,v 1.1 2005/05/28 01:32:33 www Exp $ +# $Id: loncleanup.pm,v 1.2 2005/05/28 02:18:03 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -208,36 +208,50 @@ sub symbolfontreplace { } sub htmlclean { - my ($raw,$full)=@_; + my ($raw,$full,$blocklinefeed,$blockemptytags,$blocklowercasing,$blockdesymboling)=@_; # Take care of CRLF etc - - $raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs; - $raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs; - $raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs; - $raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs; - + unless ($blocklinefeed) { + $raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs; + $raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs; + $raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs; + $raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs; + } # Generate empty tags, remove wrong end tags - $raw=~s/\<(br|hr|img|meta|allow|basefont)([^\>\/]*?)\>/\<$1$2 \/\>/gis; - $raw=~s/\<\/(br|hr|img|meta|allow|basefont)\>//gis; - unless ($full) { - $raw=~s/\<[\/]*(body|head|html)\>//gis; + unless ($blockemptytags) { + $raw=~s/\<(br|hr|img|meta|allow|basefont)([^\>\/]*?)\>/\<$1$2 \/\>/gis; + $raw=~s/\<\/(br|hr|img|meta|allow|basefont)\>//gis; + unless ($full) { + $raw=~s/\<[\/]*(body|head|html)\>//gis; + } } # Make standard tags lowercase - foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m', - 'table','tr','td','th','p','br','hr','img','embed','font', - 'a','strong','center','title','basefont','li','ol','ul', - 'input','select','form','option','script','pre') { - $raw=~s/\<$_\s*\>/\<$_\>/gis; - $raw=~s/\<\/$_\s*\>/<\/$_\>/gis; - $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis; + unless ($blocklowercasing) { + foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m', + 'table','tr','td','th','p','br','hr','img','embed','font', + 'a','strong','center','title','basefont','li','ol','ul', + 'input','select','form','option','script','pre') { + $raw=~s/\<$_\s*\>/\<$_\>/gis; + $raw=~s/\<\/$_\s*\>/<\/$_\>/gis; + $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis; + } + } +# Replace + unless ($blockdesymboling) { + $raw=&symbolfontreplace($raw); } return $raw; } sub phaseone { + my ($r,$fn,$uname,$udom)=@_; } sub phasetwo { + my ($r,$fn,$uname,$udom)=@_; +} + +sub phasethree { + my ($r,$fn,$uname,$udom)=@_; } # ---------------------------------------------------------------- Main Handler @@ -289,7 +303,9 @@ sub handler { $r->print(&Apache::loncommon::bodytag('Cleanup XML Document')); - if ($env{'form.phase'} eq 'two') { + if ($env{'form.phase'} eq 'three') { + &phasethree($r,$fn,$uname,$udom); + } elsif ($env{'form.phase'} eq 'two') { &phasetwo($r,$fn,$uname,$udom); } else { &phaseone($r,$fn,$uname,$udom);