Annotation of loncom/xml/scripttag.pm, revision 1.175

1.1       albertel    1: # The LearningOnline Network with CAPA
                      2: # <script> definiton
1.58      www         3: #
1.175   ! raeburn     4: # $Id: scripttag.pm,v 1.174 2015/04/06 16:27:12 raeburn Exp $
1.58      www         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: #
1.116     www        28: 
1.47      albertel   29: package Apache::scripttag;
1.1       albertel   30: 
                     31: use strict;
1.3       albertel   32: use Apache::lonnet;
1.145     albertel   33: use Apache::lonlocal;
1.167     raeburn    34: use Apache::lonxml();
                     35: use Apache::londefdef();
1.145     albertel   36: use Apache::style();
1.1       albertel   37: 
1.47      albertel   38: #Globals
                     39: # this used to pass around the standard callsub arguments to a tag func
                     40: # so xmlparse can reenter the inner_xmlparse loop.
                     41: 
                     42: @Apache::scripttag::parser_env = ();
1.61      harris41   43: BEGIN {
1.62      albertel   44:   &Apache::lonxml::register('Apache::scripttag',
                     45: 			    ('script','scriptlib','parserlib','import',
1.163     www        46: 			     'window','windowlink','togglebox','display','storetc','physnet',
1.123     albertel   47: 			     'standalone','comment','num','parse','algebra',
1.86      albertel   48: 			     'LONCAPA_INTERNAL_TURN_STYLE_ON',
1.150     raeburn    49: 			     'LONCAPA_INTERNAL_TURN_STYLE_OFF'));
1.81      albertel   50: }
                     51: 
                     52: sub start_LONCAPA_INTERNAL_TURN_STYLE_ON {
                     53:     $Apache::lonxml::usestyle=1;
1.89      albertel   54:     $Apache::lonxml::style_values='';
1.81      albertel   55:     return ('','no');
                     56: }
                     57: 
                     58: sub end_LONCAPA_INTERNAL_TURN_STYLE_ON {
1.91      albertel   59:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     60:     my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
                     61:     if (defined($end)) {
                     62: 	&Apache::lonxml::end_tag($tagstack,$parstack,$token);
                     63:     }
1.100     albertel   64:     return ('','no');
                     65: }
                     66: 
                     67: sub start_LONCAPA_INTERNAL_TURN_STYLE_OFF {
                     68:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     69:     $Apache::lonxml::usestyle=0;
                     70:     my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
                     71:     if (!$end) {
                     72: 	$Apache::lonxml::style_values=$$parstack[-1];
                     73: 	$Apache::lonxml::style_end_values=$$parstack[-1];
                     74:     } else {
                     75: 	$Apache::lonxml::style_values=$Apache::lonxml::style_end_values;
                     76: 	$Apache::lonxml::style_end_values='';
                     77:     }
                     78:     return ('','no');
                     79: }
                     80: 
                     81: sub end_LONCAPA_INTERNAL_TURN_STYLE_OFF {
1.86      albertel   82:     return ('','no');
                     83: }
                     84: 
1.1       albertel   85: sub start_script {
1.40      albertel   86:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.47      albertel   87:   @Apache::scripttag::parser_env = @_;
1.24      albertel   88:   my $result='';
1.39      albertel   89:   my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);
                     90:   &Apache::lonxml::debug("found type of $type");
