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

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

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