Diff for /loncom/xml/lonxml.pm between versions 1.151 and 1.158

version 1.151, 2002/01/30 16:04:04 version 1.158, 2002/03/18 21:51:34
Line 64  qw(@pwd @outputstack $redirection $impor Line 64  qw(@pwd @outputstack $redirection $impor
 use strict;  use strict;
 use HTML::TokeParser;  use HTML::TokeParser;
 use HTML::TreeBuilder;  use HTML::TreeBuilder;
   use HTML::Entities;
 use Safe;  use Safe;
 use Safe::Hole;  use Safe::Hole;
 use Math::Cephes qw(:trigs :hypers :bessels erf erfc);  use Math::Cephes qw(:trigs :hypers :bessels erf erfc);
Line 316  sub fontsettings() { Line 317  sub fontsettings() {
   
 sub registerurl {  sub registerurl {
     my $forcereg=shift;      my $forcereg=shift;
       my $target = shift;
       my $result = '';
     if ($ENV{'request.publicaccess'}) {      if ($ENV{'request.publicaccess'}) {
  return    return 
          '<script>function LONCAPAreg(){} function LONCAPAstale(){}</script>';           '<script>function LONCAPAreg(){} function LONCAPAstale(){}</script>';
Line 347  ENDGRDS Line 350  ENDGRDS
 ENDPARM  ENDPARM
             }              }
  }   }
  return (<<ENDREGTHIS);   $result = (<<ENDREGTHIS);
             
 <script language="JavaScript">  <script language="JavaScript">
 // BEGIN LON-CAPA Internal  // BEGIN LON-CAPA Internal
   
     function LONCAPAreg() {      function LONCAPAreg() {
   menu=window.open("","LONCAPAmenu");    menu=window.open("","LONCAPAmenu","",false);
           menu.clearTimeout(menu.menucltim);            menu.clearTimeout(menu.menucltim);
   menu.currentURL=window.location.pathname;    menu.currentURL=window.location.pathname;
           menu.currentStale=0;            menu.currentStale=0;
Line 380  ENDPARM Line 383  ENDPARM
     }      }
   
     function LONCAPAstale() {      function LONCAPAstale() {
   menu=window.open("","LONCAPAmenu");    menu=window.open("","LONCAPAmenu","",false);
           menu.currentStale=1;            menu.currentStale=1;
           menu.switchbutton            menu.switchbutton
              (3,1,'reload.gif','return','location','go(currentURL)');               (3,1,'reload.gif','return','location','go(currentURL)');
Line 399  ENDPARM Line 402  ENDPARM
 ENDREGTHIS  ENDREGTHIS
   
     } else {      } else {
         return (<<ENDDONOTREGTHIS);          $result = (<<ENDDONOTREGTHIS);
   
 <script language="JavaScript">  <script language="JavaScript">
 // BEGIN LON-CAPA Internal  // BEGIN LON-CAPA Internal
   
     function LONCAPAreg() {      function LONCAPAreg() {
   menu=window.open("","LONCAPAmenu");    menu=window.open("","LONCAPAmenu","",false);
           menu.currentStale=1;            menu.currentStale=1;
           menu.clearbut(2,1);            menu.clearbut(2,1);
           menu.clearbut(2,3);            menu.clearbut(2,3);
Line 426  ENDREGTHIS Line 429  ENDREGTHIS
 // END LON-CAPA Internal  // END LON-CAPA Internal
 </script>  </script>
 ENDDONOTREGTHIS  ENDDONOTREGTHIS
   
     }      }
       if ($target eq 'edit') {
    # Javascript routines for construction space:
    # openbrowser and opensearcher will start the file browser
    # (lonindexer) and searcher (lonsearchcat) respectively.
    # Inputs are the name of the html form being used
    # and the name of the element the selected URL should
    # be placed in.
           $result .=<<"ENDBROWSERSCRIPT";
   <script>
       var editbrowser;
       function openbrowser(formname,elementname) {
           var url = '/res/?';
           if (editbrowser == null) {
               url += 'launch=1&';
           }
           url += 'catalogmode=interactive&';
           url += 'mode=edit&';
           url += 'form=' + formname + '&';
           url += 'element=' + elementname + '';
           var title = 'Browser';
           var options = 'scrollbars=1,resizable=1,menubar=0';
           options += ',width=700,height=600';
           editbrowser = open(url,title,options,'1');
           editbrowser.focus();
       }
       var editsearcher;
       function opensearcher(formname,elementname) {
           var url = '/adm/searchcat?';
           if (editsearcher == null) {
               url += 'launch=1&';
           }
           url += 'catalogmode=interactive&';
           url += 'mode=edit&';
           url += 'form=' + formname + '&';
           url += 'element=' + elementname + '';
           var title = 'Search';
           var options = 'scrollbars=1,resizable=1,menubar=0';
           options += ',width=700,height=600';
           editsearcher = open(url,title,options,'1');
           editsearcher.focus();
       }
   </script>
   ENDBROWSERSCRIPT
       }
       return $result;
 }  }
   
 sub loadevents() {  sub loadevents() {
Line 538  sub inner_xmlparse { Line 585  sub inner_xmlparse {
     &Apache::lonxml::warning('Using tag &lt;/'.$token->[1].'&gt; as end tag to &lt;'.$$stack[-1].'&gt;');      &Apache::lonxml::warning('Using tag &lt;/'.$token->[1].'&gt; as end tag to &lt;'.$$stack[-1].'&gt;');
     last;      last;
   } else {    } else {
     &Apache::lonxml::warning('Found tag &lt;/'.$$stack[-1].'&gt; when looking for &lt;/'.$token->[1].'&gt; in file');      &Apache::lonxml::warning('Found tag &lt;/'.$token->[1].'&gt; when looking for &lt;/'.$$stack[-1].'&gt; in file');
     &end_tag($stack,$parstack,$token);      &end_tag($stack,$parstack,$token);
   }    }
  }   }
Line 626  sub recurse { Line 673  sub recurse {
     &Apache::lonxml::warning('Using tag &lt;/'.$tokenpat->[1].'&gt; as end tag to &lt;'.$innerstack[-1].'&gt;');      &Apache::lonxml::warning('Using tag &lt;/'.$tokenpat->[1].'&gt; as end tag to &lt;'.$innerstack[-1].'&gt;');
     last;      last;
   } else {    } else {
     &Apache::lonxml::warning('Found tag &lt;/'.$innerstack[-1].'&gt; when looking for &lt;/'.$tokenpat->[1].'&gt; in file');      &Apache::lonxml::warning('Found tag &lt;/'.$tokenpat->[1].'&gt; when looking for &lt;/'.$innerstack[-1].'&gt; in file');
     &end_tag(\@innerstack,\@innerparstack,$tokenpat);      &end_tag(\@innerstack,\@innerparstack,$tokenpat);
   }    }
  }   }
Line 689  sub callsub { Line 736  sub callsub {
     }      }
     if (!$deleted) {      if (!$deleted) {
       if ($space) {        if ($space) {
  #&Apache::lonxml::debug("Calling sub $sub in $space $metamode<br />\n");   #&Apache::lonxml::debug("Calling sub $sub in $space $metamode");
  $sub1="$space\:\:$sub";   $sub1="$space\:\:$sub";
  ($currentstring,$nodefault) = &$sub1($target,$token,$tagstack,   ($currentstring,$nodefault) = &$sub1($target,$token,$tagstack,
      $parstack,$parser,$safeeval,       $parstack,$parser,$safeeval,
      $style);       $style);
       } else {        } else {
  #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode<br />\n");   #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode");
  if ($metamode <1) {   if ($metamode <1) {
   if (defined($token->[4]) && ($metamode < 1)) {    if (defined($token->[4]) && ($metamode < 1)) {
     $currentstring = $token->[4];      $currentstring = $token->[4];
Line 978  sub writeallows { Line 1025  sub writeallows {
 #  #
 sub afterburn {  sub afterburn {
     my $result=shift;      my $result=shift;
     foreach (split(/&/,$ENV{'QUERY_STRING'})) {      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
        my ($name, $value) = split(/=/,$_);      ['highlight','anchor','link']);
        $value =~ tr/+/ /;  
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;  
        if (($name eq 'highlight')||($name eq 'anchor')||($name eq 'link')) {  
            unless ($ENV{'form.'.$name}) {  
               $ENV{'form.'.$name}=$value;  
    }  
        }  
     }  
     if ($ENV{'form.highlight'}) {      if ($ENV{'form.highlight'}) {
        foreach (split(/\,/,$ENV{'form.highlight'})) {         foreach (split(/\,/,$ENV{'form.highlight'})) {
            my $anchorname=$_;             my $anchorname=$_;
Line 1049  SIMPLECONTENT Line 1088  SIMPLECONTENT
   
 sub inserteditinfo {  sub inserteditinfo {
       my ($result,$filecontents)=@_;        my ($result,$filecontents)=@_;
       $filecontents =~ s:</textarea>:&lt;/textarea&gt;:ig;        $filecontents = &HTML::Entities::encode($filecontents);
 #      my $editheader='<a href="#editsection">Edit below</a><hr />';  #      my $editheader='<a href="#editsection">Edit below</a><hr />';
       my $editfooter=(<<ENDFOOTER);        my $editfooter=(<<ENDFOOTER);
 <hr />  <hr />
Line 1069  ENDFOOTER Line 1108  ENDFOOTER
       return $result;        return $result;
 }  }
   
   sub get_target {
     my $viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
     if ( $ENV{'request.state'} eq 'published') {
       if ( defined($ENV{'form.grade_target'})
    && ($viewgrades == 'F' )) {
         return ($ENV{'form.grade_target'});
       } elsif (defined($ENV{'form.grade_target'})) {
         if (($ENV{'form.grade_target'} eq 'web') ||
     ($ENV{'form.grade_target'} eq 'tex') ) {
    return $ENV{'form.grade_target'}
         } else {
    return 'web';
         }
       } else {
         return 'web';
       }
     } elsif ($ENV{'request.state'} eq 'construct') {
       if ( defined($ENV{'form.grade_target'})) {
         return ($ENV{'form.grade_target'});
       } else {
         return 'web';
       }
     } else {
       return 'web';
     }
   }
   
 sub handler {  sub handler {
   my $request=shift;    my $request=shift;
   
   my $target='web';    my $target=&get_target();
   
   $Apache::lonxml::debug=0;    $Apache::lonxml::debug=0;
   
Line 1185  sub get_param { Line 1251  sub get_param {
   if ( ! $context ) { $context = -1; }    if ( ! $context ) { $context = -1; }
   my $args ='';    my $args ='';
   if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }    if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
     if ( ! $args ) { return undef; }
   if ( $args =~ /my \$$param=\"/ ) {    if ( $args =~ /my \$$param=\"/ ) {
     return &Apache::run::run("{$args;".'return $'.$param.'}',$safeeval); #'      return &Apache::run::run("{$args;".'return $'.$param.'}',$safeeval); #'
   } else {    } else {

Removed from v.1.151  
changed lines
  Added in v.1.158


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