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

1.1       albertel    1: # The LearningOnline Network with CAPA
                      2: # <script> definiton
1.58      www         3: #
1.100   ! albertel    4: # $Id: scripttag.pm,v 1.99 2003/06/18 21:04:42 albertel 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.34      albertel   28: # 2/21 Guy
1.50      www        29: # 8/20 Gerd Kortemeyer
1.1       albertel   30: 
1.47      albertel   31: package Apache::scripttag;
1.1       albertel   32: 
                     33: use strict;
1.3       albertel   34: use Apache::lonnet;
1.42      sakharuk   35: use Apache::style;
1.1       albertel   36: 
1.47      albertel   37: #Globals
                     38: # this used to pass around the standard callsub arguments to a tag func
                     39: # so xmlparse can reenter the inner_xmlparse loop.
                     40: 
                     41: @Apache::scripttag::parser_env = ();
1.61      harris41   42: BEGIN {
1.62      albertel   43:   &Apache::lonxml::register('Apache::scripttag',
                     44: 			    ('script','scriptlib','parserlib','import',
                     45: 			     'window','display','storetc','physnet',
1.81      albertel   46: 			     'standalone','comment',
1.86      albertel   47: 			     'LONCAPA_INTERNAL_TURN_STYLE_ON',
1.100   ! albertel   48: 			     'LONCAPA_INTERNAL_TURN_STYLE_OFF',
1.86      albertel   49: 			     'LONCAPA_INTERNAL_LONHTTPD_PORT'));
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: 
                     85: sub start_LONCAPA_INTERNAL_LONHTTPD_PORT {
                     86:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     87:     if ($target eq 'web') {
                     88: 	my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
                     89: 	if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
                     90: 	return '<script type="text/javascript">var lonhttpdport=\''.
                     91: 	    $lonhttpdPort.'\';</script>';
                     92:     }
                     93:     return ('','no');
                     94: }
                     95: 
                     96: sub end_LONCAPA_INTERNAL_LONHTTPD_PORT {
1.81      albertel   97:     return ('','no');
1.1       albertel   98: }
                     99: 
                    100: sub start_script {
1.40      albertel  101:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.47      albertel  102:   @Apache::scripttag::parser_env = @_;
1.24      albertel  103:   my $result='';
1.39      albertel  104:   my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);
                    105:   &Apache::lonxml::debug("found type of $type");
1.17      albertel  106:   if ($type eq "loncapa/perl") {
1.84      albertel  107:     my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);
1.17      albertel  108:     if ( $target eq "modified" ) {
1.41      albertel  109:       $result=$token->[4].&Apache::edit::modifiedfield();
1.54      albertel  110:     } elsif ( $target eq 'web' || $target eq 'tex' ||
1.78      albertel  111: 	      $target eq 'grade' || $target eq 'answer' ||
                    112: 	      $target eq 'analyze' ) {
1.79      albertel  113: 	if (!$Apache::lonxml::default_homework_loaded) {
                    114: 	    &Apache::lonxml::default_homework_load($safeeval);
                    115: 	}
                    116: 	&Apache::run::run($bodytext,$safeeval);
1.88      albertel  117: 	if (($target eq 'answer') &&
                    118: 	    ($ENV{'form.answer_output_mode'} ne 'tex') &&
                    119: 	    ($Apache::lonhomework::viewgrades == 'F')) {
1.79      albertel  120: 	    $Apache::lonxml::evaluate--;
1.99      albertel  121: 	    $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=200,scrollbars=1');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";
                    122: 	    my $listing=&Apache::run::dump($target,$safeeval);
                    123: 	    $listing=~s/\'/\\\'/g;
                    124: 	    $listing=~s/\n/\\n/g;
                    125: 	    $listing=~s/\r/\\r/g;
1.79      albertel  126: 	    $result.=$listing;
1.99      albertel  127: 	    $result.= "</pre></body></html>');newWindow.document.close();}</script><a href=\"javascript:LONCAPA_scriptvars_$Apache::lonxml::curdepth();void(0);\">Script Vars</a><br />";
1.79      albertel  128: 	}
1.28      albertel  129:     } elsif ($target eq "edit" ) {
1.41      albertel  130:       #&Apache::run::run($bodytext,$safeeval);
                    131:       #$result="<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
                    132:       $result=&Apache::edit::tag_start($target,$token,'Script');
1.77      albertel  133:       $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
1.17      albertel  134:     }
                    135:   } else {
1.66      albertel  136:     if ($target ne "meta") {
                    137:       $result = $token->[4];
1.85      albertel  138:       my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);
1.66      albertel  139:       $result.=$bodytext;
                    140:     }
