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

banghart lon-capa-cvs@mail.lon-capa.org
Thu, 30 Nov 2006 01:07:13 -0000


banghart		Wed Nov 29 20:07:13 2006 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  	Bug #5081. Adds undo function to edit HTML. 
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.427 loncom/xml/lonxml.pm:1.428
--- loncom/xml/lonxml.pm:1.427	Thu Nov 23 17:11:21 2006
+++ loncom/xml/lonxml.pm	Wed Nov 29 20:07:09 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.427 2006/11/23 22:11:21 banghart Exp $
+# $Id: lonxml.pm,v 1.428 2006/11/30 01:07:09 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1335,10 +1335,12 @@
       my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',
 					 'vi' => 'Save and View',
 					 'dv' => 'Discard Edits and View',
+					 'un' => 'undo',
 					 'ed' => 'Edit');
       my $buttons=(<<BUTTONS);
 $cleanbut
-<input type="submit" name="discardview" accesskey="d"  value="$lt{'dv'}" /><hr>
+<input type="submit" name="discardview" accesskey="d"  value="$lt{'dv'}" />
+<input type="submit" name="Undo" accesskey="u"  value="$lt{'un'}" /><hr>
 <input type="submit" name="savethisfile" accesskey="s"  value="$lt{'st'}" />
 <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
 BUTTONS
@@ -1418,14 +1420,10 @@
 #
 # Edit action? Save file.
 #
-    unless ($env{'request.state'} eq 'published') {
-	if ($env{'form.savethisfile'} || $env{'form.viewmode'}) {
-	    if (&storefile($file,$env{'form.filecont'})) {
-		&Apache::lonxml::info("<font COLOR=\"#0000FF\">".
-				      &mt('Updated').": ".
-				      &Apache::lonlocal::locallocaltime(time).
-				      " </font>");
-	    } 
+    if (!($env{'request.state'} eq 'published')) {
+	if ($env{'form.savethisfile'} || $env{'form.viewmode'} || $env{'form.Undo'}) {
+	    my $problem=&Apache::lonnet::getfile($file);
+	    my $error = &Apache::lonhomework::handle_save_or_undo($request, \$problem, \$env{'form.filecont'});
 	}
     }
     my %mystyle;