![]() ![]() | ![]() |
Added co-author on the same foot as author.
1: # The LearningOnline Network 2: # Printout 3: # 4: # $Id: lonprintout.pm,v 1.48 2002/08/09 18:06:46 sakharuk Exp $ 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: # 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: # 38: # 9/17 Alex Sakharuk 39: # 40: package Apache::lonprintout; 41: 42: use strict; 43: use Apache::Constants qw(:common :http); 44: use Apache::lonxml; 45: use Apache::lonnet; 46: use Apache::inputtags; 47: use Apache::edit; 48: use Apache::File(); 49: use POSIX qw(strftime); 50: 51: 52: sub headerform { 53: my $r = shift; 54: $r->print(<<ENDHEADER); 55: <html> 56: <head> 57: <title>LON-CAPA output for printing</title> 58: </head> 59: <body bgcolor="FFFFFF"> 60: <form method="post" enctype="multipart/form-data" action="/adm/printout" name="printform"> 61: <tt>$ENV{'form.postdata'}</tt><p> 62: <h1>What do you want to print? Make a choice.</h1><br /> 63: ENDHEADER 64: } 65: 66: 67: sub menu_for_output { 68: my $r = shift; 69: $r->print(<<ENDMENUOUT1); 70: <input type="hidden" name="phase" value="two"> 71: <input type="hidden" name="url" value="$ENV{'form.postdata'}"> 72: <input type="radio" name="choice" value="Standard LaTeX output for current document" checked> Current document 73: (you will print what you see on the screen)<br /> 74: ENDMENUOUT1 75: if ((not $ENV{'request.role'}=~m/^au\./) and (not $ENV{'request.role'}=~m/^ca\./)) { 76: $r->print(<<ENDMENUOUT2); 77: <input type="radio" name="choice" value="Standard LaTeX output for the primary sequence"> All problems from the primary sequence<br /> 78: <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 /> 79: <input type="radio" name="choice" value="Standard LaTeX output for the top level sequence"> All problems from the top level sequence<br /> 80: <br /> 81: ENDMENUOUT2 82: } 83: my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'}); 84: $subdirtoprint =~ s/\/[^\/]+$//; 85: if (&Apache::lonnet::allowed('bre',$subdirtoprint) eq 'F') { 86: $r->print(<<ENDMENUOUT4); 87: <input type="radio" name="choice" value="Subdirectory print"> All problems from current subdirectory (where this particular problem is)<br /> 88: ENDMENUOUT4 89: } 90: $r->print(<<ENDMENUOUT5); 91: <br /><hr /><br /> 92: <h1>And what page format do you prefer?</h1> 93: <table> 94: <tr> 95: <td> 96: <input type="radio" name="layout" value="CBI"> Landscape <br /> 97: <input type="radio" name="layout" value="CAPA" checked> Portrait <br /> 98: </td> 99: <td> </td> 100: <td rawspan="2"> 101: Number of columns: <select name="numberofcolumns"> 102: <option selected> 1 </option> 103: <option> 2 </option> 104: <option> 3 </option> 105: <option> 4 </option> 106: <option> 5 </option> 107: <option> 6 </option> 108: <option> 7 </option> 109: <option> 8 </option> 110: <option> 9 </option> 111: </select> 112: </td> 113: </tr> 114: </table> 115: </br> 116: <input type="submit" value="Submit your choice"> 117: </form> 118: </body> 119: </html> 120: ENDMENUOUT5 121: } 122: 123: 124: 125: 126: sub output_data { 127: my $r = shift; 128: $r->print(<<ENDPART); 129: <html> 130: <head> 131: <title>LON-CAPA output for printing</title> 132: </head> 133: <body bgcolor="FFFFFF"> 134: <hr> 135: ENDPART 136: 137: my $choice = $ENV{'form.choice'}; 138: my $layout = $ENV{'form.layout'}; 139: my $numberofcolumns = $ENV{'form.numberofcolumns'}; 140: my $laystyle = 'book'; 141: my $result = ''; 142: my $number_of_columns = 1; 143: # my $number_of_columns = $ENV{'form.numberofcolumns'}; 144: 145: if ($choice eq 'Standard LaTeX output for current document') { 146: #-- single document - problem, page, html, xml 147: my %moreenv; 148: $moreenv{'form.grade_target'}='tex'; 149: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { 150: $ENV{'form.url'}=~s/http:\/\/[^\/]+//; 151: } 152: $moreenv{'request.filename'}=$ENV{'form.url'}; 153: &Apache::lonnet::appenv(%moreenv); 154: my $texversion=&Apache::lonnet::ssi($ENV{'form.url'}); 155: &Apache::lonnet::delenv('form.grade_target'); 156: $result .= $texversion; 157: $result = &additional_cleanup($result); 158: if ($ENV{'form.url'}=~m/\.page\s*$/) { 159: ($result,$number_of_columns) = &page_cleanup($result); 160: } 161: } elsif ($choice eq 'Standard LaTeX output for the primary sequence' or 162: $choice eq 'Standard LaTeX output for whole primary sequence') { 163: #-- minimal sequence to which the current document belongs 164: #-- where is the primary sequence containing file? 165: my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'}); 166: $_ = $symbolic; 167: m/([^_]+)_/; 168: my $primary_sequence = '/res/'.$1; 169: #-- open and analyses the primary sequence 170: my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence); 171: my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file); 172: my @master_seq = &content_map($sequencefilecontents); 173: #-- produce an output string 174: for (my $i=0;$i<=$#master_seq;$i++) { 175: $_ = $master_seq[$i]; 176: m/\"(.*)\"/; 177: $_ = $1; 178: my $urlp = $1; 179: if ($choice eq 'Standard LaTeX output for the primary sequence') { 180: if ($urlp =~ m/\.(problem|exam|quiz|assess|survey|form|library)/) { 181: my %moreenv; 182: $moreenv{'form.grade_target'}='tex'; 183: &Apache::lonnet::appenv(%moreenv); 184: my $texversion=&Apache::lonnet::ssi($urlp); 185: &Apache::lonnet::delenv('form.grade_target'); 186: $result .= $texversion; 187: } 188: } else { 189: my %moreenv; 190: $moreenv{'form.grade_target'}='tex'; 191: &Apache::lonnet::appenv(%moreenv); 192: my $texversion=&Apache::lonnet::ssi($urlp); 193: &Apache::lonnet::delenv('form.grade_target'); 194: $result .= $texversion; 195: } 196: } 197: $result = &additional_cleanup($result); 198: } elsif ($choice eq 'Standard LaTeX output for the top level sequence') { 199: my @master_seq = (); 200: my @add_file_seq = (); 201: # where is the main sequence of the course? 202: my $main_seq = '/res/'.$ENV{'request.course.uri'}; 203: my $file=&Apache::lonnet::filelocation("",$main_seq); 204: my $filecontents=&Apache::lonnet::getfile($file); 205: my @file_seq = &content_map($filecontents); 206: for (my $iu=0;$iu<=$#file_seq;$iu++) { 207: $file_seq[$iu]=~s/^"//; 208: $file_seq[$iu]=~s/"$//; 209: $file_seq[$iu]=&Apache::lonnet::filelocation("",$file_seq[$iu]); 210: #remove $result .= ' SSS '.$file_seq[$iu].' FFF '; 211: } 212: my $i=0; 213: while ($i<=$#file_seq) { 214: unless ($file_seq[$i]=~m/\.(problem|page)/) { 215: if ($file_seq[$i]=~m/\.sequence/) { 216: my $filecontents=&Apache::lonnet::getfile($file_seq[$i]); 217: my @newfile_seq = &content_map($filecontents); 218: $result .=' START '.$i.' LOOK '.$filecontents.' FINISH '; 219: # splice @file_seq,$1,1,@newfile_seq; 220: # $i=-1; 221: } else { 222: splice @file_seq,$1,1; 223: } 224: } 225: 226: 227: 228: 229: $i++; 230: } 231: for (my $iu=0;$iu<=$#file_seq;$iu++) { 232: $result .= ' SSS '.$file_seq[$iu].' FFF '; 233: } 234: 235: 236: # do we have any other sequence inside? 237: # $result.=$#file_seq.' '; 238: ## my $i=1; 239: ## while ($i<=$#file_seq) { 240: # $result.=' '.$file_seq[$i].' '; 241: ## $file_seq[$i]=~s/^"//; 242: ## $file_seq[$i]=~s/"$//; 243: ## if ($file_seq[$i]=~m/\.sequence\s*$/) { 244: ## $file = &Apache::lonnet::filelocation("",$file_seq[$i]); 245: # $result.=' location '.$file.' '; 246: # $result .= 'FFFFFFFFF'.$file.' '; 247: ## $filecontents=&Apache::lonnet::getfile($file); 248: ## @add_file_seq = &content_map($filecontents); 249: 250: # 251: # for (my $iu=0;$iu<=$#add_file_seq;$iu++) { 252: # $result .= ' SDSD '.$add_file_seq[$iu].' FDFD '; 253: # } 254: # 255: 256: 257: ## splice(@file_seq,$i,1,@add_file_seq); 258: ## @add_file_seq = (); 259: ## $i = -1; 260: ## } 261: ## $i++; 262: ## last; #do not forget to remove 263: ## } 264: ## @master_seq = @file_seq; 265: 266: # 267: # for (my $iu=0;$iu<=$#file_seq;$iu++) { 268: # $result .= ' SSS '.$file_seq[$iu].' FFF '; 269: # } 270: # 271: 272: #-- produce an output string 273: ### for (my $i=0;$i<=$#master_seq;$i++) { 274: ### $_ = $master_seq[$i]; 275: ### m/\"(.*)\"/; 276: ### $_ = $1; 277: ### my $urlp = $1; 278: ### if (/\.(problem|exam|quiz|assess|survey|form|library)/) { 279: ### my %moreenv; 280: ### $moreenv{'form.grade_target'}='tex'; 281: ### &Apache::lonnet::appenv(%moreenv); 282: ### my $texversion=&Apache::lonnet::ssi($urlp); 283: ### &Apache::lonnet::delenv('form.grade_target'); 284: ### $result .= $texversion; 285: ### } 286: ### } 287: ### $result = &additional_cleanup($result); 288: } elsif ($choice eq 'Subdirectory print') { 289: my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'}); 290: $subdirtoprint =~ s/\/[^\/]+$//; 291: my @list_of_files = (); 292: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { 293: $subdirtoprint =~ s/^[^~]*~(\w+)\//\/home\/$1\/public_html\//; 294: } else { 295: $subdirtoprint =~ s/.*(\/res\/)/$1/; 296: } 297: my @content_directory = (); 298: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { 299: @content_directory = &Apache::lonnet::dirlist($subdirtoprint,$ENV{'user.domain'}, $ENV{'user.name'},''); 300: } else { 301: @content_directory = &Apache::lonnet::dirlist($subdirtoprint); 302: } 303: for (my $iy=0;$iy<=$#content_directory;$iy++) { 304: my @tempo_array = split(/&/,$content_directory[$iy]); 305: if ($tempo_array[0] =~ m/^[^\.]+\.(problem|exam|quiz|assess|survey|form|library)$/) { 306: push(@list_of_files,$tempo_array[0]); 307: } 308: } 309: $subdirtoprint =~ s/\/$//; 310: for (my $i=0;$i<=$#list_of_files;$i++) { 311: my $urlp = $subdirtoprint.'/'.$list_of_files[$i]; 312: my %moreenv; 313: $moreenv{'form.grade_target'}='tex'; 314: &Apache::lonnet::appenv(%moreenv); 315: if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { 316: $urlp =~ s/\/home\/([^\/]*)\/public_html/\/~$1/; 317: } 318: my $texversion=&Apache::lonnet::ssi($urlp); 319: &Apache::lonnet::delenv('form.grade_target'); 320: $texversion =~ s/(\\begin{document})/$1 {\\tiny\\begin{verbatim}$urlp\\end{verbatim}}/; 321: $result .= $texversion; 322: } 323: $result = &additional_cleanup($result); 324: 325: 326: 327: 328: 329: 330: } 331: #-- corrections for the different page formats 332: if ($layout eq 'CBI' and $numberofcolumns eq '1') { 333: } elsif ($layout eq 'CBI' and $numberofcolumns eq '2') { 334: $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}/; 335: $laystyle = 'album'; 336: } elsif ($layout eq 'CAPA') { 337: my $courseidinfo = $ENV{'request.role'}; 338: $_ = $courseidinfo; 339: m/.*\/(.*)/; 340: $courseidinfo = $ENV{'course.physnet_'.$1.'.description'}; 341: # $result =~ s/\\documentclass\[letterpaper\]{article}/\\documentclass\[twocolumn\]{article}/; 342: $result =~ s/\\documentclass\[letterpaper\]{article}/\\documentclass{article}/; 343: $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 /; 344: $result =~ s/\\includegraphics{/\\includegraphics\[width=9\.0 cm\]{/g; 345: # $result =~ s/\\includegraphics{/\\includegraphics\[width=\\textwidth\]{/g; 346: # $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/; 347: $result =~ s/(\\end{document})/\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Dept\. of Physics and Astronomy, MSU\\makebox\[1.5cm\]\[b\]{\\hfill}LON-CAPA\\copyright MSU GNU\/GPL $1/; 348: # $result =~ s/(\\end{longtable}\s*)(\\newline\\noindent\\makebox\[9\.0cm\]\[b\]{\\hrulefill})/$2$1/g; 349: $result =~ s/(\\end{longtable}\s*)(\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g; 350: $result =~ s/(\\end{longtable}\s*)\\newline/$1/g; 351: $result =~ s/\$number_of_columns/$number_of_columns/g; 352: } 353: #-- LaTeX corrections 354: my $first_comment = index($result,'<!--',0); 355: while ($first_comment != -1) { 356: my $end_comment = index($result,'-->',$first_comment); 357: substr($result,$first_comment,$end_comment-$first_comment+3) = ''; 358: $first_comment = index($result,'<!--',$first_comment); 359: } 360: $result =~ s/^\s+$//gm; #remove empty lines 361: $result =~ s/\s%/\\%/g; #corrects % 362: $result =~ s/(\s)+/$1/g; #removes more than one empty space 363: $result =~ s/\\\\\s*\\vskip/\\vskip/gm; 364: $result =~ s/\\\\\s*\\noindent\s*(\\\\)+/\\\\\\noindent /g; 365: $result =~ s/{\\par }\s*\\\\/\\\\/gm; 366: $result =~ s/\\\\\s+\[/ \[/g; 367: $result =~ s/θ/\$\\theta\$/g; #converts theta from html into tex 368: $result =~ s/\b__+\b/\\makebox\[1 cm\]\[b\]{\\hrulefill}/g; 369: #conversion of html characters to LaTeX equivalents 370: if ($result =~ m/&(\w+|#\d+);/) { 371: $result = &character_chart($result); 372: } 373: $result =~ s/(\\end{tabular})\s*\\vskip 0 mm/$1/g; 374: $result =~ s/(\\begin{enumerate})\s*\\noindent/$1/g; 375: #-- writing .tex file in prtspool 376: my $temp_file; 377: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex"; 378: unless ($temp_file = Apache::File->new('>'.$filename)) { 379: $r->log_error("Couldn't open $filename for output $!"); 380: return SERVER_ERROR; 381: } 382: print $temp_file $result; 383: $r->print(<<FINALEND); 384: <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$filename&$laystyle"> 385: </body> 386: </html> 387: FINALEND 388: } 389: 390: sub character_chart { 391: my $result = shift; 392: $result =~ s/�?0?7;//g; 393: $result =~ s/�?0?9;//g; 394: $result =~ s/�?10;//g; 395: $result =~ s/�?13;//g; 396: $result =~ s/�?32;/ /g; 397: $result =~ s/�?33;/!/g; 398: $result =~ s/�?34;/"/g; 399: $result =~ s/"/"/g; 400: $result =~ s/�?35;/\\#/g; 401: # $result =~ s/�?36;/\\\$/g; 402: $result =~ s/�?37;/\\%/g; 403: $result =~ s/�?38;/\\&/g; 404: $result =~ s/&/\\&/g; 405: $result =~ s/�?39;/'/g; 406: $result =~ s/�?40;/(/g; 407: $result =~ s/�?41;/)/g; 408: $result =~ s/�?42;/\*/g; 409: $result =~ s/�?43;/\+/g; 410: $result =~ s/�?44;/,/g; 411: $result =~ s/�?45;/-/g; 412: $result =~ s/�?46;/\./g; 413: $result =~ s/�?47;/\//g; 414: $result =~ s/�?48;/0/g; 415: $result =~ s/�?49;/1/g; 416: $result =~ s/�?50;/2/g; 417: $result =~ s/�?51;/3/g; 418: $result =~ s/�?52;/4/g; 419: $result =~ s/�?53;/5/g; 420: $result =~ s/�?54;/6/g; 421: $result =~ s/�?55;/7/g; 422: $result =~ s/�?56;/8/g; 423: $result =~ s/�?57;/9/g; 424: $result =~ s/�?58;/:/g; 425: $result =~ s/�?59;/;/g; 426: $result =~ s/�?60;/\$<\$/g; 427: $result =~ s/</\$<\$/g; 428: $result =~ s/�?61;/\$=\$/g; 429: $result =~ s/�?62;/\$>\$/g; 430: $result =~ s/>/\$>\$/g; 431: $result =~ s/�?63;/?/g; 432: # $result =~ s/�?64;//g; 433: $result =~ s/�?65;/A/g; 434: $result =~ s/�?66;/B/g; 435: $result =~ s/�?67;/C/g; 436: $result =~ s/�?68;/D/g; 437: $result =~ s/�?69;/E/g; 438: $result =~ s/�?70;/F/g; 439: $result =~ s/�?71;/G/g; 440: $result =~ s/�?72;/H/g; 441: $result =~ s/�?73;/I/g; 442: $result =~ s/�?74;/J/g; 443: $result =~ s/�?75;/K/g; 444: $result =~ s/�?76;/L/g; 445: $result =~ s/�?77;/M/g; 446: $result =~ s/�?78;/N/g; 447: $result =~ s/�?79;/O/g; 448: $result =~ s/�?80;/P/g; 449: $result =~ s/�?81;/Q/g; 450: $result =~ s/�?82;/R/g; 451: $result =~ s/�?83;/S/g; 452: $result =~ s/�?84;/T/g; 453: $result =~ s/�?85;/U/g; 454: $result =~ s/�?86;/V/g; 455: $result =~ s/�?87;/W/g; 456: $result =~ s/�?88;/X/g; 457: $result =~ s/�?89;/Y/g; 458: $result =~ s/�?90;/Z/g; 459: $result =~ s/�?91;/[/g; 460: $result =~ s/�?92;/\\/g; 461: $result =~ s/�?93;/]/g; 462: # $result =~ s/�?94;//g; 463: # $result =~ s/�?95;//g; 464: $result =~ s/�?96;/`/g; 465: $result =~ s/�?97;/a/g; 466: $result =~ s/�?98;/b/g; 467: $result =~ s/�?99;/c/g; 468: $result =~ s/d/d/g; 469: $result =~ s/e/e/g; 470: $result =~ s/f/f/g; 471: $result =~ s/g/g/g; 472: $result =~ s/h/h/g; 473: $result =~ s/i/i/g; 474: $result =~ s/j/j/g; 475: $result =~ s/k/k/g; 476: $result =~ s/l/l/g; 477: $result =~ s/m/m/g; 478: $result =~ s/n/n/g; 479: $result =~ s/o/o/g; 480: $result =~ s/p/p/g; 481: $result =~ s/q/q/g; 482: $result =~ s/r/r/g; 483: $result =~ s/s/s/g; 484: $result =~ s/t/t/g; 485: $result =~ s/u/u/g; 486: $result =~ s/v/v/g; 487: $result =~ s/w/w/g; 488: $result =~ s/x/x/g; 489: $result =~ s/y/y/g; 490: $result =~ s/z/z/g; 491: $result =~ s/{/\\{/g; 492: $result =~ s/|/\|/g; 493: $result =~ s/}/\\}/g; 494: $result =~ s/~/\~/g; 495: $result =~ s/‚/,/g; 496: # $result =~ s/ƒ//g; 497: $result =~ s/„/''/g; 498: $result =~ s/…/\$\\ldots\$/g; 499: $result =~ s/†/\$\\dagger\$/g; 500: $result =~ s/‡/\$\\ddagger\$/g; 501: # $result =~ s/ˆ//g; 502: # $result =~ s/‰//g; 503: # $result =~ s/Š//g; 504: $result =~ s/‹/\$<\$/g; 505: # $result =~ s/Œ//g; 506: $result =~ s/‘/`/g; 507: $result =~ s/’/'/g; 508: $result =~ s/“/``/g; 509: $result =~ s/”/''/g; 510: $result =~ s/•/\$\\bullet\$/g; 511: # $result =~ s/–//g; 512: # $result =~ s/—//g; 513: $result =~ s/˜/~/g; 514: # $result =~ s/™//g; 515: # $result =~ s/š//g; 516: $result =~ s/›/\$>\$/g; 517: $result =~ s/œ/\\{\\oe\\}/g; 518: $result =~ s/Ÿ/\\"\\{Y\\}/g; 519: $result =~ s/ //g; 520: $result =~ s/ //g; 521: $result =~ s/¡/!`/g; 522: $result =~ s/¡/!`/g; #` 523: # $result =~ s/¢//g; 524: # $result =~ s/¢//g; 525: $result =~ s/£/\\pounds/g; 526: $result =~ s/£/\\pounds/g; 527: # $result =~ s/¤//g; 528: # $result =~ s/¤//g; 529: # $result =~ s/¥//g; 530: # $result =~ s/¥//g; 531: # $result =~ s/¦//g; 532: # $result =~ s/¦//g; 533: # $result =~ s/§//g; 534: # $result =~ s/§//g; 535: # $result =~ s/¨//g; 536: # $result =~ s/¨//g; 537: $result =~ s/©/\\copyright/g; 538: $result =~ s/©/\\copyright/g; 539: # $result =~ s/ª//g; 540: # $result =~ s/ª//g; 541: # $result =~ s/«//g; 542: # $result =~ s/«//g; 543: $result =~ s/¬/\$\\neg\$/g; 544: $result =~ s/¬/\$\\neg\$/g; 545: # $result =~ s/­//g; 546: # $result =~ s/­//g; 547: # $result =~ s/®//g; 548: # $result =~ s/®//g; 549: # $result =~ s/¯//g; 550: # $result =~ s/¯//g; 551: $result =~ s/°/\$^{\\circ}\$/g; 552: $result =~ s/°/\$^{\\circ}\$/g; 553: $result =~ s/±/\$\\pm\$/g; 554: $result =~ s/±/\$\\pm\$/g; 555: $result =~ s/²/\$^2\$/g; 556: $result =~ s/²/\$^2\$/g; 557: $result =~ s/³/\$^3\$/g; 558: $result =~ s/³/\$^3\$/g; 559: # $result =~ s/´//g; 560: # $result =~ s/´//g; 561: $result =~ s/µ/\$\\mu\$/g; 562: $result =~ s/µ/\$\\mu\$/g; 563: $result =~ s/¶/\\P/g; 564: $result =~ s/¶/\\P/g; 565: $result =~ s/·/\$\\cdot\$/g; 566: $result =~ s/·/\$\\cdot\$/g; 567: # $result =~ s/¸//g; 568: # $result =~ s/¸//g; 569: $result =~ s/¹/\$^1\$/g; 570: $result =~ s/¹/\$^1\$/g; 571: # $result =~ s/º//g; 572: # $result =~ s/º//g; 573: # $result =~ s/»//g; 574: # $result =~ s/»//g; 575: # $result =~ s/¼//g; 576: # $result =~ s/¼//g; 577: # $result =~ s/½//g; 578: # $result =~ s/½//g; 579: # $result =~ s/¾//g; 580: # $result =~ s/¾//g; 581: $result =~ s/¿/?`/g; 582: $result =~ s/¿/?`/g; 583: $result =~ s/À/\\`{A}/g; 584: $result =~ s/À/\\`{A}/g; 585: $result =~ s/Á/\\'{A}/g; 586: $result =~ s/Á/\\'{A}/g; 587: $result =~ s/Â/\\^{A}/g; 588: $result =~ s/Â/\\^{A}/g; 589: $result =~ s/Ã/\\~{A}/g; 590: $result =~ s/Ã/\\~{A}/g; 591: $result =~ s/Ä/\\"{A}/g; 592: $result =~ s/Ä/\\"{A}/g; 593: $result =~ s/Å/{\\AA}/g; 594: $result =~ s/Å/{\\AA}/g; 595: $result =~ s/Æ/{\\AE}/g; 596: $result =~ s/Æ/{\\AE}/g; 597: # $result =~ s/Ç//g; 598: # $result =~ s/Ç//g; 599: $result =~ s/È/\\`{E}/g; 600: $result =~ s/È/\\`{E}/g; 601: $result =~ s/É/\\'{E}/g; 602: $result =~ s/É/\\'{E}/g; 603: $result =~ s/Ê/\\^{E}/g; 604: $result =~ s/Ê/\\^{E}/g; 605: $result =~ s/Ë/\\`{E}/g; 606: $result =~ s/Ë/\\`{E}/g; 607: $result =~ s/Ì/\\`{I}/g; 608: $result =~ s/Ì/\\`{I}/g; 609: $result =~ s/Í/\\'{I}/g; 610: $result =~ s/Í/\\'{I}/g; 611: $result =~ s/Î/\\^{I}/g; 612: $result =~ s/Î/\\^{I}/g; 613: $result =~ s/Ï/\\"{I}/g; 614: $result =~ s/Ï/\\"{I}/g; 615: # $result =~ s/Ð//g; 616: # $result =~ s/Ð//g; 617: $result =~ s/Ñ/\\~{N}/g; 618: $result =~ s/Ñ/\\~{N}/g; 619: $result =~ s/Ò/\\`{O}/g; 620: $result =~ s/Ò/\\`{O}/g; 621: $result =~ s/Ó/\\'{O}/g; 622: $result =~ s/Ó/\\'{O}/g; 623: $result =~ s/Ô/\\^{O}/g; 624: $result =~ s/Ô/\\^{O}/g; 625: $result =~ s/Õ/\\~{O}/g; 626: $result =~ s/Õ/\\~{O}/g; 627: $result =~ s/Ö/\\"{O}/g; 628: $result =~ s/Ö/\\"{O}/g; 629: $result =~ s/×/\$\\times\$/g; 630: $result =~ s/×/\$\\times\$/g; 631: $result =~ s/Ø/{\\O}/g; 632: $result =~ s/Ø/{\\O}/g; 633: $result =~ s/Ù/\\`{U}/g; 634: $result =~ s/Ù/\\`{U}/g; 635: $result =~ s/Ú/\\'{U}/g; 636: $result =~ s/Ú/\\'{U}/g; 637: $result =~ s/Û/\\^{U}/g; 638: $result =~ s/Û/\\^{U}/g; 639: $result =~ s/Ü/\\"{U}/g; 640: $result =~ s/Ü/\\"{U}/g; 641: $result =~ s/Ý/\\'{Y}/g; 642: $result =~ s/Ý/\\'{Y}/g; 643: # $result =~ s/Þ//g; 644: # $result =~ s/Þ//g; 645: # $result =~ s/ß//g; 646: # $result =~ s/ß//g; 647: $result =~ s/à/\\`{a}/g; 648: $result =~ s/à/\\`{a}/g; 649: $result =~ s/á/\\'{a}/g; 650: $result =~ s/á/\\'{a}/g; 651: $result =~ s/â/\\^{a}/g; 652: $result =~ s/â/\\^{a}/g; 653: $result =~ s/ã/\\~{a}/g; 654: $result =~ s/ã/\\~{a}/g; 655: $result =~ s/ä/\\"{a}/g; 656: $result =~ s/ä/\\"{a}/g; 657: $result =~ s/å/{\\aa}/g; 658: $result =~ s/å/{\\aa}/g; 659: $result =~ s/æ/{\\ae}/g; 660: $result =~ s/æ/{\\ae}/g; 661: # $result =~ s/ç//g; 662: # $result =~ s/ç//g; 663: $result =~ s/è/\\`{e}/g; 664: $result =~ s/è/\\`{e}/g; 665: $result =~ s/é/\\'{e}/g; 666: $result =~ s/é/\\'{e}/g; 667: $result =~ s/ê/\\^{e}/g; 668: $result =~ s/ê/\\^{e}/g; 669: $result =~ s/ë/\\"{e}/g; 670: $result =~ s/ë/\\"{e}/g; 671: $result =~ s/ì/\\`{i}/g; 672: $result =~ s/ì/\\`{i}/g; 673: $result =~ s/í/\\'{i}/g; 674: $result =~ s/í/\\'{i}/g; 675: $result =~ s/î/\\^{i}/g; 676: $result =~ s/î/\\^{i}/g; 677: $result =~ s/ï/\\"{i}/g; 678: $result =~ s/ï/\\"{i}/g; 679: # $result =~ s/ð//g; 680: # $result =~ s/ð//g; 681: $result =~ s/ñ/\\~{n}/g; 682: $result =~ s/ñ/\\~{n}/g; 683: $result =~ s/ò/\\`{o}/g; 684: $result =~ s/ò/\\`{o}/g; 685: $result =~ s/ó/\\'{o}/g; 686: $result =~ s/ó/\\'{o}/g; 687: $result =~ s/ô/\\^{o}/g; 688: $result =~ s/ô/\\^{o}/g; 689: $result =~ s/õ/\\~{o}/g; 690: $result =~ s/õ/\\~{o}/g; 691: $result =~ s/ö/\\"{o}/g; 692: $result =~ s/ö/\\"{o}/g; 693: $result =~ s/÷/\$\\div\$/g; 694: $result =~ s/÷/\$\\div\$/g; 695: $result =~ s/ø/{\\o}/g; 696: $result =~ s/ø/{\\o}/g; 697: $result =~ s/ù/\\`{u}/g; 698: $result =~ s/ù/\\`{u}/g; 699: $result =~ s/ú/\\'{u}/g; 700: $result =~ s/ú/\\'{u}/g; 701: $result =~ s/û/\\^{u}/g; 702: $result =~ s/û/\\^{u}/g; 703: $result =~ s/ü/\\"{u}/g; 704: $result =~ s/ü/\\"{u}/g; 705: $result =~ s/ý/\\'{y}/g; 706: $result =~ s/ý/\\'{y}/g; 707: # $result =~ s/þ//g; 708: # $result =~ s/þ//g; 709: $result =~ s/ÿ/\\"{y}/g; 710: $result =~ s/ÿ/\\"{y}/g; 711: return $result; 712: } 713: 714: 715: #'"` 716: 717: sub additional_cleanup { 718: my $result = shift; 719: my $first_app = index($result,'\documentclass',0); 720: $first_app = index($result,'\documentclass',$first_app+5); 721: while ($first_app != -1) { 722: my $second_app = index($result,'begin{document}',$first_app); 723: $first_app = rindex($result,'\end{document}',$first_app); 724: substr($result,$first_app,$second_app-$first_app+15) = '\vskip 3 mm'; 725: $first_app = index($result,'\documentclass',$first_app+5); 726: } 727: return $result; 728: } 729: sub page_cleanup { 730: my $result = shift; 731: $_ = $result; 732: m/\\end{document}(\d*)$/; 733: my $number_of_columns = $1; 734: my $insert = '{'; 735: for (my $id=1;$id<=$number_of_columns;$id++) { $insert .='l'; } 736: $insert .= '}'; 737: $result =~ s/(\\begin{longtable})INSERTTHEHEADOFLONGTABLE/$1$insert/g; 738: $result =~ s/&\s*REMOVETHEHEADOFLONGTABLE\\\\/\\\\/g; 739: $result =~ s/(\\vskip\s*\d+\s*mm)/}\\\\\\parbox{\\minipagewidth}{/g; 740: $result =~ s/\\parbox{\\minipagewidth}{}\s*\\\\\s*(\\parbox{\\minipagewidth})/$1/g; 741: $result =~ s/\\parbox{\\minipagewidth}{\s*\\\\\\\\/\\parbox{\\minipagewidth}{/g; 742: return $result,$number_of_columns; 743: } 744: 745: sub content_map { 746: #-- find a list of files to print 747: my $map_string = shift; 748: my @number_seq = (); 749: my @file_seq = (); 750: my $startlink = index($map_string,'<link',0); 751: my $endlink = index($map_string,'</link>',$startlink); 752: my $chunk = substr($map_string,$startlink,$endlink-$startlink+7); 753: $_ = $chunk; 754: m/from=\"(\d+)\"/; 755: push @number_seq,$1; 756: while ($startlink != -1) { 757: $endlink = index($map_string,'</link>',$startlink); 758: $chunk = substr($map_string,$startlink,$endlink-$startlink+7); 759: substr($map_string,$startlink,$endlink-$startlink+7) = ''; 760: $_ = $chunk; 761: m/to=\"(\d+)\"/; 762: push @number_seq,$1; 763: $startlink = index($map_string,'from="'.$1.'"',0); 764: $startlink = rindex($map_string,'<link ',$startlink); 765: } 766: my $stalink = index($map_string,' to="'.$number_seq[0].'"',0); 767: while ($stalink != -1) { 768: $startlink = rindex($map_string,'<link ',$stalink); 769: $endlink = index($map_string,'</link>',$startlink); 770: $chunk = substr($map_string,$startlink,$endlink-$startlink+7); 771: substr($map_string,$startlink,$endlink-$startlink+7) = ''; 772: $_ = $chunk; 773: m/from=\"(\d+)\"/; 774: unshift @number_seq,$1; 775: $stalink = index($map_string,' to="'.$number_seq[0].'"',0); 776: } 777: for (my $i=0;$i<=$#number_seq;$i++) { 778: $stalink = index($map_string,' id="'.$number_seq[$i].'"',0); 779: { 780: my $ahed1 = index($map_string,'src="',$stalink); 781: my $ahed2 = index($map_string,'</resource>',$stalink); 782: if ($ahed1 != -1) { 783: if ($ahed1 < $ahed2) { 784: $startlink = $ahed1; 785: } else { 786: $startlink = rindex($map_string,'src="',$stalink); 787: } 788: } else { 789: $startlink = rindex($map_string,'src="',$stalink); 790: } 791: 792: } 793: $startlink = index($map_string,'"',$startlink); 794: $endlink = index($map_string,'"',$startlink+1); 795: $chunk = substr($map_string,$startlink,$endlink-$startlink+1); 796: push @file_seq,$chunk; 797: } 798: return @file_seq; 799: } 800: 801: 802: 803: sub handler { 804: 805: my $r = shift; 806: $r->content_type('text/html'); 807: $r->send_http_header; 808: 809: #-- start form 810: &headerform($r); 811: #-- menu for output 812: unless ($ENV{'form.phase'}) { 813: &menu_for_output($r); 814: } 815: #-- core part 816: if ($ENV{'form.phase'} eq 'two') { 817: &output_data($r); 818: } 819: return OK; 820: 821: } 822: 823: 1; 824: __END__ 825: 826: 827: 828: 829: #### Test block 830: # my $ere; 831: # foreach $ere (%ENV) { 832: # $result .= ' SS '.$ere.' => '.$ENV{$ere}.' FF '."\n\n"; 833: # } 834: ####