1.13      albertel  141:   }
1.24      albertel  142:   return $result;
1.17      albertel  143: }
1.13      albertel  144: 
1.17      albertel  145: sub end_script {
1.40      albertel  146:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.28      albertel  147:   if ( $target eq "meta" ) { return ''; } 
1.39      albertel  148:   my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval);
1.29      albertel  149:   my $result='';
                    150:   #other script blocks need to survive
1.53      albertel  151:   if ($type ne "loncapa/perl") {
                    152:     return $token->[2];
                    153:   } elsif ($target eq 'edit' ) {
                    154:     return &Apache::edit::end_table();
1.78      albertel  155:   } elsif ($target eq 'answer') {
1.53      albertel  156:     $Apache::lonxml::evaluate++;
                    157:   }
1.28      albertel  158:   return '';
1.24      albertel  159: }
                    160: 
                    161: sub start_display {
1.40      albertel  162:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.39      albertel  163: 
1.48      albertel  164:   my $result;
1.84      albertel  165:   my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);
1.39      albertel  166: 
1.24      albertel  167:   if ( $target eq "modified" ) {
1.48      albertel  168:     $result=$token->[4].&Apache::edit::modifiedfield();
1.54      albertel  169:   } elsif ( $target eq 'web' || $target eq 'tex' ||
1.78      albertel  170: 	    $target eq 'grade' || $target eq 'answer' ||
                    171: 	      $target eq 'analyze') {
1.80      albertel  172:       if (!$Apache::lonxml::default_homework_loaded) {
                    173: 	  &Apache::lonxml::default_homework_load($safeeval);
                    174:       }
                    175:       $result=&Apache::run::run($bodytext,$safeeval);
                    176:       if ($target eq 'grade' || $target eq 'answer' ||
                    177: 	  $target eq 'analyze') {
                    178: 	  $result=''; # grade should produce no output
                    179:       }
1.48      albertel  180:   } elsif ($target eq "edit" ) {
                    181:     #$result = 
                    182:     #  "<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
                    183:     #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
                    184:     $result=&Apache::edit::tag_start($target,$token,'Script With Display');
1.77      albertel  185:     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)
1.24      albertel  186:   }
                    187:   return $result;
                    188: }
                    189: 
                    190: sub end_display {
1.48      albertel  191:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    192:   if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
                    193:   return '';
1.1       albertel  194: }
1.3       albertel  195: 
                    196: sub start_scriptlib {
1.40      albertel  197:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.37      albertel  198:   my $bodytext;
                    199:   my $result ='';
                    200:   my $error='';
                    201: 
1.78      albertel  202:   if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || 
                    203:       $target eq 'edit' || $target eq 'answer' || $target eq 'analyze') {
1.37      albertel  204:     $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
                    205:     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
                    206: 				     $$parstack[$#$parstack]);
                    207:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
                    208: 					       $bodytext);
                    209:     my $script=&Apache::lonnet::getfile($location);
                    210:     if ($script == -1) {
                    211:       if ($target eq 'edit') {
                    212:         $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
                    213:       } else {
                    214: 	&Apache::lonxml::error("<b> Unable to find <i>$location</i> for scriptlib</b>");
                    215: 	return "";
                    216:       }
                    217:     }
                    218:     &Apache::run::run($script,$safeeval);
                    219:     #&Apache::lonxml::debug("ran $bodytext:<br />".&Apache::lonnet::getfile($bodytext)."<br />");
1.18      albertel  220:   }
1.13      albertel  221:   if ($target eq "edit" ) {
1.37      albertel  222:     $result=
1.49      albertel  223:       &Apache::edit::tag_start($target,$token,'New Script Functions').
1.83      matthew   224: 	&Apache::edit::editline($token->[1],$bodytext,'scriptlib',40).
                    225:             &Apache::edit::browse(undef,'textnode').
1.49      albertel  226: 	  $error.'</td></tr>'.
                    227: 	    &Apache::edit::end_table();
1.37      albertel  228:   }
                    229:   if ($target eq "modified" ) {
                    230:     $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
1.65      matthew   231:     $result=$token->[4].&Apache::edit::modifiedfield($token);
1.37      albertel  232:     &Apache::lonxml::debug($result);
1.3       albertel  233:   }
                    234:   return $result;
                    235: }
                    236: 
