Diff for /loncom/xml/lonxml.pm between versions 1.150 and 1.155

version 1.150, 2002/01/18 17:04:46 version 1.155, 2002/03/06 20:28:19
Line 316  sub fontsettings() { Line 316  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 349  ENDGRDS
 ENDPARM  ENDPARM
             }              }
  }   }
  return (<<ENDREGTHIS);   $result = (<<ENDREGTHIS);
             
 <script language="JavaScript">  <script language="JavaScript">
 // BEGIN LON-CAPA Internal  // BEGIN LON-CAPA Internal
Line 399  ENDPARM Line 401  ENDPARM
 ENDREGTHIS  ENDREGTHIS
   
     } else {      } else {
         return (<<ENDDONOTREGTHIS);          $result = (<<ENDDONOTREGTHIS);
   
 <script language="JavaScript">  <script language="JavaScript">
 // BEGIN LON-CAPA Internal  // BEGIN LON-CAPA Internal
Line 426  ENDREGTHIS Line 428  ENDREGTHIS
 // END LON-CAPA Internal  // END LON-CAPA Internal
 </script>  </script>
 ENDDONOTREGTHIS  ENDDONOTREGTHIS
   
     }      }
       if ($target eq 'edit') {
           $result .=<<"ENDBROWSERSCRIPT";
   <script>
       var editform;
       function openbrowser(formname,elementname) {
           var url = '/res/?';
           if (editform == 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';
           editform = open(url,title,options,'1');
           editform.focus();
       }
   </script>
   ENDBROWSERSCRIPT
       }
       return $result;
 }  }
   
 sub loadevents() {  sub loadevents() {
Line 538  sub inner_xmlparse { Line 562  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 650  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 713  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 897  sub get_all_text { Line 921  sub get_all_text {
      } elsif ($token->[0] eq 'PI') {       } elsif ($token->[0] eq 'PI') {
        $result.=$token->[2];         $result.=$token->[2];
      } elsif ($token->[0] eq 'S') {       } elsif ($token->[0] eq 'S') {
        if ($token->[1] eq $tag) { $depth++; }         if ($token->[1] =~ /^$tag$/i) { $depth++; }
        $result.=$token->[4];         $result.=$token->[4];
      } elsif ($token->[0] eq 'E')  {       } elsif ($token->[0] eq 'E')  {
        if ( $token->[1] eq $tag) { $depth--; }         if ( $token->[1] =~ /^$tag$/i) { $depth--; }
        #skip sending back the last end tag         #skip sending back the last end tag
        if ($depth > -1) { $result.=$token->[2]; } else {         if ($depth > -1) { $result.=$token->[2]; } else {
  $pars->unget_token($token);   $pars->unget_token($token);
Line 915  sub get_all_text { Line 939  sub get_all_text {
      } elsif ($token->[0] eq 'PI') {       } elsif ($token->[0] eq 'PI') {
        $result.=$token->[2];         $result.=$token->[2];
      } elsif ($token->[0] eq 'S') {       } elsif ($token->[0] eq 'S') {
        if ( $token->[1] eq $tag) {          if ( $token->[1] =~ /^$tag$/i) {
  $pars->unget_token($token); last;   $pars->unget_token($token); last;
        } else {         } else {
  $result.=$token->[4];   $result.=$token->[4];
Line 978  sub writeallows { Line 1002  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 1028  sub storefile { Line 1044  sub storefile {
     }      }
 }  }
   
 sub inserteditinfo {  sub createnewhtml {
       my ($result,$filecontents)=@_;    my $filecontents=(<<SIMPLECONTENT);
       unless ($filecontents) {  
   $filecontents=(<<SIMPLECONTENT);  
 <html>  <html>
 <head>  <head>
 <title>  <title>
Line 1045  sub inserteditinfo { Line 1059  sub inserteditinfo {
 </body>  </body>
 </html>  </html>
 SIMPLECONTENT  SIMPLECONTENT
       }    return $filecontents;
   }
   
   
   sub inserteditinfo {
         my ($result,$filecontents)=@_;
       $filecontents =~ s:</textarea>:&lt;/textarea&gt;:ig;        $filecontents =~ s:</textarea>:&lt;/textarea&gt;:ig;
 #      my $editheader='<a href="#editsection">Edit below</a><hr />';  #      my $editheader='<a href="#editsection">Edit below</a><hr />';
       my $editfooter=(<<ENDFOOTER);        my $editfooter=(<<ENDFOOTER);
Line 1067  ENDFOOTER Line 1085  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 1109  sub handler { Line 1154  sub handler {
 </html>  </html>
 ENDNOTFOUND  ENDNOTFOUND
     $filecontents='';      $filecontents='';
       if ($ENV{'request.state'} ne 'published') {
         $filecontents=&createnewhtml();
         $ENV{'form.showmode'}='Edit'; #force edit mode
       }
   } else {    } else {
     unless ($ENV{'request.state'} eq 'published') {      unless ($ENV{'request.state'} eq 'published') {
       if ($ENV{'form.attemptclean'}) {        if ($ENV{'form.attemptclean'}) {

Removed from v.1.150  
changed lines
  Added in v.1.155


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