[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 22 Mar 2002 17:52:20 -0000


albertel		Fri Mar 22 12:52:20 2002 EDT

  Modified files:              
    /loncom/xml	lonxml.pm londefdef.pm 
  Log:
  - memory reduction (no need to import symbols we address eveything explicitly)
  - the cleanup of the TreeBuilder cleanup is better
  - buttons when editing an html file appear before and after the edit box
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.160 loncom/xml/lonxml.pm:1.161
--- loncom/xml/lonxml.pm:1.160	Thu Mar 21 17:10:31 2002
+++ loncom/xml/lonxml.pm	Fri Mar 22 12:52:20 2002
@@ -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 @@
 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 @@
 }
 
 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 @@
 
     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 @@
       my ($result,$filecontents)=@_;
       $filecontents = &HTML::Entities::encode($filecontents);
 #      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);
 <hr />
 <a name="editsection" />
 <form method="post">
+<input type="hidden" name="editmode" value="Edit" />
+$buttons
 <textarea cols="80" rows="40" name="filecont">$filecontents</textarea>
+$buttons
 <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>
 ENDFOOTER
 #      $result=~s/(\<body[^\>]*\>)/$1$editheader/is;
@@ -1182,7 +1186,7 @@
     $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 @@
 	$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 @@
 # 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='<html><body bgcolor="#FFFFFF"></body></html>';
       $result=&inserteditinfo($result,$filecontents);
     }
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.48 loncom/xml/londefdef.pm:1.49
--- loncom/xml/londefdef.pm:1.48	Wed Mar  6 15:37:38 2002
+++ loncom/xml/londefdef.pm	Fri Mar 22 12:52:20 2002
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.48 2002/03/06 20:37:38 sakharuk Exp $
+# $Id: londefdef.pm,v 1.49 2002/03/22 17:52:20 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -353,7 +353,7 @@
 	      if ($ENV{'request.state'} ne 'published') {
 		$currentstring.=(<<EDITBUTTON);
 		<form method="post">
-		<input type="submit" name="showmode" value="Edit" />
+		<input type="submit" name="editmode" value="Edit" />
 		</form>
 EDITBUTTON
 	      }