Diff for /loncom/xml/lonxml.pm between versions 1.522 and 1.533

version 1.522, 2011/11/11 02:55:37 version 1.533, 2012/11/21 23:13:30
Line 113  use Apache::lonr(); Line 113  use Apache::lonr();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
 use Apache::functionplotresponse();  use Apache::functionplotresponse();
   use Apache::lonnavmaps();
   
 #====================================   Main subroutine: xmlparse    #====================================   Main subroutine: xmlparse  
   
Line 210  sub xmlend { Line 211  sub xmlend {
     my $discussion;      my $discussion;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
    ['LONCAPA_INTERNAL_no_discussion']);     ['LONCAPA_INTERNAL_no_discussion']);
     if (! exists($env{'form.LONCAPA_INTERNAL_no_discussion'}) ||      if (
         $env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {             (   (!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);          $discussion=&Apache::lonfeedback::list_discussion($mode,$status);
     }      }
     if ($target eq 'tex') {      if ($target eq 'tex') {
Line 301  sub xmlparse { Line 306  sub xmlparse {
  &clean_safespace($safeeval);   &clean_safespace($safeeval);
   
  if (@script_var_displays) {   if (@script_var_displays) {
      $finaloutput .= join('',@script_var_displays);       my $scriptoutput = join('',@script_var_displays);
        $finaloutput=~s{(</body>\s*</html>)\s*$}{$scriptoutput$1}s;
      undef(@script_var_displays);       undef(@script_var_displays);
  }   }
  &init_state();   &init_state();
Line 643  sub setup_globals { Line 649  sub setup_globals {
   
 sub init_safespace {  sub init_safespace {
   my ($target,$safeeval,$safehole,$safeinit) = @_;    my ($target,$safeeval,$safehole,$safeinit) = @_;
   $safeeval->reval('use Math::Complex;');  
   $safeeval->reval('use LaTeX::Table;');    $safeeval->reval('use LaTeX::Table;');
   $safeeval->deny_only(':dangerous');    $safeeval->deny_only(':dangerous');
     $safeeval->reval('use Math::Complex;');
   $safeeval->permit_only(":default");    $safeeval->permit_only(":default");
   $safeeval->permit("entereval");    $safeeval->permit("entereval");
   $safeeval->permit(":base_math");    $safeeval->permit(":base_math");
Line 792  sub init_safespace { Line 798  sub init_safespace {
   $safehole->wrap(\&Apache::functionplotresponse::fpr_f,$safeeval,'&fpr_f');    $safehole->wrap(\&Apache::functionplotresponse::fpr_f,$safeeval,'&fpr_f');
   $safehole->wrap(\&Apache::functionplotresponse::fpr_dfdx,$safeeval,'&fpr_dfdx');    $safehole->wrap(\&Apache::functionplotresponse::fpr_dfdx,$safeeval,'&fpr_dfdx');
   $safehole->wrap(\&Apache::functionplotresponse::fpr_d2fdx2,$safeeval,'&fpr_d2fdx2');    $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;  #  use Data::Dumper;
 #  $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');  #  $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');
Line 1492  sub renderingoptions { Line 1502  sub renderingoptions {
            {&Apache::lonlocal::texthash             {&Apache::lonlocal::texthash
                (''        => '',                 (''        => '',
                 'tth'     => 'tth (TeX to HTML)',                  'tth'     => 'tth (TeX to HTML)',
                 'jsMath'  => 'jsMath',                  'MathJax' => 'MathJax',
     'jsMath'  => 'jsMath',
                 'mimetex' => 'mimetex (Convert to Images)')}).                  'mimetex' => 'mimetex (Convert to Images)')}).
      '</span>';       '</span>';
     return $output;      return $output;
 }  }
   
 sub inserteditinfo {  sub inserteditinfo {
       my ($filecontents, $filetype, $filename)=@_;        my ($filecontents,$filetype,$filename,$symb,$itemtitle) = @_;
       $filecontents = &HTML::Entities::encode($filecontents,'<>&"');        $filecontents = &HTML::Entities::encode($filecontents,'<>&"');
       my $xml_help = '';        my $xml_help = '';
       my $initialize='';        my $initialize='';
       my $textarea_id = 'filecont';        my $textarea_id = 'filecont';
       my $dragmath_button;        my ($dragmath_button,$deps_button);
       my ($add_to_onload, $add_to_onresize);        my ($add_to_onload, $add_to_onresize);
       $initialize=&Apache::lonhtmlcommon::spellheader();        $initialize=&Apache::lonhtmlcommon::spellheader();
       if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) {        if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) {
Line 1525  sub inserteditinfo { Line 1536  sub inserteditinfo {
 </script>  </script>
 FULLPAGE  FULLPAGE
       if ($filetype eq 'html') {        if ($filetype eq 'html') {
             if ($symb) {
                 $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n";
                 $initialize .= 
                     &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle)."\n";
             }
           $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';            $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';
           $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');            $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
       }        }
Line 1569  $initialize Line 1585  $initialize
     <div class="LC_edit_problem_discards">      <div class="LC_edit_problem_discards">
       <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />        <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />
       <input type="submit" name="Undo" accesskey="u" value="$lt{'un'}" />        <input type="submit" name="Undo" accesskey="u" value="$lt{'un'}" />
       $htmlerror $dragmath_button        $htmlerror $deps_button $dragmath_button
     </div>      </div>
     <div class="LC_edit_problem_saves">      <div class="LC_edit_problem_saves">
       <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />        <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />
Line 1754  ENDNOTFOUND Line 1770  ENDNOTFOUND
                 }                  }
                 my $brcrum;                  my $brcrum;
                 if ($env{'request.state'} eq 'construct') {                  if ($env{'request.state'} eq 'construct') {
                     $brcrum = [{'href' => &Apache::loncommon::authorspace(),                      $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                                 'text' => 'Construction Space'},                                  'text' => 'Construction Space'},
                                {'href' => '',                                 {'href' => '',
                                 'text' => $breadcrumbtext}];                                  'text' => $breadcrumbtext}];
Line 1778  ENDNOTFOUND Line 1794  ENDNOTFOUND
     unless ($env{'request.state'} eq 'published') {      unless ($env{'request.state'} eq 'published') {
  if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'})))   if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'})))
  {   {
     my $displayfile=$request->uri;              my ($displayfile,$url,$symb,$itemtitle);
     $displayfile=~s/^\/[^\/]*//;      $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)=      my ($edit_info, $add_to_onload, $add_to_onresize)=
  &inserteditinfo($filecontents,$filetype,$displayfile);   &inserteditinfo($filecontents,$filetype,$displayfile,$symb,$itemtitle);
   
     my %options =       my %options = 
  ('add_entries' =>   ('add_entries' =>
Line 1791  ENDNOTFOUND Line 1813  ENDNOTFOUND
             my $header;              my $header;
             if ($env{'request.state'} eq 'construct') {              if ($env{'request.state'} eq 'construct') {
                 $options{'bread_crumbs'} = [{                  $options{'bread_crumbs'} = [{
                             'href' => &Apache::loncommon::authorspace(),                              'href' => &Apache::loncommon::authorspace($request->uri),
                             'text' => 'Construction Space'},                              'text' => 'Construction Space'},
                            {'href' => '',                             {'href' => '',
                             'text' => $breadcrumbtext}];                              'text' => $breadcrumbtext}];
Line 1832  sub display_title { Line 1854  sub display_title {
     return $result;      return $result;
 }  }
   
   sub get_courseupload_hierarchy {
       my ($url) = @_;
       my ($symb,$itemtitle,$displaypath);
       if ($env{'request.course.id'}) {
           $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(' &raquo; ',@pathitems);
               }
           }
       }
       return ($symb,$itemtitle,$displaypath);
   }
   
 sub debug {  sub debug {
     if ($Apache::lonxml::debug eq "1") {      if ($Apache::lonxml::debug eq "1") {
  $|=1;   $|=1;
Line 1914  sub error { Line 1957  sub error {
     my @userlist;      my @userlist;
     foreach (keys %users) {      foreach (keys %users) {
  my ($user,$domain) = split(/:/, $_);   my ($user,$domain) = split(/:/, $_);
  push(@userlist,"$user\@$domain");   push(@userlist,"$user:$domain");
  my $key=$declutter.'_'.$user.'_'.$domain;   my $key=$declutter.'_'.$user.'_'.$domain;
  my %lastnotified=&Apache::lonnet::get('nohist_xmlerrornotifications',   my %lastnotified=&Apache::lonnet::get('nohist_xmlerrornotifications',
       [$key],        [$key],
Line 1937  sub error { Line 1980  sub error {
  $errormsg=&mt("An error occurred while processing this resource. The instructor has been notified.");   $errormsg=&mt("An error occurred while processing this resource. The instructor has been notified.");
     }      }
  }   }
  push(@Apache::lonxml::error_messages,"<b>$errormsg</b> <br />");   push(@Apache::lonxml::error_messages,"<span class=\"LC_warning\">$errormsg</span><br />");
     }      }
 }  }
   
Line 2045  sub register_insert_xml { Line 2088  sub register_insert_xml {
     while (my $token = $parser->get_token()) {      while (my $token = $parser->get_token()) {
  if ($token->[0] eq 'S') {   if ($token->[0] eq 'S') {
     my $key;      my $key;
     if      ($token->[1] eq 'tag') {      if ($token->[1] eq 'tag') {
  $tag = $token->[2]{'name'};   $tag = $token->[2]{'name'};
  $insertlist{$tagnum.'.tag'} = $tag;                  if (defined($tag)) {
  $insertlist{$tag.'.num'}   = $tagnum;      $insertlist{$tagnum.'.tag'} = $tag;
  push(@alltags,$tag);      $insertlist{$tag.'.num'}   = $tagnum;
       push(@alltags,$tag);
                   }
     } elsif ($in_help && $token->[1] eq 'file') {      } elsif ($in_help && $token->[1] eq 'file') {
  $key = $tag.'.helpfile';   $key = $tag.'.helpfile';
     } elsif ($in_help && $token->[1] eq 'description') {      } elsif ($in_help && $token->[1] eq 'description') {

Removed from v.1.522  
changed lines
  Added in v.1.533


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>