--- loncom/xml/lonxml.pm 2018/09/14 21:41:13 1.531.2.24
+++ loncom/xml/lonxml.pm 2024/09/04 17:22:51 1.531.2.24.2.5
@@ -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.5 2024/09/04 17:22:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1708,8 +1708,9 @@ FULLPAGE
my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',
'vi' => 'Save and View',
'dv' => 'Discard Edits and View',
- 'un' => 'undo',
- 'ed' => 'Edit');
+ 'un' => 'Undo',
+ 'ed' => 'Edit',
+ 'ew' => 'Edit with Daxe');
my $spelllink = &Apache::lonhtmlcommon::spelllink('xmledit','filecont');
my $textarea_events = &Apache::edit::element_change_detection();
my $form_events = &Apache::edit::form_change_detection();
@@ -1717,7 +1718,7 @@ FULLPAGE
if ($filetype eq 'html') {
$htmlerror=&verify_html($filecontents);
if ($htmlerror) {
- $htmlerror=''.$htmlerror.'';
+ $htmlerror=(' 'x3).' '.$htmlerror.'';
}
if (&Apache::lonhtmlcommon::htmlareabrowser()) {
unless ($textareaclass) {
@@ -1725,14 +1726,30 @@ FULLPAGE
}
}
}
- my $undo;
+ my ($undo,$daxebutton,%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();
+ if ($filetype eq 'html') {
+ my %editors = &Apache::loncommon::permitted_editors();
+ if ($editors{'daxe'}) {
+ $daxebutton = ''."\n";
+ }
}
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 {
+ my ($is_course_doc,$is_supp,$supp_path,$supp_title) = @_;
+ my $symb;
+ if ($is_course_doc) {
+ if (!$is_supp) {
+ ($symb) = &Apache::lonnet::whichuser();
+ if ($symb) {
+ $symb = &escape($symb);
+ }
+ }
+ }
+ return <<"ENDSCRIPT";
+
+ENDSCRIPT
}
sub get_target {
@@ -1861,11 +1968,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 +2003,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 +2015,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,15 +2085,22 @@ 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/}) {
if ($env{'request.course.id'}) {
- if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/supplemental/\E}) {
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folderpath','title']);
+ if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/\E(docs|supplemental)/}) {
+ if ($1 eq 'supplemental') {
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['folderpath','title']);
+ }
+ if (($env{'request.state'} eq 'edit') && ($env{'form.editmode'} eq 'edit') &&
+ ($filetype eq 'html')) {
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ }
} elsif ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) {
my $filename = $1;
if ($1 eq 'loncapa.html') {