Annotation of loncom/interface/lonprintout.pm, revision 1.57
1.1 www 1: # The LearningOnline Network
2: # Printout
3: #
1.57 ! sakharuk 4: # $Id: lonprintout.pm,v 1.56 2002/09/06 17:46:13 sakharuk Exp $
1.11 albertel 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.1 www 28: # (Internal Server Error Handler
29: #
30: # (Login Screen
31: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
32: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
33: #
34: # 3/1/1 Gerd Kortemeyer)
35: #
36: # 3/1 Gerd Kortemeyer
37: #
1.3 sakharuk 38: # 9/17 Alex Sakharuk
39: #
1.1 www 40: package Apache::lonprintout;
41:
42: use strict;
1.10 albertel 43: use Apache::Constants qw(:common :http);
1.2 sakharuk 44: use Apache::lonxml;
45: use Apache::lonnet;
1.54 sakharuk 46: use Apache::loncommon;
1.13 sakharuk 47: use Apache::inputtags;
1.54 sakharuk 48: use Apache::grades;
1.13 sakharuk 49: use Apache::edit;
1.5 sakharuk 50: use Apache::File();
1.34 sakharuk 51: use POSIX qw(strftime);
1.3 sakharuk 52:
53:
54: sub headerform {
1.1 www 55: my $r = shift;
1.3 sakharuk 56: $r->print(<<ENDHEADER);
57: <html>
58: <head>
59: <title>LON-CAPA output for printing</title>
60: </head>
61: <body bgcolor="FFFFFF">
62: <form method="post" enctype="multipart/form-data" action="/adm/printout" name="printform">
1.38 www 63: <tt>$ENV{'form.postdata'}</tt><p>
1.3 sakharuk 64: ENDHEADER
65: }
66:
1.1 www 67:
1.3 sakharuk 68: sub menu_for_output {
69: my $r = shift;
1.28 sakharuk 70: $r->print(<<ENDMENUOUT1);
1.57 ! sakharuk 71: <h1>What do you want to print? Make a choice.</h1><br />
1.3 sakharuk 72: <input type="hidden" name="phase" value="two">
1.10 albertel 73: <input type="hidden" name="url" value="$ENV{'form.postdata'}">
1.25 sakharuk 74: <input type="radio" name="choice" value="Standard LaTeX output for current document" checked> Current document
1.16 sakharuk 75: (you will print what you see on the screen)<br />
1.39 sakharuk 76: ENDMENUOUT1
1.48 sakharuk 77: if ((not $ENV{'request.role'}=~m/^au\./) and (not $ENV{'request.role'}=~m/^ca\./)) {
1.52 sakharuk 78: $r->print(<<ENDMENUOUT2);
1.19 sakharuk 79: <input type="radio" name="choice" value="Standard LaTeX output for the primary sequence"> All problems from the primary sequence<br />
1.20 sakharuk 80: <input type="radio" name="choice" value="Standard LaTeX output for whole primary sequence"> The whole primary sequence (problems plus all html and xml files)<br />
1.19 sakharuk 81: <input type="radio" name="choice" value="Standard LaTeX output for the top level sequence"> All problems from the top level sequence<br />
1.28 sakharuk 82: <br />
83: ENDMENUOUT2
1.44 sakharuk 84: }
1.52 sakharuk 85: if ($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) {
86: $r->print(<<ENDMENUOUT6);
1.55 sakharuk 87: <input type="radio" name="choice" value="All class print"> Print assignment (all problems from the primary sequence) for group of students<br /><br />
1.52 sakharuk 88: ENDMENUOUT6
89: }
1.39 sakharuk 90: my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'});
91: $subdirtoprint =~ s/\/[^\/]+$//;
92: if (&Apache::lonnet::allowed('bre',$subdirtoprint) eq 'F') {
93: $r->print(<<ENDMENUOUT4);
94: <input type="radio" name="choice" value="Subdirectory print"> All problems from current subdirectory (where this particular problem is)<br />
95: ENDMENUOUT4
96: }
97: $r->print(<<ENDMENUOUT5);
1.16 sakharuk 98: <br /><hr /><br />
99: <h1>And what page format do you prefer?</h1>
1.36 sakharuk 100: <table>
101: <tr>
102: <td>
103: <input type="radio" name="layout" value="CBI"> Landscape <br />
104: <input type="radio" name="layout" value="CAPA" checked> Portrait <br />
105: </td>
106: <td> </td>
107: <td rawspan="2">
1.44 sakharuk 108: Number of columns: <select name="numberofcolumns">
109: <option selected> 1 </option>
110: <option> 2 </option>
111: </select>
1.36 sakharuk 112: </td>
113: </tr>
114: </table>
115: </br>
1.16 sakharuk 116: <input type="submit" value="Submit your choice">
1.52 sakharuk 117: ENDMENUOUT5
118: }
119:
120:
121: sub additional_class_menu {
122: my $r = shift;
123: $r->print(<<ENDMENUOUT1);
124: <input type="hidden" name="url" value="$ENV{'form.url'}">
125: <input type="hidden" name="choice" value="$ENV{'form.choice'}">
126: <input type="hidden" name="layout" value="$ENV{'form.layout'}">
127: <input type="hidden" name="numberofcolumns" value="$ENV{'form.numberofcolumns'}">
128: <h1>Mark students which assignments you want to print</h1>
129: ENDMENUOUT1
1.57 ! sakharuk 130: my %courselist=&Apache::lonnet::dump(
! 131: 'classlist',
! 132: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
! 133: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
! 134: my $now=time;
! 135: $r->print(<<ENDDISHEADER);
! 136: <input type=hidden name=sendmode value=group>
! 137: <script>
! 138: function checkall() {
! 139: for (i=0; i<document.forms.printform.elements.length; i++) {
! 140: if
! 141: (document.forms.printform.elements[i].name.indexOf('whomtoprint')==0) {
! 142: document.forms.printform.elements[i].checked=true;
! 143: }
! 144: }
! 145: }
! 146:
! 147: function checksec() {
! 148: for (i=0; i<document.forms.printform.elements.length; i++) {
! 149: if
! 150: (document.forms.printform.elements[i].value.indexOf
! 151: (document.forms.printform.chksec.value)==0) {
! 152: document.forms.printform.elements[i].checked=true;
! 153: }
! 154: }
! 155: }
! 156:
! 157: function uncheckall() {
! 158: for (i=0; i<document.forms.printform.elements.length; i++) {
! 159: if
! 160: (document.forms.printform.elements[i].name.indexOf('whomtoprint')==0) {
! 161: document.forms.printform.elements[i].checked=false;
! 162: }
! 163: }
1.52 sakharuk 164: }
1.57 ! sakharuk 165: </script>
! 166: <input type=button onClick="checkall()" value="Check for All">
! 167: <input type=button onClick="checksec()" value="Check for Section/Group">
! 168: <input type=text size=5 name=chksec>
! 169: <input type=button onClick="uncheckall()" value="Check for None">
! 170: <p>
! 171: ENDDISHEADER
1.54 sakharuk 172: my $i = 0;
1.57 ! sakharuk 173: foreach (sort keys %courselist) {
! 174: my ($end,$start)=split(/\:/,$courselist{$_});
! 175: my $active=1;
! 176: if (($end) && ($now>$end)) { $active=0; }
! 177: if ($active) {
! 178: my ($sname,$sdom)=split(/\:/,$_);
! 179: my %reply=&Apache::lonnet::get('environment',
! 180: ['firstname','middlename','lastname','generation'],
! 181: $sdom,$sname);
! 182: my $section=&Apache::lonnet::usection
! 183: ($sdom,$sname,$ENV{'request.course.id'});
! 184: $r->print(
! 185: '<br /><input type=checkbox name="whomtoprint'.$i.'" value="'.$section.':'.$_.'"> '.
! 186: $reply{'firstname'}.' '.
! 187: $reply{'middlename'}.' '.
! 188: $reply{'lastname'}.' '.
! 189: $reply{'generation'}.
! 190: ' ('.$_.') '.$section);
! 191: $i++;
! 192: }
1.52 sakharuk 193: }
194: $r->print(<<ENDMENUOUT2);
1.57 ! sakharuk 195: <br />
1.54 sakharuk 196: <input type="hidden" name="numberofstudents" value="$i">
1.52 sakharuk 197: <input type="hidden" name="phase" value="three">
198: <input type="submit" value="Submit">
199: ENDMENUOUT2
200: }
201:
202:
203: sub additional_print_menu {
204: my $r = shift;
1.54 sakharuk 205: my $what_to_print = '';
206: for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) {
207: $what_to_print .= '<input type="hidden" name="whomtoprint'.$i.'" value="'.$ENV{'form.whomtoprint'.$i}.'">';
208: }
1.52 sakharuk 209: $r->print(<<ENDMENUOUT);
1.54 sakharuk 210: $what_to_print
1.52 sakharuk 211: <input type="hidden" name="url" value="$ENV{'form.url'}">
212: <input type="hidden" name="choice" value="$ENV{'form.choice'}">
213: <input type="hidden" name="layout" value="$ENV{'form.layout'}">
1.54 sakharuk 214: <input type="hidden" name="numberofstudents" value="$ENV{'form.numberofstudents'}">
1.52 sakharuk 215: <input type="hidden" name="numberofcolumns" value="$ENV{'form.numberofcolumns'}">
1.57 ! sakharuk 216: Define page layout parameters: <br />
! 217: <b>Width</b>: <input type="text" name="width" width="8" value="9cm"> <br />
! 218: <b>Height</b>: <input type="text" name="height" width="8" value="25.9cm"> <br />
! 219: <b>Left margin</b>: <input type="text" name="leftmargin" width="8" value="-0.57in"> <br />
1.52 sakharuk 220: <input type="hidden" name="phase" value="four">
221: <input type="submit" value="Submit">
1.3 sakharuk 222: </form>
223: </body>
224: </html>
1.52 sakharuk 225: ENDMENUOUT
1.3 sakharuk 226: }
1.2 sakharuk 227:
228:
1.3 sakharuk 229: sub output_data {
230: my $r = shift;
231: $r->print(<<ENDPART);
232: <html>
233: <head>
234: <title>LON-CAPA output for printing</title>
235: </head>
236: <body bgcolor="FFFFFF">
237: <hr>
238: ENDPART
1.2 sakharuk 239:
1.3 sakharuk 240: my $choice = $ENV{'form.choice'};
1.16 sakharuk 241: my $layout = $ENV{'form.layout'};
1.36 sakharuk 242: my $numberofcolumns = $ENV{'form.numberofcolumns'};
1.16 sakharuk 243: my $laystyle = 'book';
1.2 sakharuk 244: my $result = '';
1.34 sakharuk 245: my $number_of_columns = 1;
1.36 sakharuk 246:
1.3 sakharuk 247: if ($choice eq 'Standard LaTeX output for current document') {
1.36 sakharuk 248: #-- single document - problem, page, html, xml
1.14 albertel 249: my %moreenv;
250: $moreenv{'form.grade_target'}='tex';
1.48 sakharuk 251: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
252: $ENV{'form.url'}=~s/http:\/\/[^\/]+//;
253: }
1.14 albertel 254: $moreenv{'request.filename'}=$ENV{'form.url'};
255: &Apache::lonnet::appenv(%moreenv);
256: my $texversion=&Apache::lonnet::ssi($ENV{'form.url'});
257: &Apache::lonnet::delenv('form.grade_target');
258: $result .= $texversion;
1.29 sakharuk 259: $result = &additional_cleanup($result);
1.40 sakharuk 260: if ($ENV{'form.url'}=~m/\.page\s*$/) {
261: ($result,$number_of_columns) = &page_cleanup($result);
262: }
263: } elsif ($choice eq 'Standard LaTeX output for the primary sequence' or
264: $choice eq 'Standard LaTeX output for whole primary sequence') {
1.36 sakharuk 265: #-- minimal sequence to which the current document belongs
266: #-- where is the primary sequence containing file?
1.18 sakharuk 267: my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});
268: $_ = $symbolic;
269: m/([^_]+)_/;
270: my $primary_sequence = '/res/'.$1;
1.36 sakharuk 271: #-- open and analyses the primary sequence
1.18 sakharuk 272: my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence);
273: my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file);
274: my @master_seq = &content_map($sequencefilecontents);
1.36 sakharuk 275: #-- produce an output string
1.18 sakharuk 276: for (my $i=0;$i<=$#master_seq;$i++) {
277: $_ = $master_seq[$i];
278: m/\"(.*)\"/;
279: $_ = $1;
1.36 sakharuk 280: my $urlp = $1;
1.20 sakharuk 281: if ($choice eq 'Standard LaTeX output for the primary sequence') {
1.36 sakharuk 282: if ($urlp =~ m/\.(problem|exam|quiz|assess|survey|form|library)/) {
1.20 sakharuk 283: my %moreenv;
284: $moreenv{'form.grade_target'}='tex';
285: &Apache::lonnet::appenv(%moreenv);
286: my $texversion=&Apache::lonnet::ssi($urlp);
287: &Apache::lonnet::delenv('form.grade_target');
288: $result .= $texversion;
289: }
1.53 albertel 290: } elsif ($urlp =~ /\S+/) {
1.36 sakharuk 291: my %moreenv;
1.18 sakharuk 292: $moreenv{'form.grade_target'}='tex';
293: &Apache::lonnet::appenv(%moreenv);
294: my $texversion=&Apache::lonnet::ssi($urlp);
295: &Apache::lonnet::delenv('form.grade_target');
1.20 sakharuk 296: $result .= $texversion;
1.16 sakharuk 297: }
1.28 sakharuk 298: }
299: $result = &additional_cleanup($result);
1.13 sakharuk 300: } elsif ($choice eq 'Standard LaTeX output for the top level sequence') {
1.47 sakharuk 301: # where is the main sequence of the course?
1.13 sakharuk 302: my $main_seq = '/res/'.$ENV{'request.course.uri'};
303: my $file=&Apache::lonnet::filelocation("",$main_seq);
304: my $filecontents=&Apache::lonnet::getfile($file);
305: my @file_seq = &content_map($filecontents);
1.48 sakharuk 306: for (my $iu=0;$iu<=$#file_seq;$iu++) {
307: $file_seq[$iu]=~s/^"//;
308: $file_seq[$iu]=~s/"$//;
1.49 sakharuk 309: if ($file_seq[$iu]=~m/\S+/) {
310: $file_seq[$iu]=&Apache::lonnet::filelocation("",$file_seq[$iu]);
311: } else {
312: $file_seq[$iu]= 'REMOVE IT PLEASE';
313: }
1.48 sakharuk 314: }
315: my $i=0;
1.49 sakharuk 316: my $limit = $#file_seq;
317: while ($i<=$limit) {
1.48 sakharuk 318: unless ($file_seq[$i]=~m/\.(problem|page)/) {
319: if ($file_seq[$i]=~m/\.sequence/) {
320: my $filecontents=&Apache::lonnet::getfile($file_seq[$i]);
321: my @newfile_seq = &content_map($filecontents);
1.49 sakharuk 322: for (my $iu=0;$iu<=$#newfile_seq;$iu++) {
323: $newfile_seq[$iu]=~s/^"//;
324: $newfile_seq[$iu]=~s/"$//;
325: if ($newfile_seq[$iu]=~m/\S+/) {
326: $newfile_seq[$iu]=&Apache::lonnet::filelocation("",$newfile_seq[$iu]);
327: } else {
328: $newfile_seq[$iu]= 'REMOVE IT PLEASE';
329: }
330: }
331: splice @file_seq,$i,1,@newfile_seq;
332: $i=0;
333: $limit = $#file_seq;
1.48 sakharuk 334: } else {
1.49 sakharuk 335: splice @file_seq,$i,1,'REMOVE IT PLEASE';
1.48 sakharuk 336: }
337: }
338: $i++;
339: }
340: for (my $iu=0;$iu<=$#file_seq;$iu++) {
1.49 sakharuk 341: if ($file_seq[$iu]=~m/REMOVE IT PLEASE/) {
342: splice @file_seq,$iu,1;
343: }
344: }
345: if ($file_seq[-1]=~m/REMOVE IT PLEASE/) {
346: pop @file_seq;
1.48 sakharuk 347: }
1.52 sakharuk 348: #-- produce an output string
1.49 sakharuk 349: for (my $i=0;$i<=$#file_seq;$i++) {
350: my $urlp = $file_seq[$i];
351: $urlp=~s/\/home\/httpd\/html//;
352: if ($urlp=~m/\.(problem|exam|quiz|assess|survey|form|library)/) {
353: my %moreenv;
354: $moreenv{'form.grade_target'}='tex';
355: &Apache::lonnet::appenv(%moreenv);
356: my $texversion=&Apache::lonnet::ssi($urlp);
357: &Apache::lonnet::delenv('form.grade_target');
358: $result .= $texversion;
359: }
360: }
361: $result = &additional_cleanup($result);
1.52 sakharuk 362: } elsif ($choice eq 'All class print') {
1.54 sakharuk 363: #-- prints assignments for whole class or for selected students
364: my (@students,@st_output) = ((),());
365: for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) {
366: if ($ENV{'form.whomtoprint'.$i}=~/:/) {
367: push @students,$ENV{'form.whomtoprint'.$i};
368: }
369: }
370: #where is the primary sequence containing current resource (the same for all students)?
371: my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});
372: $symbolic =~ m/([^_]+)_/;
373: my $primary_sequence = '/res/'.$1;
374: #opens and analyses the primary sequence file, produces the array of resources
375: my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence);
376: my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file);
377: my @master_seq = &content_map($sequencefilecontents);
378: #loop over students
379: foreach my $person (@students) {
380: my $current_output = '';
1.57 ! sakharuk 381: my ($usersection,$username,$userdomain) = split /:/,$person;
1.54 sakharuk 382: my $fullname = &Apache::grades::get_fullname($username,$userdomain);
383: #goes through all resources, checks if they are available for current student, and produces output
384: foreach my $curres (@master_seq) {
385: $curres =~ s/^"//;
386: $curres =~ s/"$//;
387: if ($curres=~/\w+/) {
388: my $symb = &Apache::lonnet::symbread($curres);
389: my ($map,$id,$res_url) = split(/___/,$symb);
390: if (&Apache::lonnet::allowed('bre',$res_url)) {
391: my $rendered = &Apache::loncommon::get_student_view($symb,$username,$userdomain,
392: $ENV{'request.course.id'},'tex');
393: $current_output .= $rendered;
394: }
395: }
396: }
397: $current_output =~ s/\\begin{document}/\\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$fullname}}\\hskip 1\.4in } \\vskip 5 mm /;
398: $result .= $current_output;
399: }
400:
401: $result = &additional_cleanup($result);
402:
403:
404:
1.52 sakharuk 405:
406:
407:
1.31 sakharuk 408: } elsif ($choice eq 'Subdirectory print') {
409: my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'});
410: $subdirtoprint =~ s/\/[^\/]+$//;
411: my @list_of_files = ();
1.48 sakharuk 412: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
1.45 sakharuk 413: $subdirtoprint =~ s/^[^~]*~(\w+)\//\/home\/$1\/public_html\//;
414: } else {
415: $subdirtoprint =~ s/.*(\/res\/)/$1/;
416: }
1.46 sakharuk 417: my @content_directory = ();
1.48 sakharuk 418: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
1.46 sakharuk 419: @content_directory = &Apache::lonnet::dirlist($subdirtoprint,$ENV{'user.domain'}, $ENV{'user.name'},'');
1.45 sakharuk 420: } else {
1.46 sakharuk 421: @content_directory = &Apache::lonnet::dirlist($subdirtoprint);
422: }
423: for (my $iy=0;$iy<=$#content_directory;$iy++) {
424: my @tempo_array = split(/&/,$content_directory[$iy]);
425: if ($tempo_array[0] =~ m/^[^\.]+\.(problem|exam|quiz|assess|survey|form|library)$/) {
426: push(@list_of_files,$tempo_array[0]);
1.28 sakharuk 427: }
1.13 sakharuk 428: }
1.45 sakharuk 429: $subdirtoprint =~ s/\/$//;
1.31 sakharuk 430: for (my $i=0;$i<=$#list_of_files;$i++) {
1.45 sakharuk 431: my $urlp = $subdirtoprint.'/'.$list_of_files[$i];
1.31 sakharuk 432: my %moreenv;
433: $moreenv{'form.grade_target'}='tex';
434: &Apache::lonnet::appenv(%moreenv);
1.48 sakharuk 435: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
436: $urlp =~ s/\/home\/([^\/]*)\/public_html/\/~$1/;
437: }
1.31 sakharuk 438: my $texversion=&Apache::lonnet::ssi($urlp);
439: &Apache::lonnet::delenv('form.grade_target');
440: $texversion =~ s/(\\begin{document})/$1 {\\tiny\\begin{verbatim}$urlp\\end{verbatim}}/;
441: $result .= $texversion;
442: }
443: $result = &additional_cleanup($result);
444:
1.51 sakharuk 445:
1.7 sakharuk 446: }
1.16 sakharuk 447: #-- corrections for the different page formats
1.36 sakharuk 448: if ($layout eq 'CBI' and $numberofcolumns eq '1') {
449: } elsif ($layout eq 'CBI' and $numberofcolumns eq '2') {
1.16 sakharuk 450: $result =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{-40pt}\\setlength{\\evensidemargin}{-60pt}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{4\.4in}\\setlength{\\textheight}{6\.8in}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt} \\begin{document}/;
451: $laystyle = 'album';
452: } elsif ($layout eq 'CAPA') {
453: my $courseidinfo = $ENV{'request.role'};
454: $_ = $courseidinfo;
455: m/.*\/(.*)/;
456: $courseidinfo = $ENV{'course.physnet_'.$1.'.description'};
1.34 sakharuk 457: # $result =~ s/\\documentclass\[letterpaper\]{article}/\\documentclass\[twocolumn\]{article}/;
458: $result =~ s/\\documentclass\[letterpaper\]{article}/\\documentclass{article}/;
1.56 sakharuk 459: if ($choice ne 'All class print') {
460: $result =~ s/\\begin{document}/\\textheight 25\.9cm\\oddsidemargin = -0\.57in\\evensidemargin = -0\.57in\\textwidth= 9cm\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}}}\\hskip 1\.4in $courseidinfo} \\vskip 5 mm /;
461: } else {
462: $result =~ s/\\begin{document}/\\textheight 25\.9cm\\oddsidemargin = -0\.57in\\evensidemargin = -0\.57in\\textwidth= 9cm\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1} \\vskip 5 mm /;
463: }
1.27 sakharuk 464: $result =~ s/\\includegraphics{/\\includegraphics\[width=9\.0 cm\]{/g;
1.37 sakharuk 465: # $result =~ s/\\includegraphics{/\\includegraphics\[width=\\textwidth\]{/g;
466: # $result =~ s/(\\end{document})/\\newline\\noindent\\makebox\[9.0cm\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Dept\. of Physics and Astronomy, MSU\\makebox\[1.5cm\]\[b\]{\\hfill}LON-CAPA\\copyright MSU GNU\/GPL $1/;
1.50 albertel 467: $result =~ s/(\\end{document})/\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny \\makebox\[1.5cm\]\[b\]{\\hfill}LON-CAPA\\copyright Michigan State University Board of Trustees $1/;
1.37 sakharuk 468: # $result =~ s/(\\end{longtable}\s*)(\\newline\\noindent\\makebox\[9\.0cm\]\[b\]{\\hrulefill})/$2$1/g;
469: $result =~ s/(\\end{longtable}\s*)(\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g;
1.34 sakharuk 470: $result =~ s/(\\end{longtable}\s*)\\newline/$1/g;
1.37 sakharuk 471: $result =~ s/\$number_of_columns/$number_of_columns/g;
1.16 sakharuk 472: }
1.52 sakharuk 473: #changes page's parameters for the one column output
474: if ($ENV{'form.numberofcolumns'} == 1) {
475: $result =~ s/\\textwidth= 9cm/\\textwidth= $ENV{'form.width'}/;
476: }
1.23 sakharuk 477: #-- LaTeX corrections
478: my $first_comment = index($result,'<!--',0);
479: while ($first_comment != -1) {
480: my $end_comment = index($result,'-->',$first_comment);
481: substr($result,$first_comment,$end_comment-$first_comment+3) = '';
482: $first_comment = index($result,'<!--',$first_comment);
483: }
1.17 sakharuk 484: $result =~ s/^\s+$//gm; #remove empty lines
1.20 sakharuk 485: $result =~ s/(\s)+/$1/g; #removes more than one empty space
1.23 sakharuk 486: $result =~ s/\\\\\s*\\vskip/\\vskip/gm;
1.24 sakharuk 487: $result =~ s/\\\\\s*\\noindent\s*(\\\\)+/\\\\\\noindent /g;
1.23 sakharuk 488: $result =~ s/{\\par }\s*\\\\/\\\\/gm;
1.24 sakharuk 489: $result =~ s/\\\\\s+\[/ \[/g;
490: $result =~ s/θ/\$\\theta\$/g; #converts theta from html into tex
1.41 sakharuk 491: $result =~ s/\b__+\b/\\makebox\[1 cm\]\[b\]{\\hrulefill}/g;
1.37 sakharuk 492: #conversion of html characters to LaTeX equivalents
493: if ($result =~ m/&(\w+|#\d+);/) {
494: $result = &character_chart($result);
495: }
1.42 sakharuk 496: $result =~ s/(\\end{tabular})\s*\\vskip 0 mm/$1/g;
497: $result =~ s/(\\begin{enumerate})\s*\\noindent/$1/g;
1.7 sakharuk 498: #-- writing .tex file in prtspool
1.16 sakharuk 499: my $temp_file;
1.33 sakharuk 500: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex";
1.16 sakharuk 501: unless ($temp_file = Apache::File->new('>'.$filename)) {
502: $r->log_error("Couldn't open $filename for output $!");
503: return SERVER_ERROR;
504: }
505: print $temp_file $result;
1.3 sakharuk 506: $r->print(<<FINALEND);
1.51 sakharuk 507: <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$filename&$laystyle&$numberofcolumns">
1.3 sakharuk 508: </body>
509: </html>
510: FINALEND
511: }
1.2 sakharuk 512:
1.37 sakharuk 513: sub character_chart {
514: my $result = shift;
1.41 sakharuk 515: $result =~ s/�?0?7;//g;
1.40 sakharuk 516: $result =~ s/�?0?9;//g;
517: $result =~ s/�?10;//g;
518: $result =~ s/�?13;//g;
519: $result =~ s/�?32;/ /g;
520: $result =~ s/�?33;/!/g;
521: $result =~ s/�?34;/"/g;
1.39 sakharuk 522: $result =~ s/"/"/g;
1.40 sakharuk 523: $result =~ s/�?35;/\\#/g;
524: # $result =~ s/�?36;/\\\$/g;
525: $result =~ s/�?37;/\\%/g;
526: $result =~ s/�?38;/\\&/g;
1.37 sakharuk 527: $result =~ s/&/\\&/g;
1.40 sakharuk 528: $result =~ s/�?39;/'/g;
529: $result =~ s/�?40;/(/g;
530: $result =~ s/�?41;/)/g;
531: $result =~ s/�?42;/\*/g;
532: $result =~ s/�?43;/\+/g;
533: $result =~ s/�?44;/,/g;
534: $result =~ s/�?45;/-/g;
535: $result =~ s/�?46;/\./g;
536: $result =~ s/�?47;/\//g;
537: $result =~ s/�?48;/0/g;
538: $result =~ s/�?49;/1/g;
539: $result =~ s/�?50;/2/g;
540: $result =~ s/�?51;/3/g;
541: $result =~ s/�?52;/4/g;
542: $result =~ s/�?53;/5/g;
543: $result =~ s/�?54;/6/g;
544: $result =~ s/�?55;/7/g;
545: $result =~ s/�?56;/8/g;
546: $result =~ s/�?57;/9/g;
547: $result =~ s/�?58;/:/g;
548: $result =~ s/�?59;/;/g;
549: $result =~ s/�?60;/\$<\$/g;
1.37 sakharuk 550: $result =~ s/</\$<\$/g;
1.40 sakharuk 551: $result =~ s/�?61;/\$=\$/g;
552: $result =~ s/�?62;/\$>\$/g;
1.37 sakharuk 553: $result =~ s/>/\$>\$/g;
1.40 sakharuk 554: $result =~ s/�?63;/?/g;
555: # $result =~ s/�?64;//g;
556: $result =~ s/�?65;/A/g;
557: $result =~ s/�?66;/B/g;
558: $result =~ s/�?67;/C/g;
559: $result =~ s/�?68;/D/g;
560: $result =~ s/�?69;/E/g;
561: $result =~ s/�?70;/F/g;
562: $result =~ s/�?71;/G/g;
563: $result =~ s/�?72;/H/g;
564: $result =~ s/�?73;/I/g;
565: $result =~ s/�?74;/J/g;
566: $result =~ s/�?75;/K/g;
567: $result =~ s/�?76;/L/g;
568: $result =~ s/�?77;/M/g;
569: $result =~ s/�?78;/N/g;
570: $result =~ s/�?79;/O/g;
571: $result =~ s/�?80;/P/g;
572: $result =~ s/�?81;/Q/g;
573: $result =~ s/�?82;/R/g;
574: $result =~ s/�?83;/S/g;
575: $result =~ s/�?84;/T/g;
576: $result =~ s/�?85;/U/g;
577: $result =~ s/�?86;/V/g;
578: $result =~ s/�?87;/W/g;
579: $result =~ s/�?88;/X/g;
580: $result =~ s/�?89;/Y/g;
581: $result =~ s/�?90;/Z/g;
582: $result =~ s/�?91;/[/g;
583: $result =~ s/�?92;/\\/g;
584: $result =~ s/�?93;/]/g;
585: # $result =~ s/�?94;//g;
586: # $result =~ s/�?95;//g;
587: $result =~ s/�?96;/`/g;
588: $result =~ s/�?97;/a/g;
589: $result =~ s/�?98;/b/g;
590: $result =~ s/�?99;/c/g;
1.37 sakharuk 591: $result =~ s/d/d/g;
592: $result =~ s/e/e/g;
593: $result =~ s/f/f/g;
594: $result =~ s/g/g/g;
595: $result =~ s/h/h/g;
596: $result =~ s/i/i/g;
597: $result =~ s/j/j/g;
598: $result =~ s/k/k/g;
599: $result =~ s/l/l/g;
600: $result =~ s/m/m/g;
601: $result =~ s/n/n/g;
602: $result =~ s/o/o/g;
603: $result =~ s/p/p/g;
604: $result =~ s/q/q/g;
605: $result =~ s/r/r/g;
606: $result =~ s/s/s/g;
607: $result =~ s/t/t/g;
608: $result =~ s/u/u/g;
609: $result =~ s/v/v/g;
610: $result =~ s/w/w/g;
611: $result =~ s/x/x/g;
612: $result =~ s/y/y/g;
613: $result =~ s/z/z/g;
614: $result =~ s/{/\\{/g;
615: $result =~ s/|/\|/g;
616: $result =~ s/}/\\}/g;
617: $result =~ s/~/\~/g;
618: $result =~ s/‚/,/g;
619: # $result =~ s/ƒ//g;
620: $result =~ s/„/''/g;
621: $result =~ s/…/\$\\ldots\$/g;
622: $result =~ s/†/\$\\dagger\$/g;
623: $result =~ s/‡/\$\\ddagger\$/g;
624: # $result =~ s/ˆ//g;
625: # $result =~ s/‰//g;
626: # $result =~ s/Š//g;
627: $result =~ s/‹/\$<\$/g;
628: # $result =~ s/Œ//g;
629: $result =~ s/‘/`/g;
630: $result =~ s/’/'/g;
631: $result =~ s/“/``/g;
632: $result =~ s/”/''/g;
633: $result =~ s/•/\$\\bullet\$/g;
634: # $result =~ s/–//g;
635: # $result =~ s/—//g;
636: $result =~ s/˜/~/g;
637: # $result =~ s/™//g;
638: # $result =~ s/š//g;
639: $result =~ s/›/\$>\$/g;
640: $result =~ s/œ/\\{\\oe\\}/g;
641: $result =~ s/Ÿ/\\"\\{Y\\}/g;
642: $result =~ s/ //g;
643: $result =~ s/ //g;
644: $result =~ s/¡/!`/g;
645: $result =~ s/¡/!`/g; #`
646: # $result =~ s/¢//g;
647: # $result =~ s/¢//g;
648: $result =~ s/£/\\pounds/g;
649: $result =~ s/£/\\pounds/g;
650: # $result =~ s/¤//g;
651: # $result =~ s/¤//g;
652: # $result =~ s/¥//g;
653: # $result =~ s/¥//g;
654: # $result =~ s/¦//g;
655: # $result =~ s/¦//g;
656: # $result =~ s/§//g;
657: # $result =~ s/§//g;
658: # $result =~ s/¨//g;
659: # $result =~ s/¨//g;
660: $result =~ s/©/\\copyright/g;
661: $result =~ s/©/\\copyright/g;
662: # $result =~ s/ª//g;
663: # $result =~ s/ª//g;
664: # $result =~ s/«//g;
665: # $result =~ s/«//g;
666: $result =~ s/¬/\$\\neg\$/g;
667: $result =~ s/¬/\$\\neg\$/g;
668: # $result =~ s/­//g;
669: # $result =~ s/­//g;
670: # $result =~ s/®//g;
671: # $result =~ s/®//g;
672: # $result =~ s/¯//g;
673: # $result =~ s/¯//g;
1.42 sakharuk 674: $result =~ s/°/\$^{\\circ}\$/g;
675: $result =~ s/°/\$^{\\circ}\$/g;
1.37 sakharuk 676: $result =~ s/±/\$\\pm\$/g;
677: $result =~ s/±/\$\\pm\$/g;
678: $result =~ s/²/\$^2\$/g;
679: $result =~ s/²/\$^2\$/g;
680: $result =~ s/³/\$^3\$/g;
681: $result =~ s/³/\$^3\$/g;
682: # $result =~ s/´//g;
683: # $result =~ s/´//g;
684: $result =~ s/µ/\$\\mu\$/g;
685: $result =~ s/µ/\$\\mu\$/g;
686: $result =~ s/¶/\\P/g;
687: $result =~ s/¶/\\P/g;
688: $result =~ s/·/\$\\cdot\$/g;
689: $result =~ s/·/\$\\cdot\$/g;
690: # $result =~ s/¸//g;
691: # $result =~ s/¸//g;
692: $result =~ s/¹/\$^1\$/g;
693: $result =~ s/¹/\$^1\$/g;
694: # $result =~ s/º//g;
695: # $result =~ s/º//g;
696: # $result =~ s/»//g;
697: # $result =~ s/»//g;
698: # $result =~ s/¼//g;
699: # $result =~ s/¼//g;
700: # $result =~ s/½//g;
701: # $result =~ s/½//g;
702: # $result =~ s/¾//g;
703: # $result =~ s/¾//g;
704: $result =~ s/¿/?`/g;
705: $result =~ s/¿/?`/g;
706: $result =~ s/À/\\`{A}/g;
707: $result =~ s/À/\\`{A}/g;
708: $result =~ s/Á/\\'{A}/g;
709: $result =~ s/Á/\\'{A}/g;
710: $result =~ s/Â/\\^{A}/g;
711: $result =~ s/Â/\\^{A}/g;
712: $result =~ s/Ã/\\~{A}/g;
713: $result =~ s/Ã/\\~{A}/g;
714: $result =~ s/Ä/\\"{A}/g;
715: $result =~ s/Ä/\\"{A}/g;
716: $result =~ s/Å/{\\AA}/g;
717: $result =~ s/Å/{\\AA}/g;
718: $result =~ s/Æ/{\\AE}/g;
719: $result =~ s/Æ/{\\AE}/g;
720: # $result =~ s/Ç//g;
721: # $result =~ s/Ç//g;
722: $result =~ s/È/\\`{E}/g;
723: $result =~ s/È/\\`{E}/g;
724: $result =~ s/É/\\'{E}/g;
725: $result =~ s/É/\\'{E}/g;
726: $result =~ s/Ê/\\^{E}/g;
727: $result =~ s/Ê/\\^{E}/g;
728: $result =~ s/Ë/\\`{E}/g;
729: $result =~ s/Ë/\\`{E}/g;
730: $result =~ s/Ì/\\`{I}/g;
731: $result =~ s/Ì/\\`{I}/g;
732: $result =~ s/Í/\\'{I}/g;
733: $result =~ s/Í/\\'{I}/g;
734: $result =~ s/Î/\\^{I}/g;
735: $result =~ s/Î/\\^{I}/g;
736: $result =~ s/Ï/\\"{I}/g;
737: $result =~ s/Ï/\\"{I}/g;
738: # $result =~ s/Ð//g;
739: # $result =~ s/Ð//g;
740: $result =~ s/Ñ/\\~{N}/g;
741: $result =~ s/Ñ/\\~{N}/g;
742: $result =~ s/Ò/\\`{O}/g;
743: $result =~ s/Ò/\\`{O}/g;
744: $result =~ s/Ó/\\'{O}/g;
745: $result =~ s/Ó/\\'{O}/g;
746: $result =~ s/Ô/\\^{O}/g;
747: $result =~ s/Ô/\\^{O}/g;
748: $result =~ s/Õ/\\~{O}/g;
749: $result =~ s/Õ/\\~{O}/g;
750: $result =~ s/Ö/\\"{O}/g;
751: $result =~ s/Ö/\\"{O}/g;
752: $result =~ s/×/\$\\times\$/g;
753: $result =~ s/×/\$\\times\$/g;
754: $result =~ s/Ø/{\\O}/g;
755: $result =~ s/Ø/{\\O}/g;
756: $result =~ s/Ù/\\`{U}/g;
757: $result =~ s/Ù/\\`{U}/g;
758: $result =~ s/Ú/\\'{U}/g;
759: $result =~ s/Ú/\\'{U}/g;
760: $result =~ s/Û/\\^{U}/g;
761: $result =~ s/Û/\\^{U}/g;
762: $result =~ s/Ü/\\"{U}/g;
763: $result =~ s/Ü/\\"{U}/g;
764: $result =~ s/Ý/\\'{Y}/g;
765: $result =~ s/Ý/\\'{Y}/g;
766: # $result =~ s/Þ//g;
767: # $result =~ s/Þ//g;
768: # $result =~ s/ß//g;
769: # $result =~ s/ß//g;
770: $result =~ s/à/\\`{a}/g;
771: $result =~ s/à/\\`{a}/g;
772: $result =~ s/á/\\'{a}/g;
773: $result =~ s/á/\\'{a}/g;
774: $result =~ s/â/\\^{a}/g;
775: $result =~ s/â/\\^{a}/g;
776: $result =~ s/ã/\\~{a}/g;
777: $result =~ s/ã/\\~{a}/g;
778: $result =~ s/ä/\\"{a}/g;
779: $result =~ s/ä/\\"{a}/g;
780: $result =~ s/å/{\\aa}/g;
781: $result =~ s/å/{\\aa}/g;
782: $result =~ s/æ/{\\ae}/g;
783: $result =~ s/æ/{\\ae}/g;
784: # $result =~ s/ç//g;
785: # $result =~ s/ç//g;
786: $result =~ s/è/\\`{e}/g;
787: $result =~ s/è/\\`{e}/g;
788: $result =~ s/é/\\'{e}/g;
789: $result =~ s/é/\\'{e}/g;
790: $result =~ s/ê/\\^{e}/g;
791: $result =~ s/ê/\\^{e}/g;
792: $result =~ s/ë/\\"{e}/g;
793: $result =~ s/ë/\\"{e}/g;
794: $result =~ s/ì/\\`{i}/g;
795: $result =~ s/ì/\\`{i}/g;
796: $result =~ s/í/\\'{i}/g;
797: $result =~ s/í/\\'{i}/g;
798: $result =~ s/î/\\^{i}/g;
799: $result =~ s/î/\\^{i}/g;
800: $result =~ s/ï/\\"{i}/g;
801: $result =~ s/ï/\\"{i}/g;
802: # $result =~ s/ð//g;
803: # $result =~ s/ð//g;
804: $result =~ s/ñ/\\~{n}/g;
805: $result =~ s/ñ/\\~{n}/g;
806: $result =~ s/ò/\\`{o}/g;
807: $result =~ s/ò/\\`{o}/g;
808: $result =~ s/ó/\\'{o}/g;
809: $result =~ s/ó/\\'{o}/g;
810: $result =~ s/ô/\\^{o}/g;
811: $result =~ s/ô/\\^{o}/g;
812: $result =~ s/õ/\\~{o}/g;
813: $result =~ s/õ/\\~{o}/g;
814: $result =~ s/ö/\\"{o}/g;
815: $result =~ s/ö/\\"{o}/g;
816: $result =~ s/÷/\$\\div\$/g;
817: $result =~ s/÷/\$\\div\$/g;
818: $result =~ s/ø/{\\o}/g;
819: $result =~ s/ø/{\\o}/g;
820: $result =~ s/ù/\\`{u}/g;
821: $result =~ s/ù/\\`{u}/g;
822: $result =~ s/ú/\\'{u}/g;
823: $result =~ s/ú/\\'{u}/g;
824: $result =~ s/û/\\^{u}/g;
825: $result =~ s/û/\\^{u}/g;
826: $result =~ s/ü/\\"{u}/g;
827: $result =~ s/ü/\\"{u}/g;
828: $result =~ s/ý/\\'{y}/g;
829: $result =~ s/ý/\\'{y}/g;
830: # $result =~ s/þ//g;
831: # $result =~ s/þ//g;
832: $result =~ s/ÿ/\\"{y}/g;
833: $result =~ s/ÿ/\\"{y}/g;
834: return $result;
835: }
1.41 sakharuk 836:
837:
838: #'"`
1.37 sakharuk 839:
1.28 sakharuk 840: sub additional_cleanup {
841: my $result = shift;
842: my $first_app = index($result,'\documentclass',0);
843: $first_app = index($result,'\documentclass',$first_app+5);
844: while ($first_app != -1) {
845: my $second_app = index($result,'begin{document}',$first_app);
846: $first_app = rindex($result,'\end{document}',$first_app);
847: substr($result,$first_app,$second_app-$first_app+15) = '\vskip 3 mm';
848: $first_app = index($result,'\documentclass',$first_app+5);
849: }
850: return $result;
851: }
1.33 sakharuk 852: sub page_cleanup {
853: my $result = shift;
854: $_ = $result;
855: m/\\end{document}(\d*)$/;
1.34 sakharuk 856: my $number_of_columns = $1;
1.33 sakharuk 857: my $insert = '{';
1.34 sakharuk 858: for (my $id=1;$id<=$number_of_columns;$id++) { $insert .='l'; }
1.33 sakharuk 859: $insert .= '}';
1.34 sakharuk 860: $result =~ s/(\\begin{longtable})INSERTTHEHEADOFLONGTABLE/$1$insert/g;
861: $result =~ s/&\s*REMOVETHEHEADOFLONGTABLE\\\\/\\\\/g;
862: $result =~ s/(\\vskip\s*\d+\s*mm)/}\\\\\\parbox{\\minipagewidth}{/g;
1.35 sakharuk 863: $result =~ s/\\parbox{\\minipagewidth}{}\s*\\\\\s*(\\parbox{\\minipagewidth})/$1/g;
1.37 sakharuk 864: $result =~ s/\\parbox{\\minipagewidth}{\s*\\\\\\\\/\\parbox{\\minipagewidth}{/g;
1.34 sakharuk 865: return $result,$number_of_columns;
1.33 sakharuk 866: }
1.6 sakharuk 867:
1.3 sakharuk 868: sub content_map {
1.7 sakharuk 869: #-- find a list of files to print
1.3 sakharuk 870: my $map_string = shift;
1.5 sakharuk 871: my @number_seq = ();
1.7 sakharuk 872: my @file_seq = ();
1.5 sakharuk 873: my $startlink = index($map_string,'<link',0);
1.7 sakharuk 874: my $endlink = index($map_string,'</link>',$startlink);
875: my $chunk = substr($map_string,$startlink,$endlink-$startlink+7);
876: $_ = $chunk;
877: m/from=\"(\d+)\"/;
878: push @number_seq,$1;
1.5 sakharuk 879: while ($startlink != -1) {
1.7 sakharuk 880: $endlink = index($map_string,'</link>',$startlink);
881: $chunk = substr($map_string,$startlink,$endlink-$startlink+7);
1.5 sakharuk 882: substr($map_string,$startlink,$endlink-$startlink+7) = '';
883: $_ = $chunk;
884: m/to=\"(\d+)\"/;
885: push @number_seq,$1;
1.44 sakharuk 886: $startlink = index($map_string,'from="'.$1.'"',0);
1.18 sakharuk 887: $startlink = rindex($map_string,'<link ',$startlink);
1.5 sakharuk 888: }
1.45 sakharuk 889: my $stalink = index($map_string,' to="'.$number_seq[0].'"',0);
1.7 sakharuk 890: while ($stalink != -1) {
891: $startlink = rindex($map_string,'<link ',$stalink);
892: $endlink = index($map_string,'</link>',$startlink);
893: $chunk = substr($map_string,$startlink,$endlink-$startlink+7);
894: substr($map_string,$startlink,$endlink-$startlink+7) = '';
895: $_ = $chunk;
896: m/from=\"(\d+)\"/;
897: unshift @number_seq,$1;
898: $stalink = index($map_string,' to="'.$number_seq[0].'"',0);
899: }
900: for (my $i=0;$i<=$#number_seq;$i++) {
901: $stalink = index($map_string,' id="'.$number_seq[$i].'"',0);
1.13 sakharuk 902: {
903: my $ahed1 = index($map_string,'src="',$stalink);
904: my $ahed2 = index($map_string,'</resource>',$stalink);
905: if ($ahed1 != -1) {
906: if ($ahed1 < $ahed2) {
907: $startlink = $ahed1;
908: } else {
909: $startlink = rindex($map_string,'src="',$stalink);
910: }
911: } else {
912: $startlink = rindex($map_string,'src="',$stalink);
913: }
914:
915: }
1.7 sakharuk 916: $startlink = index($map_string,'"',$startlink);
917: $endlink = index($map_string,'"',$startlink+1);
918: $chunk = substr($map_string,$startlink,$endlink-$startlink+1);
919: push @file_seq,$chunk;
920: }
921: return @file_seq;
922: }
1.5 sakharuk 923:
1.3 sakharuk 924:
925:
926: sub handler {
927:
928: my $r = shift;
929: $r->content_type('text/html');
930: $r->send_http_header;
931:
932: #-- start form
933: &headerform($r);
934: #-- menu for output
1.16 sakharuk 935: unless ($ENV{'form.phase'}) {
1.3 sakharuk 936: &menu_for_output($r);
937: }
1.52 sakharuk 938: #-- additional menu for class printing
939: if ($ENV{'form.phase'} eq 'two') {
940: if($ENV{'form.choice'} eq 'All class print') {
941: &additional_class_menu($r);
942: } else {
943: $ENV{'form.phase'} = 'three';
944: }
945: }
946: #-- additional menu for page layout (one column case)
947: if ($ENV{'form.phase'} eq 'three') {
948: if($ENV{'form.numberofcolumns'} == 1) {
949: &additional_print_menu($r);
950: } else {
951: $ENV{'form.phase'} = 'four';
952: }
953: }
1.3 sakharuk 954: #-- core part
1.52 sakharuk 955: if ($ENV{'form.phase'} eq 'four') {
1.3 sakharuk 956: &output_data($r);
957: }
1.2 sakharuk 958: return OK;
959:
1.1 www 960: }
961:
962: 1;
963: __END__
1.6 sakharuk 964:
965:
1.13 sakharuk 966:
967:
968: #### Test block
1.6 sakharuk 969: # my $ere;
970: # foreach $ere (%ENV) {
1.13 sakharuk 971: # $result .= ' SS '.$ere.' => '.$ENV{$ere}.' FF '."\n\n";
1.6 sakharuk 972: # }
1.13 sakharuk 973: ####
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>