1.17      albertel   91:   if ($type eq "loncapa/perl") {
                     92:     if ( $target eq "modified" ) {
1.103     albertel   93: 	$result=$token->[4].&Apache::edit::modifiedfield('/script',$parser);
1.54      albertel   94:     } elsif ( $target eq 'web' || $target eq 'tex' ||
1.130     albertel   95: 	      $target eq 'grade' || $target eq 'webgrade' ||
                     96: 	      $target eq 'answer' || $target eq 'analyze' ) {
1.107     albertel   97: 	my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
1.79      albertel   98: 	if (!$Apache::lonxml::default_homework_loaded) {
                     99: 	    &Apache::lonxml::default_homework_load($safeeval);
                    100: 	}
                    101: 	&Apache::run::run($bodytext,$safeeval);
1.88      albertel  102: 	if (($target eq 'answer') &&
1.126     albertel  103: 	    ($env{'form.answer_output_mode'} ne 'tex') &&
1.88      albertel  104: 	    ($Apache::lonhomework::viewgrades == 'F')) {
1.79      albertel  105: 	    $Apache::lonxml::evaluate--;
1.138     albertel  106: 	    my (undef,undef,$udom,$uname)=&Apache::lonnet::whichuser();
1.140     albertel  107: 	    $uname =~s/\W//g;
                    108: 	    $udom  =~s/\W//g;
1.145     albertel  109: 	    my $function_name = 
                    110: 		join('_','LONCAPA_scriptvars',$uname,$udom,
                    111: 		     $env{'form.counter'},$Apache::lonxml::curdepth);
1.158     www       112:             &Apache::lonxml::add_script_result(
1.159     www       113: 	             &Apache::loncommon::modal_adhoc_window($function_name,500,500,
1.166     raeburn   114:                             '<pre style="background-color:#ffffff;">'.
                    115:                             &Apache::run::dump($target,$safeeval).'</pre>',
1.159     www       116:                             &mt('Script Vars'))."<br />");
1.79      albertel  117: 	}
1.28      albertel  118:     } elsif ($target eq "edit" ) {
1.41      albertel  119:       #&Apache::run::run($bodytext,$safeeval);
                    120:       #$result="<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
1.173     golterma  121:     	my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
                    122:     	$result=&Apache::edit::tag_start($target,$token,'Script');
                    123: 
                    124:         my $depth = $Apache::lonxml::curdepth;
                    125:         $result.='<span id="LC_edit_problem_codemirror">';
                    126:         unless ($env{'environment.nocodemirror'}) {
                    127:             # only show button if codemirror activated
                    128:             $result.='<input type="button" id="fitsize'.$depth.'" value="'.&mt("Dynamic size").
                    129:             '" onclick="autosize(\''.$depth.'\')" />';
                    130:         }
                    131:         $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4).'</span>';
                    132: 
                    133:         unless ($env{'environment.nocodemirror'}) {
                    134:             $result.='<script type="text/javascript">
                    135:                 var cm'.$depth.' = CodeMirror.fromTextArea(document.getElementById("homework_edit_'.$depth.'"),
                    136:                 {
                    137:                     mode: "perl",
                    138:                     lineWrapping: true,
                    139:                     lineNumbers: true,
                    140:                     tabSize: 4,
                    141:                     indentUnit: 4,
                    142:                     autoCloseBrackets: true,
                    143:                     styleActiveLine: true,
                    144:                     
                    145:                     extraKeys: {
                    146:                         "Tab": "indentMore",
                    147:                         "Shift-Tab": "indentLess"
                    148:                     }
                    149:                 });
                    150:                 if(sessionStorage.getItem("autosized_'.$depth.'") != null) {
                    151:                     document.getElementById("fitsize'.$depth.'").value = "'.&mt("Fixed size").'";
                    152:                     cm'.$depth.'.setSize("","auto");
                    153:                 }
                    154:             </script>';
                    155:         }
                    156:                 
                    157: 
1.107     albertel  158:     } elsif ($target eq 'meta') {
                    159: 	my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
1.17      albertel  160:     }
                    161:   } else {
1.108     matthew   162:       my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
1.144     albertel  163:       if ($target ne "meta" && $target ne 'tex' && $target ne 'answer') {
1.112     albertel  164: 	  $result = $token->[4];
                    165: 	  $result.=$bodytext;
1.168     raeburn   166:           my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
                    167:           my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
                    168:           my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                    169:           my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                    170:           if ($src ne '') {
                    171:               if ($src !~ m{^(/|https?://)}) {
                    172:                   my $cleanhref = &Apache::londefdef::clean_docs_httpref($src,$url,$cdom,$cnum);
                    173:                   if ($cleanhref) {
                    174:                       &Apache::lonxml::extlink($cleanhref);
1.167     raeburn   175:                   }
1.168     raeburn   176:               }
                    177:           } elsif (($type eq 'text/javascript') && ($bodytext ne '')) {
1.172     raeburn   178:               if ($url =~ m{^\Q/uploaded/$cdom/$cnum/\E(docs|supplemental)/}) {
1.171     raeburn   179:                   if ($bodytext =~ m{\.addMediaSrc\((["'])((?!\1).)+\1\);}) {
1.170     raeburn   180:                       my $quote = $1;
                    181:                       if ($bodytext =~ m{\Q.addMediaSrc($quote\E([^$quote]+)\Q$quote)\E}) {
                    182:                           my $fname = $1;
                    183:                           my $cleanhref =
                    184:                               &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum);
                    185:                           if ($cleanhref) {
                    186:                               &Apache::lonxml::extlink($cleanhref);
                    187:                           }
                    188:                       }
                    189:                   }
1.168     raeburn   190:                   if ($bodytext =~ m{\.set\w+(Src|Swf)\(["']}i) {
                    191:                       my @srcs = split(/\.set/,$bodytext);
                    192:                       if (scalar(@srcs) > 1) {
                    193:                           foreach my $item (@srcs) {
                    194:                               if ($item =~ m{^(FlashPlayerSwf|MediaSrc|XMPSrc|ConfigurationSrc|PosterImageSrc)\((['"])(?:(?!\2).)+\2\)}is) {
                    195:                                   my $srctype = $1;
                    196:                                   my $quote = $2;
                    197:                                   my ($fname) = ($item =~ m{^\Q$srctype($quote\E([^$quote]+)\Q$quote)\E}); 
1.169     raeburn   198:                                   my $cleanhref =
                    199:                                       &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum);
1.168     raeburn   200:                                   if ($cleanhref) {
                    201:                                       &Apache::lonxml::extlink($cleanhref);
1.169     raeburn   202:                                       if ($srctype eq 'ConfigurationSrc') {
                    203:                                           if ($cleanhref =~ m{^(.+/)configuration_express\.xml$}) {
                    204: #
                    205: # Camtasia 8.1: express_show/spritesheet.png needed, and included in zip archive.
                    206: # Not referenced directly in <main>.html or <main>_player.html files,
                    207: # so call lonxml::extlink() here to include httpref for the uploaded file.
                    208: # (where <main> is name user gave to file/archive).
                    209: #
                    210: 
                    211:                                               my $spritesheet = $1.'express_show/spritesheet.png';
                    212:                                               if (&Apache::lonnet::repcopy_userfile($spritesheet) eq 'ok') {
                    213:                                                   &Apache::lonxml::extlink($spritesheet);
                    214:                                               }
                    215:                                           }
1.170     raeburn   216: #
                    217: # Camtasia 8.4: express_show/spritesheet.min.css needed, and included in zip archive.
                    218: # Not referenced directly in <main>.html or <main>_player.html files,
                    219: # so call lonxml::extlink() here to include httpref for the uploaded file.
                    220: # (where <main> is name user gave to file/archive).
                    221: #
                    222:                                           my $spritesheet_css = $1.'express_show/spritesheet.min.css';
                    223:                                           if (&Apache::lonnet::repcopy_userfile($spritesheet_css) eq 'ok') {
                    224:                                               &Apache::lonxml::extlink($spritesheet_css);
                    225:                                           }
1.169     raeburn   226:                                       } elsif ($srctype eq 'PosterImageSrc') {
                    227:                                           if ($fname =~ m{^(.+)_First_Frame\.png$}) {
                    228:                                               my $prefix = $1;
                    229:                                               my ($path) = ($cleanhref =~ m{^(.+/)\Q$fname\E});
                    230: #
                    231: # Camtasia 8.1: <main>_Thumbnails.png needed, and included in zip archive.
                    232: # Not referenced directly in <main>.html or <main>_player.html files,
                    233: # so call lonxml::extlink() here to include httpref for the uploaded file
                    234: # (where <main> is name user gave to file/archive).
                    235: #
                    236:                                               my $thumbnail = $path.$prefix.'_Thumbnails.png';
                    237:                                               if (&Apache::lonnet::repcopy_userfile($thumbnail) eq 'ok') {
                    238:                                                   &Apache::lonxml::extlink($thumbnail);
                    239:                                               }
                    240:                                           }
                    241:                                       }
1.167     raeburn   242:                                   }
                    243:                               }
1.165     raeburn   244:                           }
                    245:                       }
                    246:                   }
1.170     raeburn   247:                   if ($bodytext =~ /\(document,\s*(['"])script\1,\s*\[([^\]]+)\]\);/s) {
                    248:                       my $scriptslist = $2;
                    249:                       my @srcs = split(/\s*,\s*/,$scriptslist);
                    250:                       foreach my $src (@srcs) {
                    251:                           if ($src =~ /(["'])(?:(?!\1).)+\.js\1/) {
                    252:                               my $quote = $1;
                    253:                               my ($fname) = ($src =~ m/\Q$quote\E([^$quote]+)\Q$quote\E/);
                    254:                               my $cleanhref =
                    255:                                   &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum);
                    256:                               if ($cleanhref) {
                    257:                                   &Apache::lonxml::extlink($cleanhref);
                    258:                               }
                    259:                           }
                    260:                       }
                    261:                   }
1.171     raeburn   262:                   if ($bodytext =~ m{loadScript\(\s*(['"])((?:(?!\1).)+\.js)\1,\s*function}is) {
                    263:                       my $fname = $2;
                    264:                       if ($fname) {
                    265:                           my $cleanhref =
                    266:                               &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum);
                    267:                           if ($cleanhref) {
                    268:                               &Apache::lonxml::extlink($cleanhref);
                    269:                           }
                    270:                       }
                    271:                   }
1.165     raeburn   272:               }
                    273:           }
1.112     albertel  274:       }
1.13      albertel  275:   }
1.24      albertel  276:   return $result;
1.17      albertel  277: }
1.13      albertel  278: 
1.17      albertel  279: sub end_script {
1.40      albertel  280:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.28      albertel  281:   if ( $target eq "meta" ) { return ''; } 
1.39      albertel  282:   my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval);
1.29      albertel  283:   my $result='';
                    284:   #other script blocks need to survive
1.115     albertel  285:   if ($type ne "loncapa/perl" && $target ne 'tex') {
1.53      albertel  286:     return $token->[2];
                    287:   } elsif ($target eq 'edit' ) {
                    288:     return &Apache::edit::end_table();
1.78      albertel  289:   } elsif ($target eq 'answer') {
1.53      albertel  290:     $Apache::lonxml::evaluate++;
                    291:   }
1.28      albertel  292:   return '';
1.24      albertel  293: }
                    294: 
                    295: sub start_display {
1.40      albertel  296:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.119     albertel  297:   @Apache::scripttag::parser_env = @_;
1.48      albertel  298:   my $result;
1.39      albertel  299: 
1.24      albertel  300:   if ( $target eq "modified" ) {
1.103     albertel  301:       $result=$token->[4].&Apache::edit::modifiedfield("/display",$parser);
1.54      albertel  302:   } elsif ( $target eq 'web' || $target eq 'tex' ||
1.130     albertel  303: 	    $target eq 'grade' || $target eq 'webgrade' ||
                    304: 	    $target eq 'answer' || $target eq 'analyze') {
1.107     albertel  305:       my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
1.80      albertel  306:       if (!$Apache::lonxml::default_homework_loaded) {
                    307: 	  &Apache::lonxml::default_homework_load($safeeval);
                    308:       }
                    309:       $result=&Apache::run::run($bodytext,$safeeval);
                    310:       if ($target eq 'grade' || $target eq 'answer' ||
                    311: 	  $target eq 'analyze') {
1.114     albertel  312: 	  # grade/answer/analyxe should produce no output but if we
                    313: 	  # are redirecting, the redirecter should know what to do
                    314: 	  # with the output
                    315: 	  if (!$Apache::lonxml::redirection) { $result=''; }
1.80      albertel  316:       }
1.101     albertel  317:       $Apache::lonxml::post_evaluate=0;
1.48      albertel  318:   } elsif ($target eq "edit" ) {
1.110     albertel  319:     my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
1.48      albertel  320:     #$result = 
                    321:     #  "<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
                    322:     #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
                    323:     $result=&Apache::edit::tag_start($target,$token,'Script With Display');
1.77      albertel  324:     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)
1.107     albertel  325:   } elsif ($target eq 'meta') {
                    326:       my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
1.24      albertel  327:   }
                    328:   return $result;
                    329: }
                    330: 
                    331: sub end_display {
1.48      albertel  332:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    333:   if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
                    334:   return '';
1.1       albertel  335: }
1.3       albertel  336: 
                    337: sub start_scriptlib {
1.40      albertel  338:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.37      albertel  339:   my $bodytext;
                    340:   my $result ='';
                    341:   my $error='';
                    342: 
1.106     albertel  343:   if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
                    344:       $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
1.137     albertel  345:       $target eq 'analyze' || $target eq 'webgrade') {
1.37      albertel  346:     $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
                    347:     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
                    348: 				     $$parstack[$#$parstack]);
                    349:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
                    350: 					       $bodytext);
                    351:     my $script=&Apache::lonnet::getfile($location);
                    352:     if ($script == -1) {
                    353:       if ($target eq 'edit') {
1.145     albertel  354:         $error='</tr><tr><td>'.&mt('Errors').'</td><td colspan="2"><b>'.&mt(' Unable to find [_1]','<span class="LC_filename">'.$location.'</span>').'</b></td>'."\n";
1.37      albertel  355:       } else {
                    356: 	&Apache::lonxml::error("<b> Unable to find <i>$location</i> for scriptlib</b>");
                    357: 	return "";
                    358:       }
                    359:     }
                    360:     &Apache::run::run($script,$safeeval);
                    361:     #&Apache::lonxml::debug("ran $bodytext:<br />".&Apache::lonnet::getfile($bodytext)."<br />");
1.18      albertel  362:   }
1.13      albertel  363:   if ($target eq "edit" ) {
1.37      albertel  364:     $result=
1.49      albertel  365:       &Apache::edit::tag_start($target,$token,'New Script Functions').
1.83      matthew   366: 	&Apache::edit::editline($token->[1],$bodytext,'scriptlib',40).
1.175   ! raeburn   367:             &Apache::edit::browse_or_search(undef,'textnode').
1.49      albertel  368: 	  $error.'</td></tr>'.
                    369: 	    &Apache::edit::end_table();
1.37      albertel  370:   }
                    371:   if ($target eq "modified" ) {
1.103     albertel  372:       $result=$token->[4].&Apache::edit::modifiedfield("/scriptlib",$parser);
1.3       albertel  373:   }
                    374:   return $result;
                    375: }
                    376: 
1.37      albertel  377: sub end_scriptlib {
1.40      albertel  378:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.49      albertel  379:   my @result;
                    380:   if ($target eq "edit" ) { $result[1]='no'; }
                    381:   return @result;
1.37      albertel  382: }
1.4       albertel  383: 
                    384: sub start_parserlib {
1.40      albertel  385:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.37      albertel  386:   my $bodytext;
1.7       albertel  387:   my $result ="";
1.37      albertel  388:   my $error='';
1.106     albertel  389:   if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
                    390:       $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
1.137     albertel  391:       $target eq 'analyze' || $target eq 'webgrade') {
1.37      albertel  392:     $bodytext=$$parser[$#$parser]->get_text("/parserlib");
                    393:     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
                    394: 				     $$parstack[$#$parstack]);
                    395:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
                    396: 					       $bodytext);
                    397:     my $styletext=&Apache::lonnet::getfile($location);
                    398:     #&Apache::lonxml::debug("found :$bodytext: in :$location: with :$styletext:");
                    399:     if ($styletext == -1) {
                    400:       if ($target eq 'edit') {
                    401: 	$error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
                    402:       } else {
                    403: 	&Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>");
                    404: 	return "";
                    405:       }
                    406:     }
                    407:     %$style = ( %$style , &Apache::style::styleparser($target,$styletext));
1.18      albertel  408:   }
1.13      albertel  409:   if ($target eq "edit" ) {
1.37      albertel  410:     $result=
1.49      albertel  411:       &Apache::edit::tag_start($target,$token,'New Tag Definitions').
1.68      albertel  412: 	&Apache::edit::editline($token->[1],$bodytext,'',40).
1.49      albertel  413: 	  $error.'</td></tr>'.
                    414: 	    &Apache::edit::end_table();
1.37      albertel  415:   }
                    416:   if ($target eq "modified" ) {
1.103     albertel  417:       $result=$token->[4].&Apache::edit::modifiedfield("/parserlib",$parser);
1.7       albertel  418:   }
                    419:   return $result;
1.4       albertel  420: }
                    421: 
                    422: sub end_parserlib {
1.40      albertel  423:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.49      albertel  424:   my @result;
                    425:   if ($target eq "edit" ) { $result[1]='no'; }
                    426:   return @result;
1.6       albertel  427: }
                    428: 
1.30      sakharuk  429: sub start_window {
1.105     albertel  430:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    431:     my $result = '';
1.137     albertel  432:     if ($target eq 'web' || $target eq 'webgrade') {
1.105     albertel  433: 	&Apache::lonxml::startredirection;
                    434:     } elsif ($target eq 'tex') {
1.164     www       435:         my $printtext=&Apache::lonxml::get_param('printtext',$parstack,$safeeval);
                    436:         if ($printtext=~/\w/) {
                    437: # If printtext is given, do not output any intervening information
                    438:            &Apache::lonxml::startredirection;
                    439:         } else {
                    440:            $result = '\unskip\footnote{';
                    441:         }
1.105     albertel  442:     } elsif ($target eq 'edit') {
                    443: 	$result.=&Apache::edit::tag_start($target,$token);
                    444: 	$result.=&Apache::edit::text_arg('Text of Link:','linktext',$token,70);
1.131     albertel  445: 	$result.=&Apache::edit::text_arg('Height:','height',$token,5);
                    446: 	$result.=&Apache::edit::text_arg('Width:','width',$token,5);
1.164     www       447:         $result.=&Apache::edit::text_arg('Printed text (optional):','printtext',$token,20);
1.105     albertel  448: 	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
                    449:     } elsif ($target eq 'modified') {
                    450: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1.129     raeburn   451: 						     $safeeval,'linktext',
1.161     www       452: 						     'width','height');
1.105     albertel  453: 	if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
                    454:     }
                    455:     return $result;  
1.19      sakharuk  456: }
                    457: 
1.30      sakharuk  458: sub end_window {
1.40      albertel  459:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.30      sakharuk  460:   my $result;
1.137     albertel  461:   if ($target eq 'web' || $target eq 'webgrade') {
1.34      albertel  462:     my $output=&Apache::lonxml::endredirection;
1.92      albertel  463:     my $linktext= &Apache::lonxml::get_param('linktext',$parstack,$safeeval);
                    464:     if (!$linktext) { $linktext='<sup>*</sup>'; }
                    465:     my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval);
                    466:     if (!$width) { $width='500'; }
                    467:     my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
                    468:     if (!$height) { $height='200'; }
1.160     www       469:     $result=&Apache::loncommon::modal_adhoc_window
                    470:            ("LONCAPA_newwindow_$Apache::lonxml::curdepth",$width,$height,$output,$linktext);
1.35      sakharuk  471:   } elsif ($target eq 'tex') {
1.164     www       472:       my $printtext=&Apache::lonxml::get_param('printtext',$parstack,$safeeval);
                    473:       if ($printtext=~/\w/) {
                    474: # If a "printtext" is given, proceed to retrieve all intervening information and trash it
                    475:          my $output=&Apache::lonxml::endredirection;
                    476: # Use printtext instead
                    477:          $result=$printtext;
                    478:       } else {
                    479:          $result='}';
                    480:       }
1.30      sakharuk  481:   } else {
1.35      sakharuk  482:       $result = '';
1.30      sakharuk  483:   }
1.20      sakharuk  484:   return $result; 
1.19      sakharuk  485: }
                    486: 
1.161     www       487: 
1.163     www       488: sub start_windowlink {
                    489:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    490:     my $result = '';
                    491:     if ($target eq 'web' || $target eq 'webgrade') {
                    492:         &Apache::lonxml::startredirection;
                    493:     } elsif ($target eq 'edit') {
                    494:         $result.=&Apache::edit::tag_start($target,$token);
                    495:         $result.=&Apache::edit::text_arg('Link:','href',$token,70);
                    496:         $result.=&Apache::edit::text_arg('Height:','height',$token,5);
                    497:         $result.=&Apache::edit::text_arg('Width:','width',$token,5);
                    498:         $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
                    499:     } elsif ($target eq 'modified') {
                    500:         my $constructtag=&Apache::edit::get_new_args($token,$parstack,
                    501:                                                      $safeeval,'href',
                    502:                                                      'width','height');
                    503:         if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
                    504:     }
                    505:     return $result;
                    506: }
                    507: 
                    508: sub end_windowlink {
                    509:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    510:   my $result;
                    511:   if ($target eq 'web' || $target eq 'webgrade') {
                    512:     my $output=&Apache::lonxml::endredirection;
                    513:     my $href= &Apache::lonxml::get_param('href',$parstack,$safeeval);
                    514:     if (!$href) { $href='/adm/rat/empty.html'; }
                    515:     my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval);
                    516:     if (!$width) { $width='500'; }
                    517:     my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
                    518:     if (!$height) { $height='200'; }
                    519:     $result=&Apache::loncommon::modal_link($href,$output,$width,$height);
                    520:   } else {
                    521:       $result = '';
                    522:   }
                    523:   return $result;
                    524: }
                    525: 
                    526: 
1.161     www       527: sub start_togglebox {
                    528:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    529:     my $result = '';
                    530:     if ($target eq 'web' || $target eq 'webgrade') {
                    531:         my $id="LONCAPA_togglebox_$Apache::lonxml::curdepth";
                    532:         my $heading=&Apache::lonxml::get_param('heading',$parstack,$safeeval);
                    533:         unless ($heading) { $heading=''; } else { $heading.=' '; }
                    534:         my $showtext=&Apache::lonxml::get_param('showtext',$parstack,$safeeval);
                    535:         my $hidetext=&Apache::lonxml::get_param('hidetext',$parstack,$safeeval);
                    536:         my $headerbg=&Apache::lonxml::get_param('headerbg',$parstack,$safeeval);
1.162     www       537:         $result=&Apache::loncommon::start_togglebox($id,$heading,$headerbg,$hidetext,$showtext);
1.161     www       538:     } elsif ($target eq 'tex') {
                    539:         my $heading=&Apache::lonxml::get_param('heading',$parstack,$safeeval);
                    540:         unless ($heading) { $heading=''; } else { $heading.=' '; }
                    541:         $result = "\n\n".'\fbox{{\bf '.$heading.'} \qquad '."\n";
                    542:     } elsif ($target eq 'edit') {
                    543:         $result.=&Apache::edit::tag_start($target,$token);
                    544:         $result.=&Apache::edit::text_arg('Heading:','heading',$token,70);
                    545:         $result.=&Apache::edit::text_arg('Header Background:','headerbg',$token,7);
                    546:         $result.=&Apache::edit::text_arg('Show text:','showtext',$token,10);
                    547:         $result.=&Apache::edit::text_arg('Hide text:','hidetext',$token,10);
                    548:         $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
                    549:     } elsif ($target eq 'modified') {
                    550:         my $constructtag=&Apache::edit::get_new_args($token,$parstack,
                    551:                                                      $safeeval,'heading',
                    552:                                                      'showtext','hidetext',
                    553:                                                      'headerbg','textbg');
                    554:         if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
                    555:     }
                    556:     return $result;
                    557: }
                    558: 
                    559: sub end_togglebox {
                    560:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    561:   my $result;
                    562:   if ($target eq 'web' || $target eq 'webgrade') {
1.162     www       563:     $result=&Apache::loncommon::end_togglebox();
1.161     www       564:   } elsif ($target eq 'tex') {
                    565:       $result = "}\n\n";
                    566:   } else {
                    567:       $result = '';
                    568:   }
                    569:   return $result;
                    570: }
                    571: 
                    572: 
                    573: 
1.6       albertel  574: sub start_import {
1.40      albertel  575:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.31      albertel  576:   my $bodytext=$$parser[$#$parser]->get_text("/import");
1.7       albertel  577:   my $result ="";
1.13      albertel  578: 
1.153     www       579:   $bodytext=&Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]);
1.14      albertel  580: 
1.135     albertel  581:   if ($target eq 'web' ||  $target eq 'webgrade' || $target eq 'grade' 
                    582:       || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze' ) {
1.46      albertel  583:     # FIXME this probably needs to be smart about construction vs.
                    584:     # non construction space.
                    585:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
                    586:     my $file=&Apache::lonnet::getfile($location);
                    587:     if ($file == -1) {
                    588:       &Apache::lonxml::error("<b> Unable to find <i>$bodytext as $location</i> for import</b>");
                    589:       return "";
                    590:     }
1.153     www       591:     my $importmode=&Apache::lonxml::get_param('importmode',$parstack,$safeeval);
1.154     www       592:     if (($importmode eq 'problem') || ($importmode eq 'part')) {
                    593: # We are using import to import published problems
                    594:        if (($importmode eq 'problem') || ($file=~/<part[^<]*>/s)) {
                    595: # We explicitly don't want this to be a separate part or the problem already has parts
                    596:           $file=~s/^\s*<problem>/<library>/s;
                    597: 	  $file=~s/<\/problem>\s*$/<\/library>/s;
                    598:        } else {
                    599: # We want this to be a separate part, but it currently is not
1.155     www       600:           $file=~s/^\s*<problem>/<library><part>/s;
1.154     www       601: 	  $file=~s/<\/problem>\s*$/<\/part><\/library>/s;
                    602:        }
1.153     www       603:     }
1.46      albertel  604:     my $dir=$location;
                    605:     $dir=~s:/[^/]*$::;
                    606:     #  &Apache::lonxml::debug("directory $dir $location file $file \n<b>END</b>\n");
1.142     albertel  607:     my $id= &Apache::lonxml::get_id($parstack,$safeeval);
1.57      albertel  608:     if (!$id) { $id=$Apache::lonxml::curdepth; }
                    609:     push(@Apache::inputtags::import,$id);
1.90      albertel  610:     push(@Apache::inputtags::importlist,$id);
1.87      sakharuk  611: 
1.144     albertel  612:     &Apache::lonxml::newparser($parser,\$file,$dir);
1.87      sakharuk  613: 
1.56      albertel  614:   } elsif ($target eq "edit" ) {
1.46      albertel  615:     $result.=&Apache::edit::tag_start($target,$token);
1.153     www       616:     my $location=$token->[1];
                    617:     $location=~s/^\s*//s;
                    618:     $location=~s/\s*$//s;
1.175   ! raeburn   619:     my $crsonly = join(',',(&Apache::loncommon::filecategorytypes('Problem'),
        !           620:                             &Apache::loncommon::filecategorytypes('Library')));
1.153     www       621:     $result.=&Apache::edit::editline($location,$bodytext,'',40);
1.175   ! raeburn   622:     $result.=&Apache::edit::browse_or_search(undef,'textnode',undef,undef,$crsonly);
        !           623:     $result.= '&nbsp;<span class="LC_nobreak"><label>'.&mt('Import as:').
1.153     www       624:               '<select name="importmode_'.$Apache::lonxml::curdepth.'">';
1.154     www       625:     my %options=&Apache::lonlocal::texthash(''        => 'as standard library',
                    626:                                             'problem' => 'as problem',
                    627:                                             'part'    => 'as problem part(s)');
                    628:     foreach my $option (sort(keys(%options))) {
1.153     www       629:        $result.='<option value="'.$option.'"';
                    630:        if ($option eq &Apache::lonxml::get_param('importmode',$parstack,$safeeval)) {
                    631:           $result.=' selected="selected"';
                    632:        }
1.154     www       633:        $result.='>'.$options{$option}.'</option>';
1.153     www       634:     }
1.175   ! raeburn   635:     $result.='</select></label></span>';
1.46      albertel  636:     #FIXME this need to convert $bodytext to be a contruction space reference
                    637:     #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
                    638:     #$result.="Click<a href=\"$location\">here</a> to edit<br />"
1.56      albertel  639:   } elsif ($target eq 'modified') {
1.153     www       640:       &Apache::edit::get_new_args($token,$parstack,$safeeval,'importmode');
                    641:       $result='<import id="'.$token->[2]{'id'}.'" importmode="'.$token->[2]{'importmode'}.'">';
                    642:       $result.=&Apache::edit::modifiedfield("/import",$parser);
1.56      albertel  643:   } elsif ($target eq 'meta') {
1.142     albertel  644:     my $id= &Apache::lonxml::get_id($parstack,$safeeval);
1.57      albertel  645:     $result.='<import part="'.$Apache::inputtags::part;
                    646:     if ($id) {
                    647:       $result.='" id="'.$id;
                    648:     }
1.156     www       649:     $result.='" importmode="'.$token->[2]{'importmode'}.'">';
1.56      albertel  650:     $result.=$bodytext;
                    651:     $result.='</import>';
1.46      albertel  652:   }
                    653:   return $result;
1.6       albertel  654: }
                    655: 
                    656: sub end_import {
1.69      albertel  657:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.57      albertel  658:   pop(@Apache::inputtags::import);
1.69      albertel  659:   my $result;
1.120     albertel  660:   if ($target eq 'edit' ) { $result=&Apache::edit::end_row.
                    661: 				&Apache::edit::end_table(); }
1.69      albertel  662:   return $result;
1.1       albertel  663: }
1.42      sakharuk  664: 
                    665: sub start_storetc {
1.43      albertel  666:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.42      sakharuk  667:   my $result = '';
                    668:   &Apache::lonxml::startredirection;
                    669:   return $result; 
                    670: }
                    671: 
                    672: sub end_storetc {
1.43      albertel  673:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.42      sakharuk  674:     my $result;
                    675:     my $output=&Apache::lonxml::endredirection;
                    676:     $output =~ s/\"/\&quot\;/g;
1.52      albertel  677:     $result = '{\bf '.$output.'.}}\write\tcfile{\protect\tcpc{ '.$output.'.}{\the\value{relpage}}}';
                    678:     return $result;
1.42      sakharuk  679: }
                    680: 
                    681: 
                    682: sub start_physnet {
1.45      sakharuk  683:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.174     raeburn   684:     my $bodytext = '/res/adm/includes/physnet.sty';
1.45      sakharuk  685:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
                    686:     my $cbistyletext=&Apache::lonnet::getfile($location);
1.42      sakharuk  687: 
1.45      sakharuk  688:     %$style = (%$style,&Apache::style::styleparser($target,$cbistyletext));
1.174     raeburn   689:     if (keys(%$style) && (($target eq 'web') || ($target eq 'tex'))) {
                    690:         $$parser['-1']->unget_token($token);
                    691:     }
1.59      albertel  692: #    if ( defined($$style{'physnet'}) ) {
                    693: #        &Apache::lonxml::newparser($parser,\$$style{'physnet'});
                    694: #    }
1.45      sakharuk  695:     return "";
                    696: }
1.42      sakharuk  697: 
1.45      sakharuk  698: sub end_physnet {
1.47      albertel  699:   return '';
1.42      sakharuk  700: }
1.62      albertel  701: 
                    702: sub start_standalone {
                    703:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.75      albertel  704:   my $result='';
1.137     albertel  705:   if ($target eq 'web' || $target eq 'webgrade') {
1.126     albertel  706:     if ( $env{'request.course.id'} ) {
1.133     albertel  707:       my $inside = &Apache::lonxml::get_all_text("/standalone",$parser,$style);
1.75      albertel  708:     } else {
                    709:       $result='<table bgcolor="#E1E1E1" border="2"><tr><td>';
                    710:     }
1.62      albertel  711:   }
1.75      albertel  712:   return $result;
1.62      albertel  713: }
                    714: 
                    715: sub end_standalone {
1.75      albertel  716:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    717:   my $result='';
1.137     albertel  718:   if ($target eq 'web' || $target eq 'webgrade' ) {
1.126     albertel  719:     if ( $env{'request.course.id'} ) {
1.75      albertel  720:     } else {
                    721:       $result='</td></tr></table>';
                    722:     }
                    723:   }
                    724:   return $result;
1.74      albertel  725: }
                    726: 
                    727: sub start_comment {
                    728:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    729:   my $result='';
                    730:   if ($target eq 'edit') {
                    731:     $result=&Apache::edit::tag_start($target,$token);
1.133     albertel  732:     my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser,$style);
1.77      albertel  733:     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)
1.74      albertel  734:   } elsif ( $target eq 'modified') {
1.103     albertel  735:     $result=$token->[4].&Apache::edit::modifiedfield("/comment",$parser);
1.137     albertel  736:   } elsif ( $target eq 'web'    || $target eq 'tex'  || $target eq 'grade'   ||
                    737: 	    $target eq 'answer' || $target eq 'meta' || $target eq 'analyze' ||
                    738: 	    $target eq 'webgrade') {
1.74      albertel  739:     #normally throw away comments
1.133     albertel  740:     my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser,$style);
1.74      albertel  741:   }
                    742:   return $result;
                    743: }
                    744: 
                    745: sub end_comment {
                    746:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    747:   if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
1.62      albertel  748:   return '';
                    749: }
                    750: 
1.42      sakharuk  751: 
1.47      albertel  752: sub xmlparse {
                    753:   my ($string) = @_;
1.111     albertel  754:   &Apache::lonxml::debug("xmlparse recursion starting with $string");
1.113     albertel  755:   # Apache::run::evaluate does an 'eval' on the name of the subroutine
                    756:   # if it detects something that looks like a subroutine, this ends up calling
                    757:   # things without any arguments and since perl is nice enough to pass
                    758:   # along the default arguments when you don't explicitly say no arguments
                    759:   # if you call &xmlparse, it gets &xmlparse passed as it argument.
                    760:   # Same thing soccurs with &chemparse.
1.111     albertel  761:   if ($string eq '&xmlparse') { return '&xmlparse'; }
1.113     albertel  762:   if ($string eq '&chemparse') { return '&chemparse'; }
1.47      albertel  763:   my ($target,$token,$tagstack,$parstack,$oldparser,$safeeval,$style)=
                    764:     @Apache::scripttag::parser_env;
                    765:   my @parser;
                    766:   &Apache::lonxml::newparser(\@parser,\$string);
1.132     albertel  767:   &Apache::lonxml::startredirection();
1.47      albertel  768:   my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,
                    769: 					     $parstack,\@parser,
                    770: 					     $safeeval,$style);
1.132     albertel  771:   $result.=&Apache::lonxml::endredirection();
1.122     albertel  772:   &Apache::lonxml::debug("target is $target xmlparse recursion ending with $result");
1.47      albertel  773:   return $result;
                    774: }
1.3       albertel  775: 
1.122     albertel  776: sub start_num {
                    777:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
                    778:     my $result = '';
                    779:     my $inside = &Apache::lonxml::get_all_text_unbalanced("/num",$parser);
1.137     albertel  780:     if ($target eq 'tex' || $target eq 'web' || $target eq 'webgrade') {
1.122     albertel  781: 	$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
                    782: 	if (!$Apache::lonxml::default_homework_loaded) {
                    783: 	    &Apache::lonxml::default_homework_load($safeeval);
                    784: 	}
                    785: 	@Apache::scripttag::parser_env = @_;
                    786: 	my $format=&Apache::lonxml::get_param('format',$parstack,$safeeval);
                    787: 	$result=&Apache::run::run("return &prettyprint(q\0$inside\0,q\0$format\0);",$safeeval);
                    788:     }    
                    789:     return $result;
                    790: }
                    791: 
                    792: sub end_num {
                    793:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
                    794:     my $result = '';
                    795:     return $result;
                    796: }
                    797: 
                    798: sub start_parse {
                    799:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
                    800:     my $result = '';
1.137     albertel  801:     if ( $target eq 'web'    || $target eq 'tex'    ||
                    802: 	 $target eq 'grade'  || $target eq 'answer' ||
                    803: 	 $target eq 'analyze'|| $target eq 'webgrade') {
1.122     albertel  804: 	my $inside = &Apache::lonxml::get_all_text_unbalanced("/parse",$parser);
                    805: 	$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
                    806: 	if (!$Apache::lonxml::default_homework_loaded) {
                    807: 	    &Apache::lonxml::default_homework_load($safeeval);
                    808: 	}
                    809: 	@Apache::scripttag::parser_env = @_;
                    810: 	$result=&Apache::run::run("return &xmlparse(q\0$inside\0);",$safeeval);
1.134     albertel  811: 	if ($target eq 'grade' || $target eq 'answer' ||
                    812: 	    $target eq 'analyze') {
                    813: 	    # grade/answer/analyxe should produce no output but if we
                    814: 	    # are redirecting, the redirecter should know what to do
                    815: 	    # with the output
                    816: 	    if (!$Apache::lonxml::redirection) { $result=''; }
                    817: 	}
1.122     albertel  818:     }
                    819:     return $result;
                    820: }
                    821: 
                    822: sub end_parse {
                    823:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
                    824:     my $result = '';
                    825:     return $result;
                    826: }
1.123     albertel  827: 
                    828: sub start_algebra {
                    829:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
                    830:     my $result = '';
1.137     albertel  831:     if ( $target eq 'web'     || $target eq 'tex'    ||
                    832: 	 $target eq 'grade'   || $target eq 'answer' ||
                    833: 	 $target eq 'analyze' || $target eq 'webgrade') {
1.123     albertel  834: 	my $inside = &Apache::lonxml::get_all_text_unbalanced("/algebra",$parser);
                    835: 	$inside = &Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
                    836: 	if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
1.125     albertel  837: 	    my $style=&Apache::lonxml::get_param('style',$parstack,$safeeval);
1.157     raeburn   838: 	    $result=&Apache::lontexconvert::algebra($inside,$target,$style,$parstack,$safeeval);
1.123     albertel  839: 	}
                    840: 	$Apache::lonxml::post_evaluate=0;
                    841:     }
                    842:     return $result;
                    843: }
                    844: 
                    845: sub end_algebra {
                    846:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
                    847:     my $result = '';
                    848:     return $result;
                    849: }
                    850: 
1.1       albertel  851: 1;
                    852: __END__
1.149     jms       853: 
                    854: =pod
                    855: 
                    856: =head1 NAME
                    857: 
                    858: Apache::scripttag.pm
                    859: 
                    860: =head1 SYNOPSIS
                    861: 
                    862: implements <script>, <scriptlib>, <parserlib>,
                    863: and <import>
                    864: 
                    865: This is part of the LearningOnline Network with CAPA project
                    866: described at http://www.lon-capa.org.
                    867: 
                    868: =cut
                    869: 

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