--- loncom/xml/lonxml.pm 2011/11/14 00:20:42 1.523 +++ loncom/xml/lonxml.pm 2012/05/10 19:08:33 1.531.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.523 2011/11/14 00:20:42 raeburn Exp $ +# $Id: lonxml.pm,v 1.531.2.1 2012/05/10 19:08:33 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') { @@ -301,7 +306,8 @@ sub xmlparse { &clean_safespace($safeeval); if (@script_var_displays) { - $finaloutput .= join('',@script_var_displays); + my $scriptoutput = join('',@script_var_displays); + $finaloutput=~s{(\s*)\s*$}{$scriptoutput$1}s; undef(@script_var_displays); } &init_state(); @@ -792,6 +798,10 @@ sub init_safespace { $safehole->wrap(\&Apache::functionplotresponse::fpr_f,$safeeval,'&fpr_f'); $safehole->wrap(\&Apache::functionplotresponse::fpr_dfdx,$safeeval,'&fpr_dfdx'); $safehole->wrap(\&Apache::functionplotresponse::fpr_d2fdx2,$safeeval,'&fpr_d2fdx2'); + $safehole->wrap(\&Apache::functionplotresponse::fpr_vectorcoords,$safeeval,'&fpr_vectorcoords'); + $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'); # use Data::Dumper; # $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper'); @@ -1492,19 +1502,19 @@ sub renderingoptions { {&Apache::lonlocal::texthash ('' => '', 'tth' => 'tth (TeX to HTML)', - 'jsMath' => 'jsMath', + 'jsMath' => 'jsMath', 'mimetex' => 'mimetex (Convert to Images)')}). ''; return $output; } sub inserteditinfo { - my ($filecontents, $filetype, $filename)=@_; + my ($filecontents,$filetype,$filename,$symb,$itemtitle) = @_; $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())) { @@ -1525,6 +1535,11 @@ sub inserteditinfo { FULLPAGE if ($filetype eq 'html') { + if ($symb) { + $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n"; + $initialize .= + &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle)."\n"; + } $dragmath_button = ''.&Apache::lonhtmlcommon::dragmath_button('filecont',1).''; $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup'); } @@ -1569,7 +1584,7 @@ $initialize
- $htmlerror $dragmath_button + $htmlerror $deps_button $dragmath_button
@@ -1778,11 +1793,17 @@ 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/}) { + ($symb,$itemtitle,$displayfile) = + &get_courseupload_hierarchy($request->uri); + } else { + $displayfile=~s/^\/[^\/]*//; + } my ($edit_info, $add_to_onload, $add_to_onresize)= - &inserteditinfo($filecontents,$filetype,$displayfile); + &inserteditinfo($filecontents,$filetype,$displayfile,$symb,$itemtitle); my %options = ('add_entries' => @@ -1832,6 +1853,27 @@ sub display_title { return $result; } +sub get_courseupload_hierarchy { + my ($url) = @_; + my ($symb,$itemtitle,$displaypath); + if ($env{'request.course.id'}) { + $symb = &Apache::lonnet::symbread(); + 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; @@ -1914,7 +1956,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], @@ -1937,7 +1979,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
"); } } @@ -2045,11 +2087,13 @@ sub register_insert_xml { while (my $token = $parser->get_token()) { if ($token->[0] eq 'S') { my $key; - if ($token->[1] eq 'tag') { + if ($token->[1] eq 'tag') { $tag = $token->[2]{'name'}; - $insertlist{$tagnum.'.tag'} = $tag; - $insertlist{$tag.'.num'} = $tagnum; - push(@alltags,$tag); + if (defined($tag)) { + $insertlist{$tagnum.'.tag'} = $tag; + $insertlist{$tag.'.num'} = $tagnum; + push(@alltags,$tag); + } } elsif ($in_help && $token->[1] eq 'file') { $key = $tag.'.helpfile'; } elsif ($in_help && $token->[1] eq 'description') {