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

raeburn raeburn at source.lon-capa.org
Thu Jul 4 11:50:20 EDT 2024


raeburn		Thu Jul  4 15:50:20 2024 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/xml	lonxml.pm 
  Log:
  - For 2.11
    Backport 1.565, 1.566, 1.568
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.531.2.24 loncom/xml/lonxml.pm:1.531.2.25
--- loncom/xml/lonxml.pm:1.531.2.24	Fri Sep 14 21:41:13 2018
+++ loncom/xml/lonxml.pm	Thu Jul  4 15:50:20 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.531.2.24 2018/09/14 21:41:13 raeburn Exp $
+# $Id: lonxml.pm,v 1.531.2.25 2024/07/04 15:50:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1717,7 +1717,7 @@
       if ($filetype eq 'html') {
           $htmlerror=&verify_html($filecontents);
           if ($htmlerror) {
-              $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';
+              $htmlerror=(' 'x3).' <span class="LC_error">'.$htmlerror.'</span>';
           }
           if (&Apache::lonhtmlcommon::htmlareabrowser()) {
               unless ($textareaclass) {
@@ -1725,14 +1725,23 @@
               }
           }
       }
-      my $undo;
+      my ($undo,%onclick);
+      foreach my $item ('discard','undo') {
+          $onclick{$item} = 'onclick="still_ask=true;setmode(this.form,'."'$item'".')"';
+      }
+      foreach my $item ('saveedit','saveview') {
+          $onclick{$item} = 'onclick="is_submit=true;setmode(this.form,'."'$item'".')"';
+      }
       unless ($uri =~ m{^/uploaded/}) {
-          $undo = '<input type="submit" name="Undo" accesskey="u" value="'.$lt{'un'}.'" />'."\n";
+          $undo = '<input type="submit" name="Undo" accesskey="u" value="'.$lt{'un'}.'" '.
+                  $onclick{'undo'}.' />'."\n"; 
       }
+      $initialize .= &setmode_javascript();
       my $editfooter=(<<ENDFOOTER);
 $initialize
 <a name="editsection" />
 <form $form_events method="post" name="xmledit" action="$action">
+  <input type="hidden" name="problemmode" value="edit" />
   <div class="LC_edit_problem_editxml_header">
     <table class="LC_edit_problem_header_title"><tr><td>
         $filename
@@ -1740,13 +1749,13 @@
         $xml_help
       </td></tr>
     </table>
-    <div>
-      <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />
-      $undo $htmlerror $deps_button $dragmath_button
-    </div>
     <div style="float:right">
-      <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />
-      <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
+      <input type="button" name="savethisfile" accesskey="s" value="$lt{'st'}" $onclick{'saveedit'} />
+      <input type="button" name="viewmode" accesskey="v" value="$lt{'vi'}" $onclick{'saveview'} />
+    </div>
+    <div>
+      <input type="button" name="discardview" accesskey="d" value="$lt{'dv'}" $onclick{'discard'} />
+      $undo $deps_button $dragmath_button $htmlerror
     </div>
   </div>
   <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont" $textareaclass>$filecontents</textarea><br />$spelllink
@@ -1756,7 +1765,7 @@
   </div>
 </form>
 ENDFOOTER
-      return ($editfooter,$add_to_onload,$add_to_onresize);;
+      return ($editfooter,$add_to_onload,$add_to_onresize);
 }
 
 sub get_target {
@@ -1861,11 +1870,13 @@
 # Edit action? Save file.
 #
     if (!($env{'request.state'} eq 'published')) {
-	if ($env{'form.savethisfile'} || $env{'form.viewmode'} || $env{'form.Undo'}) {
+        if (($env{'form.problemmode'} eq 'saveedit') ||
+            ($env{'form.problemmode'} eq 'saveview') ||
+            ($env{'form.problemmode'} eq 'undo')) {
 	    my $html_file=&Apache::lonnet::getfile($file);
 	    my $error = &Apache::lonhomework::handle_save_or_undo($request, \$html_file, \$env{'form.filecont'});
-            if ($env{'form.savethisfile'}) {
-                $env{'form.editmode'}='Edit'; #force edit mode
+            if ($env{'form.problemmode'} eq 'saveedit') {
+                $env{'form.editmode'}='edit'; #force edit mode
             }
 	}
     }
@@ -1894,7 +1905,7 @@
             } elsif ($filetype ne 'css' && $filetype ne 'txt' && $filetype ne 'tex') {
 		$filecontents=&createnewhtml();
 	    }
-	    $env{'form.editmode'}='Edit'; #force edit mode
+	    $env{'form.editmode'}='edit'; #force edit mode
 	}
     } else {
 	unless ($env{'request.state'} eq 'published') {
@@ -1906,7 +1917,9 @@
             &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 						    ['editmode']);
 	}
-	if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) {
+        if ((!$env{'form.editmode'}) ||
+            ($env{'form.problemmode'} eq 'saveview') ||
+            ($env{'form.problemmode'} eq 'discard')) {
             if ($filetype eq 'html' || $filetype eq 'sty') {
 	        &Apache::structuretags::reset_problem_globals();
 	        $result = &Apache::lonxml::xmlparse($request,$target,
@@ -1974,8 +1987,9 @@
 # Edit action? Insert editing commands
 #
     unless (($env{'request.state'} eq 'published') || ($inhibit_menu)) {
-	if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'})))
-	{
+        if (($env{'form.editmode'}) &&
+            (!($env{'form.problemmode'} eq 'saveview')) &&
+            (!($env{'form.problemmode'} eq 'discard'))) {
             my ($displayfile,$url,$symb,$itemtitle,$action);
 	    $displayfile=$request->uri;
             if ($request->uri =~ m{^/uploaded/}) {




More information about the LON-CAPA-cvs mailing list