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