--- loncom/xml/lonxml.pm 2011/12/09 21:21:43 1.527
+++ loncom/xml/lonxml.pm 2012/12/06 13:54:47 1.536
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.527 2011/12/09 21:21:43 www Exp $
+# $Id: lonxml.pm,v 1.536 2012/12/06 13:54:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -113,6 +113,7 @@ use Apache::lonr();
use Apache::lonlocal;
use Apache::lonhtmlcommon();
use Apache::functionplotresponse();
+use Apache::lonnavmaps();
#==================================== Main subroutine: xmlparse
@@ -210,8 +211,12 @@ sub xmlend {
my $discussion;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['LONCAPA_INTERNAL_no_discussion']);
- if (! exists($env{'form.LONCAPA_INTERNAL_no_discussion'}) ||
- $env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {
+ if (
+ ( (!exists($env{'form.LONCAPA_INTERNAL_no_discussion'}))
+ || ($env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true')
+ )
+ && ($env{'form.inhibitmenu'} ne 'yes')
+ ) {
$discussion=&Apache::lonfeedback::list_discussion($mode,$status);
}
if ($target eq 'tex') {
@@ -644,9 +649,9 @@ sub setup_globals {
sub init_safespace {
my ($target,$safeeval,$safehole,$safeinit) = @_;
- $safeeval->reval('use Math::Complex;');
$safeeval->reval('use LaTeX::Table;');
$safeeval->deny_only(':dangerous');
+ $safeeval->reval('use Math::Complex;');
$safeeval->permit_only(":default");
$safeeval->permit("entereval");
$safeeval->permit(":base_math");
@@ -1505,12 +1510,12 @@ sub renderingoptions {
}
sub inserteditinfo {
- my ($filecontents, $filetype, $filename)=@_;
+ my ($filecontents,$filetype,$filename,$symb,$itemtitle,$folderpath,$uri) = @_;
$filecontents = &HTML::Entities::encode($filecontents,'<>&"');
my $xml_help = '';
my $initialize='';
my $textarea_id = 'filecont';
- my $dragmath_button;
+ my ($dragmath_button,$deps_button);
my ($add_to_onload, $add_to_onresize);
$initialize=&Apache::lonhtmlcommon::spellheader();
if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) {
@@ -1531,6 +1536,12 @@ sub inserteditinfo {
FULLPAGE
if ($filetype eq 'html') {
+ if ($symb || $folderpath) {
+ $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n";
+ $initialize .=
+ &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle,
+ undef,$folderpath,$uri)."\n";
+ }
$dragmath_button = ''.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'';
$initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
}
@@ -1575,7 +1586,7 @@ $initialize
- $htmlerror $dragmath_button
+ $htmlerror $deps_button $dragmath_button
@@ -1656,8 +1667,10 @@ sub handler {
my ($filetype,$breadcrumbtext);
if ($file =~ /\.(sty|css|js|txt|tex)$/) {
$filetype=$1;
+ $env{'request.uri'}=$request->uri;
} else {
$filetype='html';
+ $env{'request.uri'}=$request->uri;
}
if ($filetype eq 'sty') {
$breadcrumbtext = 'Style File Editor';
@@ -1784,11 +1797,27 @@ ENDNOTFOUND
unless ($env{'request.state'} eq 'published') {
if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'})))
{
- my $displayfile=$request->uri;
- $displayfile=~s/^\/[^\/]*//;
+ my ($displayfile,$url,$symb,$itemtitle);
+ $displayfile=$request->uri;
+ if ($request->uri =~ m{^/uploaded/}) {
+ if ($env{'request.course.id'}) {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/\Esupplemental/}) {
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['folderpath','title']);
+ }
+ }
+ ($symb,$itemtitle,$displayfile) =
+ &get_courseupload_hierarchy($request->uri,
+ $env{'form.folderpath'},$env{'form.title'});
+ } else {
+ $displayfile=~s/^\/[^\/]*//;
+ }
my ($edit_info, $add_to_onload, $add_to_onresize)=
- &inserteditinfo($filecontents,$filetype,$displayfile);
+ &inserteditinfo($filecontents,$filetype,$displayfile,$symb,
+ $itemtitle,$env{'form.folderpath'},$request->uri);
my %options =
('add_entries' =>
@@ -1838,6 +1867,41 @@ sub display_title {
return $result;
}
+sub get_courseupload_hierarchy {
+ my ($url,$folderpath,$title) = @_;
+ my ($symb,$itemtitle,$displaypath);
+ if ($env{'request.course.id'}) {
+ if ($folderpath =~ /^supplemental/) {
+ my @folders = split(/\&/,$folderpath);
+ my @pathitems;
+ while (@folders) {
+ my $folder=shift(@folders);
+ my $foldername=shift(@folders);
+ push(@pathitems,&unescape($foldername));
+ }
+ if ($title) {
+ push(@pathitems,&unescape($title));
+ }
+ $displaypath = join(' » ',@pathitems);
+ } else {
+ $symb = &Apache::lonnet::symbread($url);
+ my ($map,$id,$res)=&Apache::lonnet::decode_symb($symb);
+ my $navmap=Apache::lonnavmaps::navmap->new;
+ if (ref($navmap)) {
+ my $res = $navmap->getBySymb($symb);
+ if (ref($res)) {
+ my @pathitems =
+ &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
+ $itemtitle = $res->compTitle();
+ push(@pathitems,$itemtitle);
+ $displaypath = join(' » ',@pathitems);
+ }
+ }
+ }
+ }
+ return ($symb,$itemtitle,$displaypath);
+}
+
sub debug {
if ($Apache::lonxml::debug eq "1") {
$|=1;
@@ -1920,7 +1984,7 @@ sub error {
my @userlist;
foreach (keys %users) {
my ($user,$domain) = split(/:/, $_);
- push(@userlist,"$user\@$domain");
+ push(@userlist,"$user:$domain");
my $key=$declutter.'_'.$user.'_'.$domain;
my %lastnotified=&Apache::lonnet::get('nohist_xmlerrornotifications',
[$key],
@@ -1943,7 +2007,7 @@ sub error {
$errormsg=&mt("An error occurred while processing this resource. The instructor has been notified.");
}
}
- push(@Apache::lonxml::error_messages,"$errormsg
");
+ push(@Apache::lonxml::error_messages,"$errormsg
");
}
}
@@ -1988,16 +2052,25 @@ sub add_messages {
}
sub get_param {
- my ($param,$parstack,$safeeval,$context,$case_insensitive) = @_;
+ my ($param,$parstack,$safeeval,$context,$case_insensitive, $noelide) = @_;
+
if ( ! $context ) { $context = -1; }
my $args ='';
if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
if ( ! $Apache::lonxml::usestyle ) {
$args=$Apache::lonxml::style_values.$args;
}
+
+
+ if ($noelide) {
+# $args =~ s/\\'/'/g;
+ $args =~ s/'\$/'\\\$/g;
+ }
+
if ( ! $args ) { return undef; }
if ( $case_insensitive ) {
if ($args =~ s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei) {
+
return &Apache::run::run("{$args;".'return $'.$param.'}',
$safeeval); #'
} else {
@@ -2005,6 +2078,7 @@ sub get_param {
}
} else {
if ( $args =~ /my .*\$\Q$param\E[,\)]/ ) {
+
return &Apache::run::run("{$args;".'return $'.$param.'}',
$safeeval); #'
} else {