Annotation of loncom/xml/scripttag.pm, revision 1.107
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # <script> definiton
1.58 www 3: #
1.107 ! albertel 4: # $Id: scripttag.pm,v 1.106 2004/01/16 19:46:03 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") {
107: if ( $target eq "modified" ) {
1.103 albertel 108: $result=$token->[4].&Apache::edit::modifiedfield('/script',$parser);
1.54 albertel 109: } elsif ( $target eq 'web' || $target eq 'tex' ||
1.78 albertel 110: $target eq 'grade' || $target eq 'answer' ||
111: $target eq 'analyze' ) {
1.107 ! albertel 112: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
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.104 albertel 121: $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";
1.99 albertel 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 /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
1.107 ! albertel 132: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
1.103 albertel 133: $result=&Apache::edit::tag_start($target,$token,'Script');
134: $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
1.107 ! albertel 135: } elsif ($target eq 'meta') {
! 136: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
1.17 albertel 137: }
138: } else {
1.66 albertel 139: if ($target ne "meta") {
140: $result = $token->[4];
1.107 ! albertel 141: my $bodytext=&Apache::lonxml::get_all_text_unblanaced("/script",$parser);
1.66 albertel 142: $result.=$bodytext;
143: }
1.13 albertel 144: }
1.24 albertel 145: return $result;
1.17 albertel 146: }
1.13 albertel 147:
1.17 albertel 148: sub end_script {
1.40 albertel 149: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.28 albertel 150: if ( $target eq "meta" ) { return ''; }
1.39 albertel 151: my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval);
1.29 albertel 152: my $result='';
153: #other script blocks need to survive
1.53 albertel 154: if ($type ne "loncapa/perl") {
155: return $token->[2];
156: } elsif ($target eq 'edit' ) {
157: return &Apache::edit::end_table();
1.78 albertel 158: } elsif ($target eq 'answer') {
1.53 albertel 159: $Apache::lonxml::evaluate++;
160: }
1.28 albertel 161: return '';
1.24 albertel 162: }
163:
164: sub start_display {
1.40 albertel 165: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.39 albertel 166:
1.48 albertel 167: my $result;
1.39 albertel 168:
1.24 albertel 169: if ( $target eq "modified" ) {
1.103 albertel 170: $result=$token->[4].&Apache::edit::modifiedfield("/display",$parser);
1.54 albertel 171: } elsif ( $target eq 'web' || $target eq 'tex' ||
1.78 albertel 172: $target eq 'grade' || $target eq 'answer' ||
173: $target eq 'analyze') {
1.107 ! albertel 174: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
1.80 albertel 175: if (!$Apache::lonxml::default_homework_loaded) {
176: &Apache::lonxml::default_homework_load($safeeval);
177: }
178: $result=&Apache::run::run($bodytext,$safeeval);
179: if ($target eq 'grade' || $target eq 'answer' ||
180: $target eq 'analyze') {
181: $result=''; # grade should produce no output
182: }
1.101 albertel 183: $Apache::lonxml::post_evaluate=0;
1.48 albertel 184: } elsif ($target eq "edit" ) {
1.107 ! albertel 185: my $bodytext=&Apache::lonxml::get_all_text_unblanced("/display",$parser);
1.48 albertel 186: #$result =
187: # "<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
188: #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
189: $result=&Apache::edit::tag_start($target,$token,'Script With Display');
1.77 albertel 190: $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)
1.107 ! albertel 191: } elsif ($target eq 'meta') {
! 192: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
1.24 albertel 193: }
194: return $result;
195: }
196:
197: sub end_display {
1.48 albertel 198: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
199: if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
200: return '';
1.1 albertel 201: }
1.3 albertel 202:
203: sub start_scriptlib {
1.40 albertel 204: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.37 albertel 205: my $bodytext;
206: my $result ='';
207: my $error='';
208:
1.106 albertel 209: if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
210: $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
211: $target eq 'analyze') {
1.37 albertel 212: $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
213: $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
214: $$parstack[$#$parstack]);
215: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
216: $bodytext);
217: my $script=&Apache::lonnet::getfile($location);
218: if ($script == -1) {
219: if ($target eq 'edit') {
220: $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
221: } else {
222: &Apache::lonxml::error("<b> Unable to find <i>$location</i> for scriptlib</b>");
223: return "";
224: }
225: }
226: &Apache::run::run($script,$safeeval);
227: #&Apache::lonxml::debug("ran $bodytext:<br />".&Apache::lonnet::getfile($bodytext)."<br />");
1.18 albertel 228: }
1.13 albertel 229: if ($target eq "edit" ) {
1.37 albertel 230: $result=
1.49 albertel 231: &Apache::edit::tag_start($target,$token,'New Script Functions').
1.83 matthew 232: &Apache::edit::editline($token->[1],$bodytext,'scriptlib',40).
233: &Apache::edit::browse(undef,'textnode').
1.49 albertel 234: $error.'</td></tr>'.
235: &Apache::edit::end_table();
1.37 albertel 236: }
237: if ($target eq "modified" ) {
1.103 albertel 238: $result=$token->[4].&Apache::edit::modifiedfield("/scriptlib",$parser);
1.3 albertel 239: }
240: return $result;
241: }
242:
1.37 albertel 243: sub end_scriptlib {
1.40 albertel 244: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.49 albertel 245: my @result;
246: if ($target eq "edit" ) { $result[1]='no'; }
247: return @result;
1.37 albertel 248: }
1.4 albertel 249:
250: sub start_parserlib {
1.40 albertel 251: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.37 albertel 252: my $bodytext;
1.7 albertel 253: my $result ="";
1.37 albertel 254: my $error='';
1.106 albertel 255: if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
256: $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
257: $target eq 'analyze') {
1.37 albertel 258: $bodytext=$$parser[$#$parser]->get_text("/parserlib");
259: $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
260: $$parstack[$#$parstack]);
261: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
262: $bodytext);
263: my $styletext=&Apache::lonnet::getfile($location);
264: #&Apache::lonxml::debug("found :$bodytext: in :$location: with :$styletext:");
265: if ($styletext == -1) {
266: if ($target eq 'edit') {
267: $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
268: } else {
269: &Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>");
270: return "";
271: }
272: }
273: %$style = ( %$style , &Apache::style::styleparser($target,$styletext));
1.18 albertel 274: }
1.13 albertel 275: if ($target eq "edit" ) {
1.37 albertel 276: $result=
1.49 albertel 277: &Apache::edit::tag_start($target,$token,'New Tag Definitions').
1.68 albertel 278: &Apache::edit::editline($token->[1],$bodytext,'',40).
1.49 albertel 279: $error.'</td></tr>'.
280: &Apache::edit::end_table();
1.37 albertel 281: }
282: if ($target eq "modified" ) {
1.103 albertel 283: $result=$token->[4].&Apache::edit::modifiedfield("/parserlib",$parser);
1.7 albertel 284: }
285: return $result;
1.4 albertel 286: }
287:
288: sub end_parserlib {
1.40 albertel 289: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.49 albertel 290: my @result;
291: if ($target eq "edit" ) { $result[1]='no'; }
292: return @result;
1.6 albertel 293: }
294:
1.30 sakharuk 295: sub start_window {
1.105 albertel 296: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
297: my $result = '';
298: if ($target eq 'web') {
299: &Apache::lonxml::startredirection;
300: } elsif ($target eq 'tex') {
301: $result = '\unskip\footnote{';
302: } elsif ($target eq 'edit') {
303: $result.=&Apache::edit::tag_start($target,$token);
304: $result.=&Apache::edit::text_arg('Text of Link:','linktext',$token,70);
305: $result.=&Apache::edit::text_arg('Height:','width',$token,5);
306: $result.=&Apache::edit::text_arg('Width:','height',$token,5);
307: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
308: } elsif ($target eq 'modified') {
309: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
310: $safeeval,'linttext',
311: 'width','height');
312: if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
313: }
314: return $result;
1.19 sakharuk 315: }
316:
1.30 sakharuk 317: sub end_window {
1.40 albertel 318: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.30 sakharuk 319: my $result;
1.31 albertel 320: if ($target eq 'web') {
1.34 albertel 321: my $output=&Apache::lonxml::endredirection;
1.97 albertel 322: $output =~ s/[\n\r]/ /g;
1.98 albertel 323: # $output = &HTML::Entities::encode($output,'<>&"\'');
324: $output =~ s/\'/\\\'/g;
1.92 albertel 325: my $linktext= &Apache::lonxml::get_param('linktext',$parstack,$safeeval);
326: if (!$linktext) { $linktext='<sup>*</sup>'; }
327: my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval);
328: if (!$width) { $width='500'; }
329: my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
330: if (!$height) { $height='200'; }
1.98 albertel 331: $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 332: } elsif ($target eq 'tex') {
333: $result = '}';
1.30 sakharuk 334: } else {
1.35 sakharuk 335: $result = '';
1.30 sakharuk 336: }
1.20 sakharuk 337: return $result;
1.19 sakharuk 338: }
339:
1.6 albertel 340: sub start_import {
1.40 albertel 341: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.31 albertel 342: my $bodytext=$$parser[$#$parser]->get_text("/import");
1.7 albertel 343: my $result ="";
1.13 albertel 344:
345: $bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]);
1.14 albertel 346:
1.78 albertel 347: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
348: $target eq 'tex' || $target eq 'analyze' ) {
1.46 albertel 349: # FIXME this probably needs to be smart about construction vs.
350: # non construction space.
351: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
352: my $file=&Apache::lonnet::getfile($location);
353: if ($file == -1) {
354: &Apache::lonxml::error("<b> Unable to find <i>$bodytext as $location</i> for import</b>");
355: return "";
356: }
1.13 albertel 357:
1.46 albertel 358: my $dir=$location;
359: $dir=~s:/[^/]*$::;
360: # &Apache::lonxml::debug("directory $dir $location file $file \n<b>END</b>\n");
1.57 albertel 361: my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
362: if (!$id) { $id=$Apache::lonxml::curdepth; }
363: push(@Apache::inputtags::import,$id);
1.90 albertel 364: push(@Apache::inputtags::importlist,$id);
1.87 sakharuk 365:
366: &Apache::lonxml::newparser($parser,\$file,$dir);
367:
1.56 albertel 368: } elsif ($target eq "edit" ) {
1.46 albertel 369: $result.=&Apache::edit::tag_start($target,$token);
1.68 albertel 370: $result.=&Apache::edit::editline($token->[1],$bodytext,'',40);
1.83 matthew 371: $result.=&Apache::edit::browse(undef,'textnode');
1.46 albertel 372: #FIXME this need to convert $bodytext to be a contruction space reference
373: #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
374: #$result.="Click<a href=\"$location\">here</a> to edit<br />"
1.56 albertel 375: } elsif ($target eq 'modified') {
1.103 albertel 376: $result=$token->[4].&Apache::edit::modifiedfield("/import",$parser);
1.56 albertel 377: } elsif ($target eq 'meta') {
1.57 albertel 378: my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
379: $result.='<import part="'.$Apache::inputtags::part;
380: if ($id) {
381: $result.='" id="'.$id;
382: }
383: $result.='">';
1.56 albertel 384: $result.=$bodytext;
385: $result.='</import>';
1.46 albertel 386: }
387: return $result;
1.6 albertel 388: }
389:
390: sub end_import {
1.69 albertel 391: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.57 albertel 392: pop(@Apache::inputtags::import);
1.69 albertel 393: my $result;
394: if ($target eq 'edit' ) { $result=&Apache::edit::end_table(); }
395: return $result;
1.1 albertel 396: }
1.42 sakharuk 397:
398: sub start_storetc {
1.43 albertel 399: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.42 sakharuk 400: my $result = '';
401: &Apache::lonxml::startredirection;
402: return $result;
403: }
404:
405: sub end_storetc {
1.43 albertel 406: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.42 sakharuk 407: my $result;
408: my $output=&Apache::lonxml::endredirection;
409: $output =~ s/\"/\"\;/g;
1.52 albertel 410: $result = '{\bf '.$output.'.}}\write\tcfile{\protect\tcpc{ '.$output.'.}{\the\value{relpage}}}';
411: return $result;
1.42 sakharuk 412: }
413:
414:
415: sub start_physnet {
1.45 sakharuk 416: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.50 www 417: my $bodytext = '/adm/includes/physnet.sty';
1.45 sakharuk 418: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
419: my $cbistyletext=&Apache::lonnet::getfile($location);
1.42 sakharuk 420:
1.45 sakharuk 421: %$style = (%$style,&Apache::style::styleparser($target,$cbistyletext));
1.59 albertel 422: $$parser['-1']->unget_token($token);
423: # if ( defined($$style{'physnet'}) ) {
424: # &Apache::lonxml::newparser($parser,\$$style{'physnet'});
425: # }
1.45 sakharuk 426: return "";
427: }
1.42 sakharuk 428:
1.45 sakharuk 429: sub end_physnet {
1.47 albertel 430: return '';
1.42 sakharuk 431: }
1.62 albertel 432:
433: sub start_standalone {
434: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.75 albertel 435: my $result='';
436: if ($target eq 'web' ) {
437: if ( $ENV{'request.course.id'} ) {
1.85 albertel 438: my $inside = &Apache::lonxml::get_all_text("/standalone",$parser);
1.75 albertel 439: } else {
440: $result='<table bgcolor="#E1E1E1" border="2"><tr><td>';
441: }
1.62 albertel 442: }
1.75 albertel 443: return $result;
1.62 albertel 444: }
445:
446: sub end_standalone {
1.75 albertel 447: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
448: my $result='';
449: if ($target eq 'web' ) {
450: if ( $ENV{'request.course.id'} ) {
451: } else {
452: $result='</td></tr></table>';
453: }
454: }
455: return $result;
1.74 albertel 456: }
457:
458: sub start_comment {
459: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
460: my $result='';
461: if ($target eq 'edit') {
462: $result=&Apache::edit::tag_start($target,$token);
1.85 albertel 463: my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
1.77 albertel 464: $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)
1.74 albertel 465: } elsif ( $target eq 'modified') {
1.103 albertel 466: $result=$token->[4].&Apache::edit::modifiedfield("/comment",$parser);
1.78 albertel 467: } elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
468: $target eq 'answer' || $target eq 'meta' || $target eq 'analyze') {
1.74 albertel 469: #normally throw away comments
1.85 albertel 470: my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
1.74 albertel 471: }
472: return $result;
473: }
474:
475: sub end_comment {
476: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
477: if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
1.62 albertel 478: return '';
479: }
480:
1.42 sakharuk 481:
1.47 albertel 482: sub xmlparse {
483: my ($string) = @_;
1.88 albertel 484: # &Apache::lonxml::debug("Got $string");
1.47 albertel 485: my ($target,$token,$tagstack,$parstack,$oldparser,$safeeval,$style)=
486: @Apache::scripttag::parser_env;
487: my @parser;
488: &Apache::lonxml::newparser(\@parser,\$string);
489: my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,
490: $parstack,\@parser,
491: $safeeval,$style);
492: return $result;
493: }
1.3 albertel 494:
1.1 albertel 495: 1;
496: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>