--- loncom/xml/lonxml.pm 2018/09/14 21:41:13 1.531.2.24
+++ loncom/xml/lonxml.pm 2023/12/29 23:40:37 1.531.2.24.2.1
@@ -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.24.2.1 2023/12/29 23:40:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1725,14 +1725,23 @@ FULLPAGE
}
}
}
- my $undo;
+ my ($undo,%onclick);
+ foreach my $item ('discard','undo','daxe') {
+ $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 = ''."\n";
+ $undo = ''."\n";
}
+ $initialize .= &setmode_javascript();
my $editfooter=(<
ENDFOOTER
- return ($editfooter,$add_to_onload,$add_to_onresize);;
+ return ($editfooter,$add_to_onload,$add_to_onresize);
+}
+
+sub setmode_javascript {
+ return <<"ENDSCRIPT";
+
+ENDSCRIPT
+}
+
+sub seteditor_javascript {
+ return <<"ENDSCRIPT";
+
+ENDSCRIPT
}
sub get_target {
@@ -1861,11 +1898,13 @@ sub handler {
# 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 +1933,7 @@ ENDNOTFOUND
} 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 +1945,9 @@ ENDNOTFOUND
&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 +2015,9 @@ ENDNOTFOUND
# 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/}) {