--- loncom/xml/lonxml.pm 2016/09/16 14:20:47 1.531.2.22
+++ loncom/xml/lonxml.pm 2024/02/28 18:33:00 1.531.2.24.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.531.2.22 2016/09/16 14:20:47 raeburn Exp $
+# $Id: lonxml.pm,v 1.531.2.24.2.2 2024/02/28 18:33:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -69,6 +69,8 @@ use Safe();
use Safe::Hole();
use Math::Cephes();
use Math::Random();
+use Math::Calculus::Expression();
+use Number::FormatEng();
use Opcode();
use POSIX qw(strftime);
use Time::HiRes qw( gettimeofday tv_interval );
@@ -440,7 +442,7 @@ sub latex_special_symbols {
} else {
$string=~s/\\/\\ensuremath{\\backslash}/g;
$string=~s/\\\%|\%/\\\%/g;
- $string=~s/\\\{|{/\\{/g;
+ $string=~s/\\\{|\{/\\{/g;
$string=~s/\\}|}/\\}/g;
$string=~s/\\ensuremath\\\{\\backslash\\}/\\ensuremath{\\backslash}/g;
$string=~s/\\\$|\$/\\\$/g;
@@ -914,6 +916,9 @@ sub init_safespace {
$safehole->wrap(\&Apache::functionplotresponse::fpr_objectcoords,$safeeval,'&fpr_objectcoords');
$safehole->wrap(\&Apache::functionplotresponse::fpr_vectorlength,$safeeval,'&fpr_vectorlength');
$safehole->wrap(\&Apache::functionplotresponse::fpr_vectorangle,$safeeval,'&fpr_vectorangle');
+ $safehole->wrap(\&Math::Calculus::Expression::math_calculus_expression,$safeeval,'&math_calculus_expression');
+ $safehole->wrap(\&Number::FormatEng::format_eng,$safeeval,'&number_format_eng');
+ $safehole->wrap(\&Number::FormatEng::format_pref,$safeeval,'&number_format_pref');
# use Data::Dumper;
# $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');
@@ -1086,7 +1091,7 @@ sub decreasedepth {
sub get_id {
my ($parstack,$safeeval)=@_;
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
- if ($env{'request.state'} eq 'construct' && $id =~ /([._]|[^\w\d\s[:punct:]])/) {
+ if ($env{'request.state'} eq 'construct' && $id =~ /([._]|[^\w\s\-])/) {
&error(&mt('ID [_1] contains invalid characters. IDs are only allowed to contain letters, numbers, spaces and -','"'.$id.'"'));
}
if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
@@ -1703,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();
@@ -1712,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) {
@@ -1720,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=(<