1: # The LearningOnline Network with CAPA
2: # XML Parser Module
3: #
4: # last modified 06/26/00 by Alexander Sakharuk
5: # 11/6 Gerd Kortemeyer
6: # 6/1/1 Gerd Kortemeyer
7: # 2/21,3/13 Guy
8: # 3/29,5/4 Gerd Kortemeyer
9: # 5/10 Scott Harrison
10:
11: package Apache::lonxml;
12: use vars
13: qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist);
14: use strict;
15: use HTML::TokeParser;
16: use Safe;
17: use Safe::Hole;
18: use Opcode;
19:
20: sub register {
21: my $space;
22: my @taglist;
23: my $temptag;
24: ($space,@taglist) = @_;
25: foreach $temptag (@taglist) {
26: $Apache::lonxml::alltags{$temptag}=$space;
27: }
28: }
29:
30: use Apache::Constants qw(:common);
31: use Apache::lontexconvert;
32: use Apache::style;
33: use Apache::run;
34: use Apache::londefdef;
35: use Apache::scripttag;
36: use Apache::edit;
37: #================================================== Main subroutine: xmlparse
38: #debugging control, to turn on debugging modify the correct handler
39: $Apache::lonxml::debug=0;
40:
41: #path to the directory containing the file currently being processed
42: @pwd=();
43:
44: #these two are used for capturing a subset of the output for later processing,
45: #don't touch them directly use &startredirection and &endredirection
46: @outputstack = ();
47: $redirection = 0;
48:
49: #controls wheter the <import> tag actually does
50: $import = 1;
51: @extlinks=();
52:
53: # meta mode is a bit weird only some output is to be turned off
54: #<output> tag turns metamode off (defined in londefdef.pm)
55: $metamode = 0;
56:
57: # turns on and of run::evaluate actually derefencing var refs
58: $evaluate = 1;
59:
60: # data structure for eidt mode, determines what tags can go into what other tags
61: %insertlist=();
62:
63: sub xmlbegin {
64: my $output='';
65: if ($ENV{'browser.mathml'}) {
66: $output='<?xml version="1.0"?>'
67: .'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'
68: .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" '
69: .'[<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">]>'
70: .'<html xmlns:math="http://www.w3.org/1998/Math/MathML" '
71: .'xmlns="http://www.w3.org/TR/REC-html40">';
72: } else {
73: $output='<html>';
74: }
75: return $output;
76: }
77:
78: sub xmlend {
79: return '</html>';
80: }
81:
82: sub fontsettings() {
83: my $headerstring='';
84: if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) {
85: $headerstring.=
86: '<meta Content-Type="text/html; charset=x-mac-roman">';
87: }
88: return $headerstring;
89: }
90:
91: sub registerurl {
92: return (<<ENDSCRIPT);
93: <script language="JavaScript">
94: // BEGIN LON-CAPA Internal
95: function LONCAPAreg() {
96: if (window.location.pathname!="/res/adm/pages/menu.html") {
97: menu=window.open("","LONCAPAmenu");
98: menu.currentURL=window.location.pathname;
99: menu.currentStale=0;
100: }
101: }
102:
103: function LONCAPAstale() {
104: if (window.location.pathname!="/res/adm/pages/menu.html") {
105: menu=window.open("","LONCAPAmenu");
106: menu.currentStale=1;
107: }
108: }
109: // END LON-CAPA Internal
110: </script>
111: ENDSCRIPT
112: }
113:
114: sub loadevents() {
115: return 'LONCAPAreg();';
116: }
117:
118: sub unloadevents() {
119: return 'LONCAPAstale();';
120: }
121:
122: sub printalltags {
123: my $temp;
124: foreach $temp (sort keys %Apache::lonxml::alltags) {
125: &Apache::lonxml::debug("$temp -- $Apache::lonxml::alltags{$temp}");
126: }
127: }
128:
129: sub xmlparse {
130:
131: my ($target,$content_file_string,$safeinit,%style_for_target) = @_;
132: if ($target eq 'meta') {
133: $Apache::lonxml::redirection = 0;
134: $Apache::lonxml::metamode = 1;
135: $Apache::lonxml::evaluate = 1;
136: $Apache::lonxml::import = 0;
137: } elsif ($target eq 'grade') {
138: &startredirection;
139: $Apache::lonxml::metamode = 0;
140: $Apache::lonxml::evaluate = 1;
141: $Apache::lonxml::import = 1;
142: } elsif ($target eq 'modified') {
143: $Apache::lonxml::redirection = 0;
144: $Apache::lonxml::metamode = 0;
145: $Apache::lonxml::evaluate = 0;
146: $Apache::lonxml::import = 0;
147: } else {
148: $Apache::lonxml::redirection = 0;
149: $Apache::lonxml::metamode = 0;
150: $Apache::lonxml::evaluate = 1;
151: $Apache::lonxml::import = 1;
152: }
153: #&printalltags();
154: my @pars = ();
155: @Apache::lonxml::pwd=();
156: my $pwd=$ENV{'request.filename'};
157: $pwd =~ s:/[^/]*$::;
158: &newparser(\@pars,\$content_file_string,$pwd);
159: my $currentstring = '';
160: my $finaloutput = '';
161: my $newarg = '';
162: my $result;
163:
164: my $safeeval = new Safe;
165: my $safehole = new Safe::Hole;
166: $safeeval->permit("entereval");
167: $safeeval->permit(":base_math");
168: $safeeval->deny(":base_io");
169: $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
170: #need to inspect this class of ops
171: # $safeeval->deny(":base_orig");
172: $safeinit .= ';$external::target='.$target.';';
173: $safeinit .= ';$external::randomseed='.&Apache::lonnet::rndseed().';';
174: &Apache::run::run($safeinit,$safeeval);
175: #-------------------- Redefinition of the target in the case of compound target
176:
177: ($target, my @tenta) = split('&&',$target);
178:
179: my @stack = ();
180: my @parstack = ();
181: &initdepth;
182: my $token;
183: while ( $#pars > -1 ) {
184: while ($token = $pars[$#pars]->get_token) {
185: if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
186: if ($metamode<1) { $result=$token->[1]; }
187: } elsif ($token->[0] eq 'PI') {
188: if ($metamode<1) { $result=$token->[2]; }
189: } elsif ($token->[0] eq 'S') {
190: # add tag to stack
191: push (@stack,$token->[1]);
192: # add parameters list to another stack
193: push (@parstack,&parstring($token));
194: &increasedepth($token);
195: if (exists $style_for_target{$token->[1]}) {
196: if ($Apache::lonxml::redirection) {
197: $Apache::lonxml::outputstack['-1'] .=
198: &recurse($style_for_target{$token->[1]},$target,$safeeval,
199: \%style_for_target,@parstack);
200: } else {
201: $finaloutput .= &recurse($style_for_target{$token->[1]},$target,
202: $safeeval,\%style_for_target,@parstack);
203: }
204: } else {
205: $result = &callsub("start_$token->[1]", $target, $token,\@parstack,
206: \@pars, $safeeval, \%style_for_target);
207: }
208: } elsif ($token->[0] eq 'E') {
209: #clear out any tags that didn't end
210: while ($token->[1] ne $stack[$#stack] && ($#stack > -1)) {
211: &Apache::lonxml::warning("Unbalanced tags in resource $stack['-1']");
212: pop @stack;pop @parstack;&decreasedepth($token);
213: }
214:
215: if (exists $style_for_target{'/'."$token->[1]"}) {
216: if ($Apache::lonxml::redirection) {
217: $Apache::lonxml::outputstack['-1'] .=
218: &recurse($style_for_target{'/'."$token->[1]"},
219: $target,$safeeval,\%style_for_target,@parstack);
220: } else {
221: $finaloutput .= &recurse($style_for_target{'/'."$token->[1]"},
222: $target,$safeeval,\%style_for_target,
223: @parstack);
224: }
225:
226: } else {
227: $result = &callsub("end_$token->[1]", $target, $token, \@parstack,
228: \@pars,$safeeval, \%style_for_target);
229: }
230: } else {
231: &Apache::lonxml::error("Unknown token event :$token->[0]:$token->[1]:");
232: }
233: #evaluate variable refs in result
234: if ($result ne "") {
235: if ( $#parstack > -1 ) {
236: if ($Apache::lonxml::redirection) {
237: $Apache::lonxml::outputstack['-1'] .=
238: &Apache::run::evaluate($result,$safeeval,$parstack[$#parstack]);
239: } else {
240: $finaloutput .= &Apache::run::evaluate($result,$safeeval,
241: $parstack[$#parstack]);
242: }
243: } else {
244: $finaloutput .= &Apache::run::evaluate($result,$safeeval,'');
245: }
246: $result = '';
247: }
248: if ($token->[0] eq 'E') {
249: pop @stack;pop @parstack;&decreasedepth($token);
250: }
251: }
252: pop @pars;
253: pop @Apache::lonxml::pwd;
254: }
255:
256: # if ($target eq 'meta') {
257: # $finaloutput.=&endredirection;
258: # }
259:
260: if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) {
261: $finaloutput=&afterburn($finaloutput);
262: }
263:
264: return $finaloutput;
265: }
266:
267:
268: sub recurse {
269:
270: my @innerstack = ();
271: my @innerparstack = ();
272: my ($newarg,$target,$safeeval,$style_for_target,@parstack) = @_;
273: my @pat = ();
274: &newparser(\@pat,\$newarg);
275: my $tokenpat;
276: my $partstring = '';
277: my $output='';
278: my $decls='';
279: while ( $#pat > -1 ) {
280: while ($tokenpat = $pat[$#pat]->get_token) {
281: if (($tokenpat->[0] eq 'T') || ($tokenpat->[0] eq 'C') || ($tokenpat->[0] eq 'D') ) {
282: if ($metamode<1) { $partstring=$tokenpat->[1]; }
283: } elsif ($tokenpat->[0] eq 'PI') {
284: if ($metamode<1) { $partstring=$tokenpat->[2]; }
285: } elsif ($tokenpat->[0] eq 'S') {
286: push (@innerstack,$tokenpat->[1]);
287: push (@innerparstack,&parstring($tokenpat));
288: &increasedepth($tokenpat);
289: $partstring = &callsub("start_$tokenpat->[1]",
290: $target, $tokenpat, \@innerparstack,
291: \@pat, $safeeval, $style_for_target);
292: } elsif ($tokenpat->[0] eq 'E') {
293: #clear out any tags that didn't end
294: while ($tokenpat->[1] ne $innerstack[$#innerstack]
295: && ($#innerstack > -1)) {
296: &Apache::lonxml::warning("Unbalanced tags in resource $innerstack['-1']");
297: pop @innerstack;pop @innerparstack;&decreasedepth($tokenpat);
298: }
299: $partstring = &callsub("end_$tokenpat->[1]",
300: $target, $tokenpat, \@innerparstack,
301: \@pat, $safeeval, $style_for_target);
302: } else {
303: &Apache::lonxml::error("Unknown token event :$tokenpat->[0]:$tokenpat->[1]:");
304: }
305: #pass both the variable to the style tag, and the tag we
306: #are processing inside the <definedtag>
307: if ( $partstring ne "" ) {
308: if ( $#parstack > -1 ) {
309: if ( $#innerparstack > -1 ) {
310: $decls= $parstack[$#parstack].$innerparstack[$#innerparstack];
311: } else {
312: $decls= $parstack[$#parstack];
313: }
314: } else {
315: if ( $#innerparstack > -1 ) {
316: $decls=$innerparstack[$#innerparstack];
317: } else {
318: $decls='';
319: }
320: }
321: $output .= &Apache::run::evaluate($partstring,$safeeval,$decls);
322: $partstring = '';
323: }
324: if ($tokenpat->[0] eq 'E') { pop @innerstack;pop @innerparstack;
325: &decreasedepth($tokenpat);}
326: }
327: pop @pat;
328: pop @Apache::lonxml::pwd;
329: }
330: return $output;
331: }
332:
333: sub callsub {
334: my ($sub,$target,$token,$parstack,$parser,$safeeval,$style)=@_;
335: my $currentstring='';
336: my $nodefault;
337: {
338: my $sub1;
339: no strict 'refs';
340: if ($target eq 'edit' && $token->[0] eq 'S') {
341: $currentstring = &Apache::edit::tag_start($target,$token,$parstack,$parser,
342: $safeeval,$style);
343: }
344: my $tag=$token->[1];
345: my $space=$Apache::lonxml::alltags{$tag};
346: if (!$space) {
347: $tag=~tr/A-Z/a-z/;
348: $sub=~tr/A-Z/a-z/;
349: $space=$Apache::lonxml::alltags{$tag}
350: }
351: if ($space) {
352: #&Apache::lonxml::debug("Calling sub $sub in $space $metamode<br />\n");
353: $sub1="$space\:\:$sub";
354: $Apache::lonxml::curdepth=join('_',@Apache::lonxml::depthcounter);
355: ($currentstring,$nodefault) = &$sub1($target,$token,$parstack,$parser,
356: $safeeval,$style);
357: } else {
358: #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode<br />\n");
359: if ($metamode <1) {
360: if (defined($token->[4]) && ($metamode < 1)) {
361: $currentstring = $token->[4];
362: } else {
363: $currentstring = $token->[2];
364: }
365: }
366: }
367: &Apache::lonxml::debug("nodefalt:$nodefault:");
368: if ($currentstring eq '' && $nodefault eq '') {
369: if ($target eq 'edit') {
370: &Apache::lonxml::debug("doing default edit for $token->[1]");
371: if ($token->[0] eq 'S') {
372: $currentstring = &Apache::edit::tag_start($target,$token);
373: } elsif ($token->[0] eq 'E') {
374: $currentstring = &Apache::edit::tag_end($target,$token);
375: }
376: } elsif ($target eq 'modified') {
377: if ($token->[0] eq 'S') {
378: $currentstring = $token->[4];
379: } else {
380: $currentstring = $token->[2];
381: }
382: }
383: }
384: use strict 'refs';
385: }
386: return $currentstring;
387: }
388:
389: sub startredirection {
390: $Apache::lonxml::redirection++;
391: push (@Apache::lonxml::outputstack, '');
392: }
393:
394: sub endredirection {
395: if (!$Apache::lonxml::redirection) {
396: &Apache::lonxml::error("Endredirection was called, before a startredirection, perhaps you have unbalanced tags. Some debuging information:".join ":",caller);
397: return '';
398: }
399: $Apache::lonxml::redirection--;
400: pop @Apache::lonxml::outputstack;
401: }
402:
403: sub initdepth {
404: @Apache::lonxml::depthcounter=();
405: $Apache::lonxml::depth=-1;
406: $Apache::lonxml::olddepth=-1;
407: }
408:
409: sub increasedepth {
410: my ($token) = @_;
411: $Apache::lonxml::depth++;
412: $Apache::lonxml::depthcounter[$Apache::lonxml::depth]++;
413: if ($Apache::lonxml::depthcounter[$Apache::lonxml::depth]==1) {
414: $Apache::lonxml::olddepth=$Apache::lonxml::depth;
415: }
416: my $curdepth=join('_',@Apache::lonxml::depthcounter);
417: &Apache::lonxml::debug("s $Apache::lonxml::depth : $Apache::lonxml::olddepth : $curdepth : $token->[1]\n");
418: #print "<br />s $Apache::lonxml::depth : $Apache::lonxml::olddepth : $curdepth : $token->[1]\n";
419: }
420:
421: sub decreasedepth {
422: my ($token) = @_;
423: $Apache::lonxml::depth--;
424: if ($Apache::lonxml::depth<$Apache::lonxml::olddepth-1) {
425: $#Apache::lonxml::depthcounter--;
426: $Apache::lonxml::olddepth=$Apache::lonxml::depth+1;
427: }
428: if ( $Apache::lonxml::depth < -1) {
429: &Apache::lonxml::warning("Unbalanced tags in resource");
430: $Apache::lonxml::depth='-1';
431: }
432: my $curdepth=join('_',@Apache::lonxml::depthcounter);
433: &Apache::lonxml::debug("e $Apache::lonxml::depth : $Apache::lonxml::olddepth : $token->[1] : $curdepth\n");
434: #print "<br />e $Apache::lonxml::depth : $Apache::lonxml::olddepth : $token->[1] : $curdepth\n";
435: }
436:
437: sub get_all_text {
438:
439: my($tag,$pars)= @_;
440: my $depth=0;
441: my $token;
442: my $result='';
443: if ( $tag =~ m:^/: ) {
444: my $tag=substr($tag,1);
445: # &Apache::lonxml::debug("have:$tag:");
446: while (($depth >=0) && ($token = $pars->get_token)) {
447: # &Apache::lonxml::debug("e token:$token->[0]:$depth:$token->[1]");
448: if (($token->[0] eq 'T')||($token->[0] eq 'C')||($token->[0] eq 'D')) {
449: $result.=$token->[1];
450: } elsif ($token->[0] eq 'PI') {
451: $result.=$token->[2];
452: } elsif ($token->[0] eq 'S') {
453: if ($token->[1] eq $tag) { $depth++; }
454: $result.=$token->[4];
455: } elsif ($token->[0] eq 'E') {
456: if ( $token->[1] eq $tag) { $depth--; }
457: #skip sending back the last end tag
458: if ($depth > -1) { $result.=$token->[2]; } else {
459: $pars->unget_token($token);
460: }
461: }
462: }
463: } else {
464: while ($token = $pars->get_token) {
465: # &Apache::lonxml::debug("s token:$token->[0]:$depth:$token->[1]");
466: if (($token->[0] eq 'T')||($token->[0] eq 'C')||($token->[0] eq 'D')) {
467: $result.=$token->[1];
468: } elsif ($token->[0] eq 'PI') {
469: $result.=$token->[2];
470: } elsif ($token->[0] eq 'S') {
471: if ( $token->[1] eq $tag) {
472: $pars->unget_token($token); last;
473: } else {
474: $result.=$token->[4];
475: }
476: } elsif ($token->[0] eq 'E') {
477: $result.=$token->[2];
478: }
479: }
480: }
481: # &Apache::lonxml::debug("Exit:$result:");
482: return $result
483: }
484:
485: sub newparser {
486: my ($parser,$contentref,$dir) = @_;
487: push (@$parser,HTML::TokeParser->new($contentref));
488: $$parser['-1']->xml_mode('1');
489: if ( $dir eq '' ) {
490: push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]);
491: } else {
492: push (@Apache::lonxml::pwd, $dir);
493: }
494: # &Apache::lonxml::debug("pwd:$#Apache::lonxml::pwd");
495: # &Apache::lonxml::debug("pwd:$Apache::lonxml::pwd[$#Apache::lonxml::pwd]");
496: }
497:
498: sub parstring {
499: my ($token) = @_;
500: my $temp='';
501: map {
502: unless ($_=~/\W/) {
503: my $val=$token->[2]->{$_};
504: $val =~ s/([\%\@\\])/\\$1/g;
505: #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }
506: $temp .= "my \$$_=\"$val\";"
507: }
508: } @{$token->[3]};
509: return $temp;
510: }
511:
512: sub writeallows {
513: my $thisurl='/res/'.&Apache::lonnet::declutter(shift);
514: my $thisdir=$thisurl;
515: $thisdir=~s/\/[^\/]+$//;
516: my %httpref=();
517: map {
518: $httpref{'httpref.'.
519: &Apache::lonnet::hreflocation($thisdir,$_)}=$thisurl; } @extlinks;
520: &Apache::lonnet::appenv(%httpref);
521: }
522:
523: #
524: # Afterburner handles anchors, highlights and links
525: #
526: sub afterburn {
527: my $result=shift;
528: map {
529: my ($name, $value) = split(/=/,$_);
530: $value =~ tr/+/ /;
531: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
532: if (($name eq 'highlight')||($name eq 'anchor')||($name eq 'link')) {
533: unless ($ENV{'form.'.$name}) {
534: $ENV{'form.'.$name}=$value;
535: }
536: }
537: } (split(/&/,$ENV{'QUERY_STRING'}));
538: if ($ENV{'form.highlight'}) {
539: map {
540: my $anchorname=$_;
541: my $matchthis=$anchorname;
542: $matchthis=~s/\_+/\\s\+/g;
543: $result=~s/($matchthis)/\<font color=\"red\"\>$1\<\/font\>/gs;
544: } split(/\,/,$ENV{'form.highlight'});
545: }
546: if ($ENV{'form.link'}) {
547: map {
548: my ($anchorname,$linkurl)=split(/\>/,$_);
549: my $matchthis=$anchorname;
550: $matchthis=~s/\_+/\\s\+/g;
551: $result=~s/($matchthis)/\<a href=\"$linkurl\"\>$1\<\/a\>/gs;
552: } split(/\,/,$ENV{'form.link'});
553: }
554: if ($ENV{'form.anchor'}) {
555: my $anchorname=$ENV{'form.anchor'};
556: my $matchthis=$anchorname;
557: $matchthis=~s/\_+/\\s\+/g;
558: $result=~s/($matchthis)/\<a name=\"$anchorname\"\>$1\<\/a\>/s;
559: $result.=(<<"ENDSCRIPT");
560: <script>
561: document.location.hash='$anchorname';
562: </script>
563: ENDSCRIPT
564: }
565: return $result;
566: }
567:
568: sub handler {
569: my $request=shift;
570:
571: my $target='web';
572:
573: $Apache::lonxml::debug=0;
574:
575: if ($ENV{'browser.mathml'}) {
576: $request->content_type('text/xml');
577: } else {
578: $request->content_type('text/html');
579: }
580:
581: # $request->print(<<ENDHEADER);
582: #<html>
583: #<head>
584: #<title>Just test</title>
585: #</head>
586: #<body bgcolor="#FFFFFF">
587: #ENDHEADER
588: # &Apache::lonhomework::send_header($request);
589: $request->send_http_header;
590:
591: return OK if $request->header_only;
592:
593:
594: my $file=&Apache::lonnet::filelocation("",$request->uri);
595: my %mystyle;
596: my $result = '';
597: my $filecontents=&Apache::lonnet::getfile($file);
598: if ($filecontents == -1) {
599: &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
600: $filecontents='';
601: } else {
602: $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle);
603: }
604:
605: $request->print($result);
606:
607: writeallows($request->uri);
608: return OK;
609: }
610:
611: sub debug {
612: if ($Apache::lonxml::debug eq 1) {
613: print "DEBUG:".$_[0]."<br />\n";
614: }
615: }
616:
617: sub error {
618: if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {
619: print "<b>ERROR:</b>".$_[0]."<br />\n";
620: } else {
621: print "<b>An Error occured while processing this resource. The instructor has been notified.</b> <br />";
622: #notify author
623: &Apache::lonmsg::author_res_msg($ENV{'request.filename'},$_[0]);
624: #notify course
625: if ( $ENV{'request.course.id'} ) {
626: my $users=$ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'};
627: foreach my $user (split /\,/, $users) {
628: ($user,my $domain) = split /:/, $user;
629: &Apache::lonmsg::user_normal_msg($user,$domain,"Error in $ENV{'request.filename'}",$_[0]);
630: }
631: }
632:
633: #FIXME probably shouldn't have me get everything forever.
634: &Apache::lonmsg::user_normal_msg('albertel','msu',"Error in $ENV{'request.filename'}",$_[0]);
635: #&Apache::lonmsg::user_normal_msg('albertel','103',"Error in $ENV{'request.filename'}",$_[0]);
636: }
637: }
638:
639: sub warning {
640: if ($ENV{'request.state'} eq 'construct') {
641: print "<b>W</b>ARNING<b>:</b>".$_[0]."<br />\n";
642: }
643: }
644:
645: sub register_insert {
646: my @data = split /\n/, &Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/insertlist.tab');
647: my $i;
648: my @order;
649: for ($i=0;$i < $#data; $i++) {
650: my $line = $data[$i];
651: if ( $line =~ /^\#/ || $line =~ /^\s*\n/) { next; }
652: if ( $line =~ /TABLE/ ) { last; }
653: my ($tag,$descrip,$function,$show) = split(/,/, $line);
654: if ($show eq 'no') { next; }
655: $insertlist{"$tag.description"} = $descrip;
656: $insertlist{"$tag.function"} = $function;
657: push (@order,$tag);
658: }
659: for (;$i < $#data;$i++) {
660: my $line = $data[$i];
661: my ($tag,@which) = split(/ +/,$line);
662: for (my $j=0;$j <$#which;$j++) {
663: if ( $which[$j] eq 'Y' ) {
664: push(@{ $insertlist{"$tag.which"} },$order[$j]);
665: }
666: }
667: }
668: }
669: 1;
670: __END__
671:
672:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>