1.37      albertel  237: sub end_scriptlib {
1.40      albertel  238:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.49      albertel  239:   my @result;
                    240:   if ($target eq "edit" ) { $result[1]='no'; }
                    241:   return @result;
1.37      albertel  242: }
1.4       albertel  243: 
                    244: sub start_parserlib {
1.40      albertel  245:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.37      albertel  246:   my $bodytext;
1.7       albertel  247:   my $result ="";
1.37      albertel  248:   my $error='';
1.78      albertel  249:   if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' ||
                    250:       $target eq 'edit' || $target eq 'answer' || $target eq 'analyze') {
1.37      albertel  251:     $bodytext=$$parser[$#$parser]->get_text("/parserlib");
                    252:     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
                    253: 				     $$parstack[$#$parstack]);
                    254:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
                    255: 					       $bodytext);
                    256:     my $styletext=&Apache::lonnet::getfile($location);
                    257:     #&Apache::lonxml::debug("found :$bodytext: in :$location: with :$styletext:");
                    258:     if ($styletext == -1) {
                    259:       if ($target eq 'edit') {
                    260: 	$error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
                    261:       } else {
                    262: 	&Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>");
                    263: 	return "";
                    264:       }
                    265:     }
                    266:     %$style = ( %$style , &Apache::style::styleparser($target,$styletext));
1.18      albertel  267:   }
1.13      albertel  268:   if ($target eq "edit" ) {
1.37      albertel  269:     $result=
1.49      albertel  270:       &Apache::edit::tag_start($target,$token,'New Tag Definitions').
1.68      albertel  271: 	&Apache::edit::editline($token->[1],$bodytext,'',40).
1.49      albertel  272: 	  $error.'</td></tr>'.
                    273: 	    &Apache::edit::end_table();
1.37      albertel  274:   }
                    275:   if ($target eq "modified" ) {
                    276:     $bodytext=$$parser[$#$parser]->get_text("/parserlib");
1.65      matthew   277:     $result=$token->[4].&Apache::edit::modifiedfield($token);
1.37      albertel  278:     &Apache::lonxml::debug($result);
1.7       albertel  279:   }
                    280:   return $result;
1.4       albertel  281: }
                    282: 
                    283: sub end_parserlib {
1.40      albertel  284:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.49      albertel  285:   my @result;
                    286:   if ($target eq "edit" ) { $result[1]='no'; }
                    287:   return @result;
1.6       albertel  288: }
                    289: 
1.30      sakharuk  290: sub start_window {
1.40      albertel  291:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.20      sakharuk  292:   my $result = '';
1.31      albertel  293:   if ($target eq 'web') {
1.34      albertel  294:     &Apache::lonxml::startredirection;
1.35      sakharuk  295:   }  elsif ($target eq 'tex') {
1.42      sakharuk  296:        $result = '\unskip\footnote{';
1.35      sakharuk  297:    }
1.19      sakharuk  298:   return $result;  
                    299: }
                    300: 
1.30      sakharuk  301: sub end_window {
1.40      albertel  302:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.30      sakharuk  303:   my $result;
1.31      albertel  304:   if ($target eq 'web') {
1.34      albertel  305:     my $output=&Apache::lonxml::endredirection;
1.97      albertel  306:     $output =~ s/[\n\r]/ /g;
1.98      albertel  307: #    $output = &HTML::Entities::encode($output,'<>&"\'');
                    308:     $output =~ s/\'/\\\'/g;
1.92      albertel  309:     my $linktext= &Apache::lonxml::get_param('linktext',$parstack,$safeeval);
                    310:     if (!$linktext) { $linktext='<sup>*</sup>'; }
                    311:     my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval);
                    312:     if (!$width) { $width='500'; }
                    313:     my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
                    314:     if (!$height) { $height='200'; }
1.98      albertel  315:     $result = "<script type=\"text/javascript\"> function LONCAPA_newwindow_$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=$width,height=$height,scrollbars=1');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>newwindow</title></head><body bgcolor=\"#FFFFFF\"> $output </body></html>');newWindow.document.close();}</script><a href=\"javascript:LONCAPA_newwindow_$Apache::lonxml::curdepth();void(0);\">$linktext</a>";
1.35      sakharuk  316:   } elsif ($target eq 'tex') {
                    317:       $result = '}';
1.30      sakharuk  318:   } else {
1.35      sakharuk  319:       $result = '';
1.30      sakharuk  320:   }
1.20      sakharuk  321:   return $result; 
1.19      sakharuk  322: }
                    323: 
