File:  [LON-CAPA] / loncom / xml / scripttag.pm
Revision 1.119: download - view: text, annotated - select for diffs
Fri Oct 8 13:43:31 2004 UTC (19 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- <display> calling &xmlparse() had issues

    1: # The LearningOnline Network with CAPA
    2: # <script> definiton
    3: #
    4: # $Id: scripttag.pm,v 1.119 2004/10/08 13:43:31 albertel Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: 
   29: package Apache::scripttag;
   30: 
   31: use strict;
   32: use Apache::lonnet;
   33: use Apache::style;
   34: 
   35: #Globals
   36: # this used to pass around the standard callsub arguments to a tag func
   37: # so xmlparse can reenter the inner_xmlparse loop.
   38: 
   39: @Apache::scripttag::parser_env = ();
   40: BEGIN {
   41:   &Apache::lonxml::register('Apache::scripttag',
   42: 			    ('script','scriptlib','parserlib','import',
   43: 			     'window','display','storetc','physnet',
   44: 			     'standalone','comment',
   45: 			     'LONCAPA_INTERNAL_TURN_STYLE_ON',
   46: 			     'LONCAPA_INTERNAL_TURN_STYLE_OFF',
   47: 			     'LONCAPA_INTERNAL_LONHTTPD_PORT'));
   48: }
   49: 
   50: sub start_LONCAPA_INTERNAL_TURN_STYLE_ON {
   51:     $Apache::lonxml::usestyle=1;
   52:     $Apache::lonxml::style_values='';
   53:     return ('','no');
   54: }
   55: 
   56: sub end_LONCAPA_INTERNAL_TURN_STYLE_ON {
   57:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   58:     my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
   59:     if (defined($end)) {
   60: 	&Apache::lonxml::end_tag($tagstack,$parstack,$token);
   61:     }
   62:     return ('','no');
   63: }
   64: 
   65: sub start_LONCAPA_INTERNAL_TURN_STYLE_OFF {
   66:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   67:     $Apache::lonxml::usestyle=0;
   68:     my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
   69:     if (!$end) {
   70: 	$Apache::lonxml::style_values=$$parstack[-1];
   71: 	$Apache::lonxml::style_end_values=$$parstack[-1];
   72:     } else {
   73: 	$Apache::lonxml::style_values=$Apache::lonxml::style_end_values;
   74: 	$Apache::lonxml::style_end_values='';
   75:     }
   76:     return ('','no');
   77: }
   78: 
   79: sub end_LONCAPA_INTERNAL_TURN_STYLE_OFF {
   80:     return ('','no');
   81: }
   82: 
   83: sub start_LONCAPA_INTERNAL_LONHTTPD_PORT {
   84:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   85:     if ($target eq 'web') {
   86: 	my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
   87: 	if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
   88: 	return '<script type="text/javascript">var lonhttpdport=\''.
   89: 	    $lonhttpdPort.'\';</script>';
   90:     }
   91:     return ('','no');
   92: }
   93: 
   94: sub end_LONCAPA_INTERNAL_LONHTTPD_PORT {
   95:     return ('','no');
   96: }
   97: 
   98: sub start_script {
   99:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  100:   @Apache::scripttag::parser_env = @_;
  101:   my $result='';
  102:   my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);
  103:   &Apache::lonxml::debug("found type of $type");
  104:   if ($type eq "loncapa/perl") {
  105:     if ( $target eq "modified" ) {
  106: 	$result=$token->[4].&Apache::edit::modifiedfield('/script',$parser);
  107:     } elsif ( $target eq 'web' || $target eq 'tex' ||
  108: 	      $target eq 'grade' || $target eq 'answer' ||
  109: 	      $target eq 'analyze' ) {
  110: 	my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
  111: 	if (!$Apache::lonxml::default_homework_loaded) {
  112: 	    &Apache::lonxml::default_homework_load($safeeval);
  113: 	}
  114: 	&Apache::run::run($bodytext,$safeeval);
  115: 	if (($target eq 'answer') &&
  116: 	    ($ENV{'form.answer_output_mode'} ne 'tex') &&
  117: 	    ($Apache::lonhomework::viewgrades == 'F')) {
  118: 	    $Apache::lonxml::evaluate--;
  119: 	    my (undef,undef,$udom,$uname)=&Apache::lonxml::whichuser();
  120: 	    my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
  121: 	    $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_".$uname."_".$udom."_"."$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";
  122: 	    my $listing=&Apache::run::dump($target,$safeeval);
  123: 	    $listing=~s/\'/\\\'/g;
  124: 	    $listing=~s/\n/\\n/g;
  125: 	    $listing=~s/\r/\\r/g;
  126: 	    $result.=$listing;
  127: 	    $result.= "</pre></body></html>');newWindow.document.close();}</script><a href=\"javascript:LONCAPA_scriptvars_".$uname."_".$udom."_$Apache::lonxml::curdepth();void(0);\">Script Vars</a><br />";
  128: 	}
  129:     } elsif ($target eq "edit" ) {
  130:       #&Apache::run::run($bodytext,$safeeval);
  131:       #$result="<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
  132: 	my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
  133: 	$result=&Apache::edit::tag_start($target,$token,'Script');
  134: 	$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
  135:     } elsif ($target eq 'meta') {
  136: 	my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
  137:     }
  138:   } else {
  139:       my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
  140:       if ($target ne "meta" && $target ne 'tex') {
  141: 	  $result = $token->[4];
  142: 	  $result.=$bodytext;
  143:       }
  144:   }
  145:   return $result;
  146: }
  147: 
  148: sub end_script {
  149:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  150:   if ( $target eq "meta" ) { return ''; } 
  151:   my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval);
  152:   my $result='';
  153:   #other script blocks need to survive
  154:   if ($type ne "loncapa/perl" && $target ne 'tex') {
  155:     return $token->[2];
  156:   } elsif ($target eq 'edit' ) {
  157:     return &Apache::edit::end_table();
  158:   } elsif ($target eq 'answer') {
  159:     $Apache::lonxml::evaluate++;
  160:   }
  161:   return '';
  162: }
  163: 
  164: sub start_display {
  165:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  166:   @Apache::scripttag::parser_env = @_;
  167:   my $result;
  168: 
  169:   if ( $target eq "modified" ) {
  170:       $result=$token->[4].&Apache::edit::modifiedfield("/display",$parser);
  171:   } elsif ( $target eq 'web' || $target eq 'tex' ||
  172: 	    $target eq 'grade' || $target eq 'answer' ||
  173: 	      $target eq 'analyze') {
  174:       my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
  175:       if (!$Apache::lonxml::default_homework_loaded) {
  176: 	  &Apache::lonxml::default_homework_load($safeeval);
  177:       }
  178:       $result=&Apache::run::run($bodytext,$safeeval);
  179:       if ($target eq 'grade' || $target eq 'answer' ||
  180: 	  $target eq 'analyze') {
  181: 	  # grade/answer/analyxe should produce no output but if we
  182: 	  # are redirecting, the redirecter should know what to do
  183: 	  # with the output
  184: 	  if (!$Apache::lonxml::redirection) { $result=''; }
  185:       }
  186:       $Apache::lonxml::post_evaluate=0;
  187:   } elsif ($target eq "edit" ) {
  188:     my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
  189:     #$result = 
  190:     #  "<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
  191:     #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
  192:     $result=&Apache::edit::tag_start($target,$token,'Script With Display');
  193:     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)
  194:   } elsif ($target eq 'meta') {
  195:       my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
  196:   }
  197:   return $result;
  198: }
  199: 
  200: sub end_display {
  201:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  202:   if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
  203:   return '';
  204: }
  205: 
  206: sub start_scriptlib {
  207:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  208:   my $bodytext;
  209:   my $result ='';
  210:   my $error='';
  211: 
  212:   if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
  213:       $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
  214:       $target eq 'analyze') {
  215:     $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
  216:     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
  217: 				     $$parstack[$#$parstack]);
  218:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
  219: 					       $bodytext);
  220:     my $script=&Apache::lonnet::getfile($location);
  221:     if ($script == -1) {
  222:       if ($target eq 'edit') {
  223:         $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
  224:       } else {
  225: 	&Apache::lonxml::error("<b> Unable to find <i>$location</i> for scriptlib</b>");
  226: 	return "";
  227:       }
  228:     }
  229:     &Apache::run::run($script,$safeeval);
  230:     #&Apache::lonxml::debug("ran $bodytext:<br />".&Apache::lonnet::getfile($bodytext)."<br />");
  231:   }
  232:   if ($target eq "edit" ) {
  233:     $result=
  234:       &Apache::edit::tag_start($target,$token,'New Script Functions').
  235: 	&Apache::edit::editline($token->[1],$bodytext,'scriptlib',40).
  236:             &Apache::edit::browse(undef,'textnode').
  237: 	  $error.'</td></tr>'.
  238: 	    &Apache::edit::end_table();
  239:   }
  240:   if ($target eq "modified" ) {
  241:       $result=$token->[4].&Apache::edit::modifiedfield("/scriptlib",$parser);
  242:   }
  243:   return $result;
  244: }
  245: 
  246: sub end_scriptlib {
  247:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  248:   my @result;
  249:   if ($target eq "edit" ) { $result[1]='no'; }
  250:   return @result;
  251: }
  252: 
  253: sub start_parserlib {
  254:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  255:   my $bodytext;
  256:   my $result ="";
  257:   my $error='';
  258:   if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
  259:       $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
  260:       $target eq 'analyze') {
  261:     $bodytext=$$parser[$#$parser]->get_text("/parserlib");
  262:     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
  263: 				     $$parstack[$#$parstack]);
  264:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
  265: 					       $bodytext);
  266:     my $styletext=&Apache::lonnet::getfile($location);
  267:     #&Apache::lonxml::debug("found :$bodytext: in :$location: with :$styletext:");
  268:     if ($styletext == -1) {
  269:       if ($target eq 'edit') {
  270: 	$error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
  271:       } else {
  272: 	&Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>");
  273: 	return "";
  274:       }
  275:     }
  276:     %$style = ( %$style , &Apache::style::styleparser($target,$styletext));
  277:   }
  278:   if ($target eq "edit" ) {
  279:     $result=
  280:       &Apache::edit::tag_start($target,$token,'New Tag Definitions').
  281: 	&Apache::edit::editline($token->[1],$bodytext,'',40).
  282: 	  $error.'</td></tr>'.
  283: 	    &Apache::edit::end_table();
  284:   }
  285:   if ($target eq "modified" ) {
  286:       $result=$token->[4].&Apache::edit::modifiedfield("/parserlib",$parser);
  287:   }
  288:   return $result;
  289: }
  290: 
  291: sub end_parserlib {
  292:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  293:   my @result;
  294:   if ($target eq "edit" ) { $result[1]='no'; }
  295:   return @result;
  296: }
  297: 
  298: sub start_window {
  299:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  300:     my $result = '';
  301:     if ($target eq 'web') {
  302: 	&Apache::lonxml::startredirection;
  303:     } elsif ($target eq 'tex') {
  304: 	$result = '\unskip\footnote{';
  305:     } elsif ($target eq 'edit') {
  306: 	$result.=&Apache::edit::tag_start($target,$token);
  307: 	$result.=&Apache::edit::text_arg('Text of Link:','linktext',$token,70);
  308: 	$result.=&Apache::edit::text_arg('Height:','width',$token,5);
  309: 	$result.=&Apache::edit::text_arg('Width:','height',$token,5);
  310: 	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  311:     } elsif ($target eq 'modified') {
  312: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  313: 						     $safeeval,'linttext',
  314: 						     'width','height');
  315: 	if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
  316:     }
  317:     return $result;  
  318: }
  319: 
  320: sub end_window {
  321:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  322:   my $result;
  323:   if ($target eq 'web') {
  324:     my $output=&Apache::lonxml::endredirection;
  325:     $output =~ s/[\n\r]/ /g;
  326: #    $output = &HTML::Entities::encode($output,'<>&"\'');
  327:     $output =~ s/\'/\\\'/g;
  328:     my $linktext= &Apache::lonxml::get_param('linktext',$parstack,$safeeval);
  329:     if (!$linktext) { $linktext='<sup>*</sup>'; }
  330:     my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval);
  331:     if (!$width) { $width='500'; }
  332:     my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
  333:     if (!$height) { $height='200'; }
  334:     $result = "<script type=\"text/javascript\"> function LONCAPA_newwindow_$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=$width,height=$height,scrollbars=1');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>newwindow</title></head><body bgcolor=\"#FFFFFF\"> $output </body></html>');newWindow.document.close();}</script><a href=\"javascript:LONCAPA_newwindow_$Apache::lonxml::curdepth();void(0);\">$linktext</a>";
  335:   } elsif ($target eq 'tex') {
  336:       $result = '}';
  337:   } else {
  338:       $result = '';
  339:   }
  340:   return $result; 
  341: }
  342: 
  343: sub start_import {
  344:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  345:   my $bodytext=$$parser[$#$parser]->get_text("/import");
  346:   my $result ="";
  347: 
  348:   $bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]);
  349: 
  350:   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  351:       $target eq 'tex' || $target eq 'analyze' ) {
  352:     # FIXME this probably needs to be smart about construction vs.
  353:     # non construction space.
  354:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
  355:     my $file=&Apache::lonnet::getfile($location);
  356:     if ($file == -1) {
  357:       &Apache::lonxml::error("<b> Unable to find <i>$bodytext as $location</i> for import</b>");
  358:       return "";
  359:     }
  360: 
  361:     my $dir=$location;
  362:     $dir=~s:/[^/]*$::;
  363:     #  &Apache::lonxml::debug("directory $dir $location file $file \n<b>END</b>\n");
  364:     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
  365:     if (!$id) { $id=$Apache::lonxml::curdepth; }
  366:     push(@Apache::inputtags::import,$id);
  367:     push(@Apache::inputtags::importlist,$id);
  368: 
  369: 	&Apache::lonxml::newparser($parser,\$file,$dir);
  370: 
  371:   } elsif ($target eq "edit" ) {
  372:     $result.=&Apache::edit::tag_start($target,$token);
  373:     $result.=&Apache::edit::editline($token->[1],$bodytext,'',40);
  374:     $result.=&Apache::edit::browse(undef,'textnode');
  375:     #FIXME this need to convert $bodytext to be a contruction space reference
  376:     #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
  377:     #$result.="Click<a href=\"$location\">here</a> to edit<br />"
  378:   } elsif ($target eq 'modified') {
  379:       $result=$token->[4].&Apache::edit::modifiedfield("/import",$parser);
  380:   } elsif ($target eq 'meta') {
  381:     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
  382:     $result.='<import part="'.$Apache::inputtags::part;
  383:     if ($id) {
  384:       $result.='" id="'.$id;
  385:     }
  386:     $result.='">';
  387:     $result.=$bodytext;
  388:     $result.='</import>';
  389:   }
  390:   return $result;
  391: }
  392: 
  393: sub end_import {
  394:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  395:   pop(@Apache::inputtags::import);
  396:   my $result;
  397:   if ($target eq 'edit' ) { $result=&Apache::edit::end_table(); }
  398:   return $result;
  399: }
  400: 
  401: sub start_storetc {
  402:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  403:   my $result = '';
  404:   &Apache::lonxml::startredirection;
  405:   return $result; 
  406: }
  407: 
  408: sub end_storetc {
  409:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  410:     my $result;
  411:     my $output=&Apache::lonxml::endredirection;
  412:     $output =~ s/\"/\&quot\;/g;
  413:     $result = '{\bf '.$output.'.}}\write\tcfile{\protect\tcpc{ '.$output.'.}{\the\value{relpage}}}';
  414:     return $result;
  415: }
  416: 
  417: 
  418: sub start_physnet {
  419:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  420:     my $bodytext = '/adm/includes/physnet.sty';
  421:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
  422:     my $cbistyletext=&Apache::lonnet::getfile($location);
  423: 
  424:     %$style = (%$style,&Apache::style::styleparser($target,$cbistyletext));
  425:     $$parser['-1']->unget_token($token);
  426: #    if ( defined($$style{'physnet'}) ) {
  427: #        &Apache::lonxml::newparser($parser,\$$style{'physnet'});
  428: #    }
  429:     return "";
  430: }
  431: 
  432: sub end_physnet {
  433:   return '';
  434: }
  435: 
  436: sub start_standalone {
  437:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  438:   my $result='';
  439:   if ($target eq 'web' ) {
  440:     if ( $ENV{'request.course.id'} ) {
  441:       my $inside = &Apache::lonxml::get_all_text("/standalone",$parser);
  442:     } else {
  443:       $result='<table bgcolor="#E1E1E1" border="2"><tr><td>';
  444:     }
  445:   }
  446:   return $result;
  447: }
  448: 
  449: sub end_standalone {
  450:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  451:   my $result='';
  452:   if ($target eq 'web' ) {
  453:     if ( $ENV{'request.course.id'} ) {
  454:     } else {
  455:       $result='</td></tr></table>';
  456:     }
  457:   }
  458:   return $result;
  459: }
  460: 
  461: sub start_comment {
  462:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  463:   my $result='';
  464:   if ($target eq 'edit') {
  465:     $result=&Apache::edit::tag_start($target,$token);
  466:     my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
  467:     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)
  468:   } elsif ( $target eq 'modified') {
  469:     $result=$token->[4].&Apache::edit::modifiedfield("/comment",$parser);
  470:   } elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
  471: 	    $target eq 'answer' || $target eq 'meta' || $target eq 'analyze') {
  472:     #normally throw away comments
  473:     my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
  474:   }
  475:   return $result;
  476: }
  477: 
  478: sub end_comment {
  479:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  480:   if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
  481:   return '';
  482: }
  483: 
  484: 
  485: sub xmlparse {
  486:   my ($string) = @_;
  487:   &Apache::lonxml::debug("xmlparse recursion starting with $string");
  488:   # Apache::run::evaluate does an 'eval' on the name of the subroutine
  489:   # if it detects something that looks like a subroutine, this ends up calling
  490:   # things without any arguments and since perl is nice enough to pass
  491:   # along the default arguments when you don't explicitly say no arguments
  492:   # if you call &xmlparse, it gets &xmlparse passed as it argument.
  493:   # Same thing soccurs with &chemparse.
  494:   if ($string eq '&xmlparse') { return '&xmlparse'; }
  495:   if ($string eq '&chemparse') { return '&chemparse'; }
  496:   my ($target,$token,$tagstack,$parstack,$oldparser,$safeeval,$style)=
  497:     @Apache::scripttag::parser_env;
  498:   my @parser;
  499:   &Apache::lonxml::newparser(\@parser,\$string);
  500:   my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,
  501: 					     $parstack,\@parser,
  502: 					     $safeeval,$style);
  503:   &Apache::lonxml::debug("xmlparse recursion ending with $result");
  504:   return $result;
  505: }
  506: 
  507: 1;
  508: __END__

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