1.6       albertel  324: sub start_import {
1.40      albertel  325:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.31      albertel  326:   my $bodytext=$$parser[$#$parser]->get_text("/import");
1.7       albertel  327:   my $result ="";
1.13      albertel  328: 
                    329:   $bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]);
1.14      albertel  330: 
1.78      albertel  331:   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
                    332:       $target eq 'tex' || $target eq 'analyze' ) {
1.46      albertel  333:     # FIXME this probably needs to be smart about construction vs.
                    334:     # non construction space.
                    335:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
                    336:     my $file=&Apache::lonnet::getfile($location);
                    337:     if ($file == -1) {
                    338:       &Apache::lonxml::error("<b> Unable to find <i>$bodytext as $location</i> for import</b>");
                    339:       return "";
                    340:     }
1.13      albertel  341: 
1.46      albertel  342:     my $dir=$location;
                    343:     $dir=~s:/[^/]*$::;
                    344:     #  &Apache::lonxml::debug("directory $dir $location file $file \n<b>END</b>\n");
1.57      albertel  345:     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
                    346:     if (!$id) { $id=$Apache::lonxml::curdepth; }
                    347:     push(@Apache::inputtags::import,$id);
1.90      albertel  348:     push(@Apache::inputtags::importlist,$id);
1.87      sakharuk  349: 
                    350: 	&Apache::lonxml::newparser($parser,\$file,$dir);
                    351: 
1.56      albertel  352:   } elsif ($target eq "edit" ) {
1.46      albertel  353:     $result.=&Apache::edit::tag_start($target,$token);
1.68      albertel  354:     $result.=&Apache::edit::editline($token->[1],$bodytext,'',40);
1.83      matthew   355:     $result.=&Apache::edit::browse(undef,'textnode');
1.46      albertel  356:     #FIXME this need to convert $bodytext to be a contruction space reference
                    357:     #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
                    358:     #$result.="Click<a href=\"$location\">here</a> to edit<br />"
1.56      albertel  359:   } elsif ($target eq 'modified') {
1.46      albertel  360:     $bodytext=$$parser[$#$parser]->get_text("/import");
1.65      matthew   361:     $result=$token->[4].&Apache::edit::modifiedfield($token);
1.46      albertel  362:     &Apache::lonxml::debug($result);
1.56      albertel  363:   } elsif ($target eq 'meta') {
1.57      albertel  364:     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
                    365:     $result.='<import part="'.$Apache::inputtags::part;
                    366:     if ($id) {
                    367:       $result.='" id="'.$id;
                    368:     }
                    369:     $result.='">';
1.56      albertel  370:     $result.=$bodytext;
                    371:     $result.='</import>';
1.46      albertel  372:   }
                    373:   return $result;
1.6       albertel  374: }
                    375: 
                    376: sub end_import {
1.69      albertel  377:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.57      albertel  378:   pop(@Apache::inputtags::import);
1.69      albertel  379:   my $result;
                    380:   if ($target eq 'edit' ) { $result=&Apache::edit::end_table(); }
                    381:   return $result;
1.1       albertel  382: }
1.42      sakharuk  383: 
                    384: sub start_storetc {
1.43      albertel  385:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.42      sakharuk  386:   my $result = '';
                    387:   &Apache::lonxml::startredirection;
                    388:   return $result; 
                    389: }
                    390: 
                    391: sub end_storetc {
1.43      albertel  392:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.42      sakharuk  393:     my $result;
                    394:     my $output=&Apache::lonxml::endredirection;
                    395:     $output =~ s/\"/\&quot\;/g;
1.52      albertel  396:     $result = '{\bf '.$output.'.}}\write\tcfile{\protect\tcpc{ '.$output.'.}{\the\value{relpage}}}';
                    397:     return $result;
1.42      sakharuk  398: }
                    399: 
                    400: 
                    401: sub start_physnet {
1.45      sakharuk  402:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.50      www       403:     my $bodytext = '/adm/includes/physnet.sty';
1.45      sakharuk  404:     my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
                    405:     my $cbistyletext=&Apache::lonnet::getfile($location);
1.42      sakharuk  406: 
1.45      sakharuk  407:     %$style = (%$style,&Apache::style::styleparser($target,$cbistyletext));
1.59      albertel  408:     $$parser['-1']->unget_token($token);
                    409: #    if ( defined($$style{'physnet'}) ) {
                    410: #        &Apache::lonxml::newparser($parser,\$$style{'physnet'});
                    411: #    }
1.45      sakharuk  412:     return "";
                    413: }
1.42      sakharuk  414: 
1.45      sakharuk  415: sub end_physnet {
1.47      albertel  416:   return '';
1.42      sakharuk  417: }
1.62      albertel  418: 
                    419: sub start_standalone {
                    420:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.75      albertel  421:   my $result='';
                    422:   if ($target eq 'web' ) {
                    423:     if ( $ENV{'request.course.id'} ) {
1.85      albertel  424:       my $inside = &Apache::lonxml::get_all_text("/standalone",$parser);
1.75      albertel  425:     } else {
                    426:       $result='<table bgcolor="#E1E1E1" border="2"><tr><td>';
                    427:     }
1.62      albertel  428:   }
1.75      albertel  429:   return $result;
1.62      albertel  430: }
                    431: 
                    432: sub end_standalone {
1.75      albertel  433:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    434:   my $result='';
                    435:   if ($target eq 'web' ) {
                    436:     if ( $ENV{'request.course.id'} ) {
                    437:     } else {
                    438:       $result='</td></tr></table>';
                    439:     }
                    440:   }
                    441:   return $result;
1.74      albertel  442: }
                    443: 
                    444: sub start_comment {
                    445:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    446:   my $result='';
                    447:   if ($target eq 'edit') {
                    448:     $result=&Apache::edit::tag_start($target,$token);
1.85      albertel  449:     my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
1.77      albertel  450:     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)
1.74      albertel  451:   } elsif ( $target eq 'modified') {
                    452:     $result=$token->[4].&Apache::edit::modifiedfield($token);
1.78      albertel  453:   } elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
                    454: 	    $target eq 'answer' || $target eq 'meta' || $target eq 'analyze') {
1.74      albertel  455:     #normally throw away comments
1.85      albertel  456:     my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
1.74      albertel  457:   }
                    458:   return $result;
                    459: }
                    460: 
                    461: sub end_comment {
                    462:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    463:   if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
1.62      albertel  464:   return '';
                    465: }
                    466: 
1.42      sakharuk  467: 
1.47      albertel  468: sub xmlparse {
                    469:   my ($string) = @_;
1.88      albertel  470: #  &Apache::lonxml::debug("Got $string");
1.47      albertel  471:   my ($target,$token,$tagstack,$parstack,$oldparser,$safeeval,$style)=
                    472:     @Apache::scripttag::parser_env;
                    473:   my @parser;
                    474:   &Apache::lonxml::newparser(\@parser,\$string);
                    475:   my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,
                    476: 					     $parstack,\@parser,
                    477: 					     $safeeval,$style);
                    478:   return $result;
                    479: }
1.3       albertel  480: 
1.1       albertel  481: 1;
                    482: __END__

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