File:  [LON-CAPA] / loncom / interface / lonprintout.pm
Revision 1.182: download - view: text, annotated - select for diffs
Thu May 15 20:45:40 2003 UTC (21 years ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
removed first item from additional menu for adding empty page after students assignments.

    1: # The LearningOnline Network
    2: # Printout
    3: #
    4: # $Id: lonprintout.pm,v 1.182 2003/05/15 20:45:40 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::loncommon;
   47: use Apache::inputtags;
   48: use Apache::grades;
   49: use Apache::edit;
   50: use Apache::File();
   51: use Apache::lonnavmaps;
   52: use POSIX qw(strftime);
   53: use GDBM_File;
   54: 
   55: 
   56: my %hash;
   57: my $LaTeXwidth = 0;
   58: 
   59: 
   60: sub latex_header_footer_remove {
   61:     my $text = shift;
   62:     $text =~ s/\\end{document}//;
   63:     $text =~ s/\\documentclass([^&]*)\\begin{document}//;
   64:     return $text;
   65: }
   66: 
   67: 
   68: sub character_chart {
   69:     my $result = shift;	
   70:     $result =~ s/&\#0?0?(7|9);//g;
   71:     $result =~ s/&\#0?(10|13);//g;
   72:     $result =~ s/&\#0?32;/ /g;
   73:     $result =~ s/&\#0?33;/!/g;
   74:     $result =~ s/&(\#0?34|quot);/\"/g;
   75:     $result =~ s/&\#0?35;/\\\#/g;
   76:     $result =~ s/&\#0?36;/\\\$/g;
   77:     $result =~ s/&\#0?37;/\\%/g; 
   78:     $result =~ s/&(\#0?38|amp);/\\&/g; 
   79:     $result =~ s/&\#(0?39|146);/\'/g;
   80:     $result =~ s/&\#0?40;/(/g;
   81:     $result =~ s/&\#0?41;/)/g;
   82:     $result =~ s/&\#0?42;/\*/g;
   83:     $result =~ s/&\#0?43;/\+/g;
   84:     $result =~ s/&\#(0?44|130);/,/g;
   85:     $result =~ s/&\#0?45;/-/g;
   86:     $result =~ s/&\#0?46;/\./g;
   87:     $result =~ s/&\#0?47;/\//g;
   88:     $result =~ s/&\#0?48;/0/g;
   89:     $result =~ s/&\#0?49;/1/g;
   90:     $result =~ s/&\#0?50;/2/g;
   91:     $result =~ s/&\#0?51;/3/g;
   92:     $result =~ s/&\#0?52;/4/g;
   93:     $result =~ s/&\#0?53;/5/g;
   94:     $result =~ s/&\#0?54;/6/g;
   95:     $result =~ s/&\#0?55;/7/g;
   96:     $result =~ s/&\#0?56;/8/g;
   97:     $result =~ s/&\#0?57;/9/g;
   98:     $result =~ s/&\#0?58;/:/g;
   99:     $result =~ s/&\#0?59;/;/g;
  100:     $result =~ s/&(\#0?60|lt|\#139);/\$<\$/g;
  101:     $result =~ s/&\#0?61;/\$=\$/g;
  102:     $result =~ s/&(\#0?62|gt|\#155);/\$>\$/g;
  103:     $result =~ s/&\#0?63;/\?/g;
  104:     $result =~ s/&\#0?65;/A/g;
  105:     $result =~ s/&\#0?66;/B/g;
  106:     $result =~ s/&\#0?67;/C/g;
  107:     $result =~ s/&\#0?68;/D/g;
  108:     $result =~ s/&\#0?69;/E/g;
  109:     $result =~ s/&\#0?70;/F/g;
  110:     $result =~ s/&\#0?71;/G/g;
  111:     $result =~ s/&\#0?72;/H/g;
  112:     $result =~ s/&\#0?73;/I/g;
  113:     $result =~ s/&\#0?74;/J/g;
  114:     $result =~ s/&\#0?75;/K/g;
  115:     $result =~ s/&\#0?76;/L/g;
  116:     $result =~ s/&\#0?77;/M/g;
  117:     $result =~ s/&\#0?78;/N/g;
  118:     $result =~ s/&\#0?79;/O/g;
  119:     $result =~ s/&\#0?80;/P/g;
  120:     $result =~ s/&\#0?81;/Q/g;
  121:     $result =~ s/&\#0?82;/R/g;
  122:     $result =~ s/&\#0?83;/S/g;
  123:     $result =~ s/&\#0?84;/T/g;
  124:     $result =~ s/&\#0?85;/U/g;
  125:     $result =~ s/&\#0?86;/V/g;
  126:     $result =~ s/&\#0?87;/W/g;
  127:     $result =~ s/&\#0?88;/X/g;
  128:     $result =~ s/&\#0?89;/Y/g;
  129:     $result =~ s/&\#0?90;/Z/g;
  130:     $result =~ s/&\#0?91;/[/g;
  131:     $result =~ s/&\#0?92;/\$\\setminus\$/g;
  132:     $result =~ s/&\#0?93;/]/g;
  133:     $result =~ s/&\#(0?94|136);/\$\\wedge\$/g;
  134:     $result =~ s/&\#(0?95|138|154);/\\underline{\\makebox[2mm]{\\strut}}/g;
  135:     $result =~ s/&\#(0?96|145);/\`/g;
  136:     $result =~ s/&\#0?97;/a/g;
  137:     $result =~ s/&\#0?98;/b/g;
  138:     $result =~ s/&\#0?99;/c/g;
  139:     $result =~ s/&\#100;/d/g;
  140:     $result =~ s/&\#101;/e/g;
  141:     $result =~ s/&\#102;/f/g;
  142:     $result =~ s/&\#103;/g/g;
  143:     $result =~ s/&\#104;/h/g;
  144:     $result =~ s/&\#105;/i/g;
  145:     $result =~ s/&\#106;/j/g;
  146:     $result =~ s/&\#107;/k/g;
  147:     $result =~ s/&\#108;/l/g;
  148:     $result =~ s/&\#109;/m/g;
  149:     $result =~ s/&\#110;/n/g;
  150:     $result =~ s/&\#111;/o/g;
  151:     $result =~ s/&\#112;/p/g;
  152:     $result =~ s/&\#113;/q/g;
  153:     $result =~ s/&\#114;/r/g;
  154:     $result =~ s/&\#115;/s/g;
  155:     $result =~ s/&\#116;/t/g;
  156:     $result =~ s/&\#117;/u/g;
  157:     $result =~ s/&\#118;/v/g;
  158:     $result =~ s/&\#119;/w/g;
  159:     $result =~ s/&\#120;/x/g;
  160:     $result =~ s/&\#121;/y/g;
  161:     $result =~ s/&\#122;/z/g;
  162:     $result =~ s/&\#123;/\\{/g;
  163:     $result =~ s/&\#124;/\|/g;
  164:     $result =~ s/&\#125;/\\}/g;
  165:     $result =~ s/&\#126;/\~/g;
  166:     $result =~ s/&\#131;/\\textflorin /g;
  167:     $result =~ s/&\#132;/\"/g;
  168:     $result =~ s/&\#133;/\$\\ldots\$/g;
  169:     $result =~ s/&\#134;/\$\\dagger\$/g;
  170:     $result =~ s/&\#135;/\$\\ddagger\$/g;
  171:     $result =~ s/&\#137;/\\textperthousand /g;
  172:     $result =~ s/&\#140;/{\\OE}/g;
  173:     $result =~ s/&\#147;/\`\`/g;
  174:     $result =~ s/&\#148;/\'\'/g;
  175:     $result =~ s/&\#149;/\$\\bullet\$/g;
  176:     $result =~ s/&\#150;/--/g;
  177:     $result =~ s/&\#151;/---/g;
  178:     $result =~ s/&\#152;/\$\\sim\$/g;
  179:     $result =~ s/&\#153;/\\texttrademark /g;
  180:     $result =~ s/&\#156;/\\oe/g;
  181:     $result =~ s/&\#159;/\\\"Y/g;
  182:     $result =~ s/&(\#160|nbsp);//g;
  183:     $result =~ s/&(\#161|iexcl);/!\`/g;
  184:     $result =~ s/&(\#162|cent);/\\textcent /g;
  185:     $result =~ s/&(\#163|pound);/\\pounds /g; 
  186:     $result =~ s/&(\#164|curren);/\\textcurrency /g;
  187:     $result =~ s/&(\#165|yen);/\\textyen /g;
  188:     $result =~ s/&(\#166|brvbar);/\\textbrokenbar /g;
  189:     $result =~ s/&(\#167|sect);/\\textsection /g;
  190:     $result =~ s/&(\#168|uml);/\\texthighdieresis /g;
  191:     $result =~ s/&(\#169|copy);/\\copyright /g;
  192:     $result =~ s/&(\#170|ordf);/\\textordfeminine /g;
  193:     $result =~ s/&(\#172|not);/\$\\neg\$/g;
  194:     $result =~ s/&(\#173|shy);/ - /g;
  195:     $result =~ s/&(\#174|reg);/\\textregistered /g;
  196:     $result =~ s/&(\#175|macr);/\$^{-}\$/g;
  197:     $result =~ s/&(\#176|deg);/\$^{\\circ}\$/g;
  198:     $result =~ s/&(\#177|plusmn);/\$\\pm\$/g;
  199:     $result =~ s/&(\#178|sup2);/\$^2\$/g;
  200:     $result =~ s/&(\#179|sup3);/\$^3\$/g;
  201:     $result =~ s/&(\#180|acute);/\\textacute /g;
  202:     $result =~ s/&(\#181|micro);/\$\\mu\$/g;
  203:     $result =~ s/&(\#182|para);/\\P/g;
  204:     $result =~ s/&(\#183|middot);/\$\\cdot\$/g;
  205:     $result =~ s/&(\#184|cedil);/\\c{\\strut}/g;
  206:     $result =~ s/&(\#185|sup1);/\$^1\$/g;
  207:     $result =~ s/&(\#186|ordm);/\\textordmasculine /g;
  208:     $result =~ s/&(\#188|frac14);/\\textonequarter /g;
  209:     $result =~ s/&(\#189|frac12);/\\textonehalf /g;
  210:     $result =~ s/&(\#190|frac34);/\\textthreequarters /g;
  211:     $result =~ s/&(\#191|iquest);/?\`/g;   
  212:     $result =~ s/&(\#192|Agrave);/\\\`{A}/g;  
  213:     $result =~ s/&(\#193|Aacute);/\\\'{A}/g; 
  214:     $result =~ s/&(\#194|Acirc);/\\^{A}/g;
  215:     $result =~ s/&(\#195|Atilde);/\\~{A}/g;
  216:     $result =~ s/&(\#196|Auml);/\\\"{A}/g; 
  217:     $result =~ s/&(\#197|Aring);/{\\AA}/g;
  218:     $result =~ s/&(\#198|AElig);/{\\AE}/g;
  219:     $result =~ s/&(\#199|Ccedil);/\\c{c}/g;
  220:     $result =~ s/&(\#200|Egrave);/\\\`{E}/g;  
  221:     $result =~ s/&(\#201|Eacute);/\\\'{E}/g;    
  222:     $result =~ s/&(\#202|Ecirc);/\\^{E}/g;
  223:     $result =~ s/&(\#203|Euml);/\\\"{E}/g;
  224:     $result =~ s/&(\#204|Igrave);/\\\`{I}/g;
  225:     $result =~ s/&(\#205|Iacute);/\\\'{I}/g;    
  226:     $result =~ s/&(\#206|Icirc);/\\^{I}/g;
  227:     $result =~ s/&(\#207|Iuml);/\\\"{I}/g;    
  228:     $result =~ s/&(\#209|Ntilde);/\\~{N}/g;
  229:     $result =~ s/&(\#210|Ograve);/\\\`{O}/g;
  230:     $result =~ s/&(\#211|Oacute);/\\\'{O}/g;
  231:     $result =~ s/&(\#212|Ocirc);/\\^{O}/g;
  232:     $result =~ s/&(\#213|Otilde);/\\~{O}/g;
  233:     $result =~ s/&(\#214|Ouml);/\\\"{O}/g;    
  234:     $result =~ s/&(\#215|times);/\$\\times\$/g;
  235:     $result =~ s/&(\#216|Oslash);/{\\O}/g;
  236:     $result =~ s/&(\#217|Ugrave);/\\\`{U}/g;    
  237:     $result =~ s/&(\#218|Uacute);/\\\'{U}/g;
  238:     $result =~ s/&(\#219|Ucirc);/\\^{U}/g;
  239:     $result =~ s/&(\#220|Uuml);/\\\"{U}/g;
  240:     $result =~ s/&(\#221|Yacute);/\\\'{Y}/g;
  241:     $result =~ s/&(\#223|szlig);/\\ss/g;
  242:     $result =~ s/&(\#224|agrave);/\\\`{a}/g;
  243:     $result =~ s/&(\#225|aacute);/\\\'{a}/g;
  244:     $result =~ s/&(\#226|acirc);/\\^{a}/g;
  245:     $result =~ s/&(\#227|atilde);/\\~{a}/g;
  246:     $result =~ s/&(\#228|auml);/\\\"{a}/g;
  247:     $result =~ s/&(\#229|aring);/{\\aa}/g;
  248:     $result =~ s/&(\#230|aelig);/{\\ae}/g;
  249:     $result =~ s/&(\#231|ccedil);/\\c{c}/g;
  250:     $result =~ s/&(\#232|egrave);/\\\`{e}/g;
  251:     $result =~ s/&(\#233|eacute);/\\\'{e}/g;
  252:     $result =~ s/&(\#234|ecirc);/\\^{e}/g;
  253:     $result =~ s/&(\#235|euml);/\\\"{e}/g;
  254:     $result =~ s/&(\#236|igrave);/\\\`{i}/g;
  255:     $result =~ s/&(\#237|iacute);/\\\'{i}/g;
  256:     $result =~ s/&(\#238|icirc);/\\^{i}/g;
  257:     $result =~ s/&(\#239|iuml);/\\\"{i}/g;
  258:     $result =~ s/&(\#240|eth);/\$\\partial\$/g;
  259:     $result =~ s/&(\#241|ntilde);/\\~{n}/g;
  260:     $result =~ s/&(\#242|ograve);/\\\`{o}/g;
  261:     $result =~ s/&(\#243|oacute);/\\\'{o}/g;
  262:     $result =~ s/&(\#244|ocirc);/\\^{o}/g;
  263:     $result =~ s/&(\#245|otilde);/\\~{o}/g;
  264:     $result =~ s/&(\#246|ouml);/\\\"{o}/g;
  265:     $result =~ s/&(\#247|divide);/\$\\div\$/g;
  266:     $result =~ s/&(\#248|oslash);/{\\o}/g;
  267:     $result =~ s/&(\#249|ugrave);/\\\`{u}/g; 
  268:     $result =~ s/&(\#250|uacute);/\\\'{u}/g;
  269:     $result =~ s/&(\#251|ucirc);/\\^{u}/g;
  270:     $result =~ s/&(\#252|uuml);/\\\"{u}/g;
  271:     $result =~ s/&(\#253|yacute);/\\\'{y}/g;
  272:     $result =~ s/&(\#255|yuml);/\\\"{y}/g;
  273:     $result =~ s/&\#952;/\$\\theta\$/g;
  274: #Greek Alphabet
  275:     $result =~ s/&(alpha|\#945);/\$\\alpha \$/g;
  276:     $result =~ s/&(beta|\#946);/\$\\beta \$/g;
  277:     $result =~ s/&(gamma|\#947);/\$\\gamma \$/g;
  278:     $result =~ s/&(delta|\#948);/\$\\delta \$/g;
  279:     $result =~ s/&(epsilon|\#949);/\$\\epsilon \$/g;
  280:     $result =~ s/&(zeta|\#950);/\$\\zeta \$/g;
  281:     $result =~ s/&(eta|\#951);/\$\\eta \$/g;
  282:     $result =~ s/&(theta|\#952);/\$\\theta \$/g;
  283:     $result =~ s/&(iota|\#953);/\$\\iota \$/g;
  284:     $result =~ s/&(kappa|\#954);/\$\\kappa \$/g;
  285:     $result =~ s/&(lambda|\#955);/\$\\lambda \$/g;
  286:     $result =~ s/&(mu|\#956);/\$\\mu \$/g;
  287:     $result =~ s/&(nu|\#957);/\$\\nu \$/g;
  288:     $result =~ s/&(xi|\#958);/\$\\xi \$/g;
  289:     $result =~ s/&(pi|\#960);/\$\\pi \$/g;
  290:     $result =~ s/&(rho|\#961);/\$\\rho \$/g;
  291:     $result =~ s/&(sigma|\#963);/\$\\sigma \$/g;
  292:     $result =~ s/&(tau|\#964);/\$\\tau \$/g;
  293:     $result =~ s/&(upsilon|\#965);/\$\\upsilon \$/g;
  294:     $result =~ s/&(phi|\#966);/\$\\phi \$/g;
  295:     $result =~ s/&(chi|\#967);/\$\\chi \$/g;
  296:     $result =~ s/&(psi|\#968);/\$\\psi \$/g;
  297:     $result =~ s/&(omega|\#969);/\$\\omega \$/g;
  298:     $result =~ s/&(Gamma|\#915);/\$\\Gamma \$/g;
  299:     $result =~ s/&(Delta|\#916);/\$\\Delta \$/g;
  300:     $result =~ s/&(Theta|\#920);/\$\\Theta \$/g;
  301:     $result =~ s/&(Lambda|\#923);/\$\\Lambda \$/g;
  302:     $result =~ s/&(Xi|\#926);/\$\\Xi \$/g;
  303:     $result =~ s/&(Pi|\#928);/\$\\Pi \$/g;
  304:     $result =~ s/&(Sigma|\#931);/\$\\Sigma \$/g;
  305:     $result =~ s/&(Upsilon|\#933);/\$\\Upsilon \$/g;
  306:     $result =~ s/&(Phi|\#934);/\$\\Phi \$/g;
  307:     $result =~ s/&(Psi|\#936);/\$\\Psi \$/g;
  308:     $result =~ s/&(Omega|\#937);/\$\\Omega \$/g;
  309:     return $result;
  310: }
  311: 
  312: 
  313: sub page_format {
  314: #
  315: #Correspondence between $papersize variable and real paper format:
  316: # 0 - "Letter [8 1/2x11 in]"
  317: # 1 - "Legal [8 1/2x14 in]"
  318: # 2 - "Ledger/Tabloid [11x17 in]"
  319: # 3 - "Executive [7 1/2x10 in]"
  320: # 4 - "A2 [420x594 mm]"
  321: # 5 - "A3 [297x420 mm]"
  322: # 6 - "A4 [210x297 mm]"
  323: # 7 - "A5 [148x210 mm]"
  324: # 8 - "A6 [105x148 mm]"
  325: # 
  326:     my ($papersize,$layout,$numberofcolumns) = @_; 
  327:     my ($textwidth,$textheight,$oddoffset,$evenoffset) = (0,0,0,0);
  328:     if ($papersize eq '0') {
  329: 	if ($layout eq 'book') {
  330: 	    if ($numberofcolumns == 1) {
  331: 		$textwidth = '18 cm';
  332: 		$textheight = '25.9 cm';
  333: 		$oddoffset = '-0.57 in';
  334: 		$evenoffset = '-0.57 in';
  335: 	    } elsif ($numberofcolumns == 2) {
  336: 		$textwidth = '93 mm';
  337: 		$textheight = '25.9 cm';
  338: 		$oddoffset = '-0.57 in';
  339: 		$evenoffset = '-0.57 in';
  340: 	    }
  341: 	} elsif ($layout eq 'album') {
  342: 	    if ($numberofcolumns eq '1') {
  343: 		$textwidth = '8.8 in';
  344: 		$textheight = '6.8 in';
  345: 		$oddoffset = '-40 pt';
  346: 		$evenoffset = '-60 pt';
  347: 	    } elsif ($numberofcolumns == 2) {
  348: 		$textwidth = '4.2 in';
  349: 		$textheight = '6.8 in';
  350: 		$oddoffset = '-40 pt';
  351: 		$evenoffset = '-60 pt';
  352: 	    }
  353: 	}
  354: #    } elsif($papersize eq '1') {
  355: #    } elsif($papersize eq '2') {
  356: #    } elsif($papersize eq '3'/) {
  357:     } elsif($papersize eq '6') {
  358: 	if ($layout eq 'book') {
  359: 	    if ($numberofcolumns == 1) {
  360: 		$textwidth = '18 cm';
  361: 		$textheight = '28 cm';
  362: 		$oddoffset = '-0.57 in';
  363: 		$evenoffset = '-0.57 in';
  364: 	    } elsif ($numberofcolumns == 2) {
  365: 		$textwidth = '96 mm';
  366: 		$textheight = '2 cm';
  367: 		$oddoffset = '-0.57 in';
  368: 		$evenoffset = '-0.57 in';
  369: 	    }
  370: 	} elsif ($layout eq 'album') {
  371: 	    if ($numberofcolumns eq '1') {
  372: 		$textwidth = '8.5 in';
  373: 		$textheight = '7.7 in';
  374: 		$oddoffset = '-40 pt';
  375: 		$evenoffset = '-60 pt';
  376: 	    } elsif ($numberofcolumns == 2) {
  377: 		$textwidth = '3.9 in';
  378: 		$textheight = '7.7 in';
  379: 		$oddoffset = '-40 pt';
  380: 		$evenoffset = '-60 pt';
  381: 	    }
  382: 	}
  383: #    } elsif($papersize eq '5') {
  384: #    } elsif($papersize eq '4') {
  385: #    } elsif($papersize eq '7') {
  386: #    } elsif($papersize eq '8') {
  387:     }
  388:     return $textwidth,$textheight,$oddoffset,$evenoffset;
  389: }
  390: 
  391: 
  392: sub get_name {
  393:     my ($uname,$udom)=@_;
  394:     if (!defined($uname)) { $uname=$ENV{'user.name'}; }
  395:     if (!defined($udom)) { $uname=$ENV{'user.domain'}; }
  396:     my $plainname=&Apache::loncommon::plainname($uname,$udom);
  397:     if ($plainname=~/^\s*$/) { $plainname=$uname; }
  398:     return &Apache::lonxml::latex_special_symbols($plainname,undef,undef,
  399: 						  'header');
  400: }
  401: 
  402: 
  403: sub page_format_transformation {
  404:     my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_; 
  405:     my ($textwidth,$textheight,$oddoffset,$evenoffset);
  406: 	$assignment=~s/_/ /g;
  407:         if ($numberofcolumns != 1) {
  408:           ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns);
  409: 	} else {
  410: 	  ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'});
  411: 	}
  412:     my $name = &get_name();
  413:     if ($name =~ /^\s*$/) {
  414: 	$name=&Apache::lonxml::latex_special_symbols($ENV{'user.name'},undef,
  415: 						     undef,'header');
  416:     }
  417:     my $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'','','header');
  418:     if ($layout eq 'album') {
  419: 	    $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm} \\begin{document}\\setcounter{page}{1}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$name}} \\hfill  $courseidinfo} \\vskip 5 mm /;
  420:     } elsif ($layout eq 'book') {
  421: 	if ($choice ne 'All class print') { 
  422: 		$text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
  423: 	} else {
  424: 	    $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1}  \\vskip 5 mm /;
  425: 
  426: 	}
  427:     }
  428:     return $text;
  429: }
  430: 
  431: 
  432: sub page_cleanup {
  433:     my $result = shift;	
  434:  
  435:     $result =~ m/\\end{document}(\d*)$/;
  436:     my $number_of_columns = $1;
  437:     my $insert = '{';
  438:     for (my $id=1;$id<=$number_of_columns;$id++) { $insert .='l'; }
  439:     $insert .= '}';
  440:     $result =~ s/(\\begin{longtable})INSERTTHEHEADOFLONGTABLE\\endfirsthead\\endhead/$1$insert/g;
  441:     $result =~ s/&\s*REMOVETHEHEADOFLONGTABLE\\\\/\\\\/g;
  442:     return $result,$number_of_columns;
  443: }
  444: 
  445: 
  446: sub details_for_menu {
  447: 
  448:     my $name_of_resourse = $hash{'title_'.$hash{'ids_'.$ENV{'form.postdata'}}};
  449:     my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'});
  450:     my ($map,$id,$resource)=split(/___/,$symbolic);
  451:     $map=&Apache::lonnet::clutter($map);
  452:     my $name_of_sequence;
  453:     $name_of_sequence = $hash{'title_'.$hash{'ids_'.$map}};
  454:     if ($name_of_sequence =~ /^\s*$/) {
  455: 	$map =~ m|([^/]+)$|;
  456: 	$name_of_sequence = $1;
  457:     }
  458:     my $name_of_map = $hash{'title_'.$hash{'ids_'.&Apache::lonnet::clutter($ENV{'request.course.uri'})}};
  459:     if ($name_of_map =~ /^\s*$/) {
  460: 	$ENV{'request.course.uri'} =~ m|([^/]+)$|;
  461: 	$name_of_map = $1;
  462:     }
  463:     return ($name_of_resourse,$name_of_sequence,$name_of_map);
  464: 
  465: }
  466: 
  467: 
  468: sub latex_corrections {
  469: 
  470:     my ($number_of_columns,$result) = @_;
  471: 
  472:     $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g;
  473:     $result =~ s/\$number_of_columns/$number_of_columns/g;
  474:     $result =~ s/(\\end{document})/\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License  $1/;
  475:     $result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g;
  476:     $result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g;
  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:     }
  484:     $result =~ s/^\s+$//gm; #remove empty lines
  485:     $result =~ s/(\s)(\s+)/$1/g; #removes more than one empty space
  486:     $result =~ s/\\\\\s*\\vskip/\\vskip/gm;
  487:     $result =~ s/\\\\\s*\\noindent\s*(\\\\)+/\\\\\\noindent /g;
  488:     $result =~ s/{\\par }\s*\\\\/\\\\/gm;
  489: 	$result =~ s/\\\\\s+\[/ \[/g;
  490:     $result =~ s/\b__+\b/\\makebox\[1 cm\]\[b\]{\\hrulefill}/g;
  491:     #conversion of html characters to LaTeX equivalents
  492:     if ($result =~ m/&(\w+|#\d+);/) {
  493: 	$result = &character_chart($result);
  494:     }
  495:     $result =~ s/(\\end{tabular})\s*\\vskip 0 mm/$1/g;
  496:     $result =~ s/(\\begin{enumerate})\s*\\noindent/$1/g;
  497: 
  498:     return $result;
  499: }
  500: 
  501: 
  502: sub output_data {
  503:     my ($r,$helper) = @_;
  504:     $r->print(<<ENDPART);
  505: <html>
  506: <head>
  507: <title>LON-CAPA output for printing</title>
  508: </head>
  509: <body bgcolor="FFFFFF">
  510: <hr>
  511: ENDPART
  512: 
  513:     my $format_from_helper = $helper->{'VARS'}->{'FORMAT'};
  514:     my ($result,$selectionmade) = ('','');
  515:     my $number_of_columns = 1; #used only for pages to determine the width of the cell
  516:     my @temporary_array=split /\|/,$format_from_helper;
  517:     my ($laystyle,$numberofcolumns,$papersize)=@temporary_array;
  518:     if ($laystyle eq 'L') {
  519: 	$laystyle='album';
  520:     } else {
  521: 	$laystyle='book';
  522:     }
  523:     my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);
  524:     my $assignment =  $ENV{'form.assignment'};
  525:     my $LaTeXwidth; 
  526:     if ($textwidth=~/(\d+)\s*cm/) {
  527: 	$LaTeXwidth = $1*10;
  528:     } elsif ($textwidth=~/(\d+)\s*mm/) {
  529: 	$LaTeXwidth = $1;
  530:     } elsif ($textwidth=~/(\d+)\s*in/) {
  531: 	$LaTeXwidth = $1*25.4;
  532:     }
  533:     $LaTeXwidth.=' mm';
  534:     
  535:     if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
  536:       #-- single document - problem, page, html, xml, ...
  537: 	my $currentURL;
  538: 	if ($helper->{'VARS'}->{'construction'} ne '1') {
  539:             #prins published resource
  540: 	    $currentURL=$helper->{'VARS'}->{'postdata'};
  541: 	} else {
  542:             #prins resource from the construction space
  543: 	    $currentURL=$helper->{'VARS'}->{'filename'};
  544: 	    $currentURL=~s/\/home\//\/~/;
  545: 	    $currentURL=~s/public_html\///;
  546: 	}
  547: 	$selectionmade = 1;
  548: 	if ($currentURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
  549: 	    my %moreenv;
  550: 	    $moreenv{'request.filename'}=$currentURL;
  551: 	    my %form;
  552: 	    $form{'grade_target'}='tex';
  553: 	    $form{'textwidth'}=$LaTeXwidth;
  554: 	    my $rndseed=time;
  555: 	    $form{'rndseed'}=$rndseed;
  556: 	    &Apache::lonnet::appenv(%moreenv);
  557: 	    my $texversion=&Apache::lonnet::ssi($currentURL,%form);
  558: 	    &Apache::lonnet::delenv('form.counter');
  559: 	    &Apache::lonnet::delenv('request.filename');
  560: 	    if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
  561: 		my %form;
  562: 		$form{'grade_target'}='answer';
  563: 		$form{'answer_output_mode'}='tex';
  564: 		$form{'rndseed'}=$rndseed;
  565: 		my $answer=&Apache::lonnet::ssi($currentURL,%form);
  566: 		$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
  567: 	    }
  568: 	    $result .= $texversion;
  569: 	    if ($currentURL=~m/\.page\s*$/) {
  570: 		($result,$number_of_columns) = &page_cleanup($result);
  571: 	    }
  572: 	} else {
  573: #	  $result='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';
  574: #	  if ($ENV{'form.url'}=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {
  575: #	      $result.=$1;
  576: #	  } else {
  577: #	      $result.=$ENV{'form.url'};
  578: #	  }
  579: #	  $result.=' \end{document}'
  580: 	}
  581:     } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or
  582:              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
  583:              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems')) { 
  584:         #-- produce an output string
  585: 	my $flag_latex_header_remove = 'NO';
  586: 	my $flag_page_in_sequence = 'NO';
  587: 	my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
  588: 	for (my $i=0;$i<=$#master_seq;$i++) {
  589: 	    $master_seq[$i]=~/___\d+___(.*)$/;
  590: 	    my $urlp='/res/'.$1;
  591: 	    if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
  592: 		$selectionmade = 2;
  593: 	    } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
  594: 		$selectionmade = 3;
  595: 	    } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {
  596: 		$selectionmade = 4;
  597: 	    }
  598: 	    my %form;	   
  599: 	    $form{'grade_target'}='tex';
  600: 	    $form{'textwidth'}=$LaTeXwidth;
  601: 	    $form{'symb'}=$master_seq[$i];
  602: 	    #&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]");
  603: 	    my $texversion=&Apache::lonnet::ssi($urlp,%form);
  604: 	    if ($urlp=~/\.page$/) {
  605: 		($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
  606: 		if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} 
  607: 		$texversion =~ s/\\end{document}\d*/\\end{document}/;
  608: 		$flag_page_in_sequence = 'YES';
  609: 	    } 
  610: 	    if ($flag_latex_header_remove ne 'NO') {
  611: 		$texversion = &latex_header_footer_remove($texversion);
  612: 	    } else {
  613: 		$texversion =~ s/\\end{document}//;
  614: 	    }
  615: 	    if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
  616: 		my %form;
  617: 		$form{'grade_target'}='answer';
  618: 		$form{'answer_output_mode'}='tex';
  619: 		my $answer=&Apache::lonnet::ssi($urlp,%form);
  620: 		$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
  621: 	    }
  622: 	    $result .= $texversion;         
  623: 	    $flag_latex_header_remove = 'YES';   
  624: 	}
  625: 	&Apache::lonnet::delenv('form.counter');
  626: 	if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;}	
  627: 	$result .= '\end{document}';
  628:      } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') { 
  629:      #-- prints assignments for whole class or for selected students  
  630: 	 $selectionmade=5;
  631: 	 my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'};
  632: 	 my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
  633: 	 #loop over students
  634: 	 my $flag_latex_header_remove = 'NO'; 
  635: 	 my %moreenv;
  636: 	 $moreenv{'form.textwidth'}=$LaTeXwidth;
  637: 	 &Apache::lonnet::appenv(%moreenv);
  638: 	 my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
  639: 	 foreach my $person (@students) {
  640: 	    my $current_output = ''; 
  641: #	    my ($usersection,$username,$userdomain) = split /:/,$person;
  642: 	    my ($username,$userdomain) = split /:/,$person;
  643: 	    my $fullname = &get_name($username,$userdomain);
  644:             #goes through all resources, checks if they are available for current student, and produces output   
  645: 	    foreach my $curresline (@master_seq)  {
  646: 		if ($curresline=~ m/\.(problem|exam|quiz|assess|survey|form|library)$/) {
  647: 		    my ($map,$id,$res_url) = split(/___/,$curresline);
  648: 		    if (&Apache::lonnet::allowed('bre',$res_url)) {
  649: 			my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,
  650:                                                                         $ENV{'request.course.id'},'tex');
  651: 			if ($flag_latex_header_remove eq 'YES') {
  652: 			    $rendered = &latex_header_footer_remove($rendered);
  653: 			} else {
  654: 			    $rendered =~ s/\\end{document}//;
  655: 			}
  656: 			if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
  657: 			    my %form;
  658: 			    $form{'answer_output_mode'}='tex';
  659: 			    my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,
  660: 										      $ENV{'request.course.id'},%form);
  661: 			    $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;
  662: 			}
  663: 			$current_output .= $rendered;
  664: 		    }
  665: 		    $flag_latex_header_remove = 'YES';
  666: 		}
  667: 	    }
  668: 	    my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
  669: 	    if ($current_output=~/\\documentclass/) {
  670: 		$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$helper->{VARS}->{'assignment'}}}\\vskip 3 mm /;
  671: 	    } else {
  672: 		my $blanspages = '';
  673: 		for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blanspages.='\clearpage\strut\clearpage';}
  674: 		$current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}} - '.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$helper->{VARS}->{'assignment'}.'}}} \vskip -5 mm '.$current_output;
  675: 	    }
  676: 	    $result .= $current_output;
  677: 	    &Apache::lonnet::delenv('form.counter');	    
  678: 	    &Apache::lonxml::init_counter(); 
  679: 	    &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
  680: 						    'last student '.$fullname);
  681: 	}
  682: 	&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
  683: 	$result .= '\end{document}';
  684: 	&Apache::lonnet::delenv('form.textwidth');
  685:     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') {      
  686:     #prints selected problems from the subdirectory 
  687: 	$selectionmade = 6;
  688:         my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'};
  689: 	@list_of_files=sort @list_of_files;
  690: 	my $flag_latex_header_remove = 'NO'; 
  691: 	my $rndseed=time;
  692: 	for (my $i=0;$i<=$#list_of_files;$i++) {
  693: 	    my $urlp = $list_of_files[$i];
  694: 	    if ($urlp=~/\//) {
  695: 		my %form;
  696: 		$form{'grade_target'}='tex';
  697: 		$form{'textwidth'}=$LaTeXwidth;
  698: 		$form{'rndseed'}=$rndseed;
  699: 		if ($urlp =~ m|/home/([^/]+)/public_html|) {
  700: 		    $urlp =~ s|/home/([^/]*)/public_html|/~$1|;
  701: 		} else {
  702: 		    $urlp =~ s|^/home/httpd/html||;
  703: 		}
  704: 		my $texversion=&Apache::lonnet::ssi($urlp,%form);
  705: 		if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
  706: 		    my %form;
  707: 		    $form{'grade_target'}='answer';
  708: 		    $form{'answer_output_mode'}='tex';
  709: 		    $form{'rndseed'}=$rndseed;
  710: 		    my $answer=&Apache::lonnet::ssi($urlp,%form);
  711: 		    $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
  712: 		}
  713:                 #this chunck is responsible for printing the path to problem
  714: 		my $newurlp = '';
  715: 		my $HowMany = length($urlp)*2;
  716: 		if ($HowMany > $LaTeXwidth) {
  717: 		    my @temporrary = split '/',$urlp;
  718: 		    my $HowManyNew = 0;
  719: 		    for (my $ii=0;$ii<=$#temporrary;$ii++) {
  720: 			if ($temporrary[$ii] ne '') {
  721: 			    $HowManyNew += length($temporrary[$ii])*2;
  722: 			    if ($HowManyNew < $LaTeXwidth ) {
  723: 				$newurlp .=  '/'.$temporrary[$ii];
  724: 			    } else {
  725: 				$HowManyNew = 0;
  726: 				$newurlp .=  '|\vskip -1 mm \noindent \verb|';
  727: 				$ii--;
  728: 			    }
  729: 			}
  730: 		    }
  731: 		}
  732: 		$texversion =~ s/(\\begin{minipage}{\\textwidth})/$1 {\\small\\noindent\\verb|$newurlp\|\\vskip 0 mm}/;
  733: 		if ($flag_latex_header_remove ne 'NO') {
  734: 		    $texversion = &latex_header_footer_remove($texversion);
  735: 		} else {
  736: 		    $texversion =~ s/\\end{document}//;
  737: 		}
  738: 		$result .= $texversion;
  739: 	    }
  740: 	    $flag_latex_header_remove = 'YES';  
  741: 	}
  742: 	if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\typeout)/ RANDOM SEED IS $rndseed $1/;}
  743: 	$result .= '\end{document}';      	
  744:     }
  745: #-------------------------------------------------------- corrections for the different page formats
  746:     $result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'});
  747: #    if ($layout eq 'CBI') {
  748: #        $laystyle = 'album';
  749: #    }
  750:     $result = &latex_corrections($number_of_columns,$result);
  751: #    #changes page's parameters for the one column output 
  752: #    if ($ENV{'form.numberofcolumns'} == 1) {
  753: #	$result =~ s/\\textwidth= 9cm/\\textwidth= $ENV{'form.width'}/;
  754: #	$result =~ s/\\textheight 25\.9cm/\\textheight $ENV{'form.height'}/;
  755: #	$result =~ s/\\evensidemargin = -0\.57in/\\evensidemargin= $ENV{'form.leftmargin'}/;
  756: #	$result =~ s/\\oddsidemargin = -0\.57in/\\oddsidemargin= $ENV{'form.leftmargin'}/;
  757: #    }
  758: #-- writing .tex file in prtspool 
  759:     my $temp_file;
  760:     my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex";
  761:     unless ($temp_file = Apache::File->new('>'.$filename)) {
  762: 	$r->log_error("Couldn't open $filename for output $!");
  763: 	return SERVER_ERROR; 
  764:     } 
  765:     print $temp_file $result;
  766: 
  767: #<meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$filename&$laystyle&$numberofcolumns&$selectionmade">
  768: $r->print(<<FINALEND);
  769: <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$filename&$laystyle&$numberofcolumns&$selectionmade">
  770: </body>
  771: </html>
  772: FINALEND
  773: }
  774: 
  775: 
  776: 
  777: sub handler {
  778: 
  779:     my $r = shift;
  780:     my $helper;
  781: 
  782: #    my $loaderror=&Apache::lonnet::overloaderror($r);
  783: #    if ($loaderror) { return $loaderror; }
  784: #    $loaderror=
  785: #       &Apache::lonnet::overloaderror($r,
  786: #         $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
  787: #    if ($loaderror) { return $loaderror; }
  788: 
  789:     my $result = printHelper($r);
  790:     if (!ref($result)) {
  791: 	return $result;
  792:     }
  793:     $helper = $result;
  794:    
  795: #	my $key; 
  796: #	foreach $key (keys %{$helper->{'VARS'}}) {
  797: #	    $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-<br />');
  798: #	}
  799: #	return OK;
  800: 	
  801:     &output_data($r,$helper);
  802:     return OK;
  803: } 
  804: 
  805: use Apache::lonhelper;
  806: 
  807: sub printHelper {
  808:     my $r = shift;
  809: 
  810:     if ($ENV{'request.course.id'}) {
  811: 	my $fn=$ENV{'request.course.fn'};
  812: 	tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640);
  813:     }
  814: 
  815:     if ($r->header_only) {
  816:         if ($ENV{'browser.mathml'}) {
  817:             $r->content_type('text/xml');
  818:         } else {
  819:             $r->content_type('text/html');
  820:         }
  821:         $r->send_http_header;
  822:         return OK;
  823:     }
  824: 
  825:     # Send header, nocache
  826:     if ($ENV{'browser.mathml'}) {
  827:         $r->content_type('text/xml');
  828:     } else {
  829:         $r->content_type('text/html');
  830:     }
  831:     &Apache::loncommon::no_cache($r);
  832:     $r->send_http_header;
  833:     $r->rflush();
  834: 
  835:     # Unfortunately, this helper is so complicated we have to
  836:     # write it by hand
  837: 
  838:     Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
  839:     
  840:     my $helper = Apache::lonhelper::helper->new("Printing Helper");
  841:     $helper->declareVar('symb');
  842:     $helper->declareVar('postdata');    
  843:     $helper->declareVar('filename');
  844:     $helper->declareVar('construction');
  845:     $helper->declareVar('assignment');
  846:     
  847:     # This will persistently load in the data we want from the
  848:     # very first screen.
  849:     # Detect whether we're coming from construction space
  850:     if ($ENV{'form.postdata'} =~ /http:\/\// ) {
  851:         $ENV{'form.postdata'} =~ /http:\/\/[a-zA-Z.]+\/~([a-zA-Z0-9]+)\/(.*)/;
  852:         $helper->{VARS}->{'filename'} = "/home/$1/public_html/$2";
  853:         $helper->{VARS}->{'construction'} = 1;
  854:     } else {
  855:         if ($ENV{'form.postdata'}) {
  856:             $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'});
  857:         }
  858:         if ($ENV{'form.symb'}) {
  859:             $helper->{VARS}->{'symb'} = $ENV{'form.symb'};
  860:         }
  861:         if ($ENV{'form.url'}) {
  862:             $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
  863:         }
  864:     }
  865: 
  866:     if ($ENV{'form.symb'}) {
  867:         $helper->{VARS}->{'symb'} = $ENV{'form.symb'};
  868:     }
  869:     if ($ENV{'form.url'}) {
  870:         $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
  871: 
  872:     }
  873:     
  874:     my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu;
  875:     if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;}
  876: 
  877:     
  878:     # Extract map
  879:     my $symb = $helper->{VARS}->{'symb'};
  880:     my ($map, $id, $url);
  881:     my $subdir;
  882: 
  883:     # Get the resource name from construction space
  884:     if ($helper->{VARS}->{'construction'}) {
  885:         $resourceTitle = substr($helper->{VARS}->{'filename'}, 
  886:                                 rindex($helper->{VARS}->{'filename'}, '/')+1);
  887:         $subdir = substr($helper->{VARS}->{'filename'},
  888:                          0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
  889:     } else {
  890:         ($map, $id, $url) = split(/___/, $symb);
  891:         $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);
  892: 
  893:         if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
  894:             my $url = $helper->{VARS}->{'postdata'};
  895:             $resourceTitle = substr($url, rindex($url, '/') + 1);
  896:         }
  897:         $subdir = &Apache::lonnet::filelocation("", $url);
  898:     }
  899: 
  900:     Apache::lonhelper::registerHelperTags();
  901: 
  902:     # "Delete everything after the last slash."
  903:     $subdir =~ s|/[^/]+$||;
  904:     if (not $helper->{VARS}->{'construction'}) {
  905: 	$subdir='/home/httpd/html/res/'.$subdir;
  906:     }
  907: 
  908:     # What can be printed is a very dynamic decision based on
  909:     # lots of factors. So we need to dynamically build this list.
  910:     # To prevent security leaks, states are only added to the wizard
  911:     # if they can be reached, which ensures manipulating the form input
  912:     # won't allow anyone to reach states they shouldn't have permission
  913:     # to reach.
  914: 
  915:     # printChoices is tracking the kind of printing the user can
  916:     # do, and will be used in a choices construction later.
  917:     # In the meantime we will be adding states and elements to
  918:     # the helper by hand.
  919:     my $printChoices = [];
  920:     my $paramHash;
  921: 
  922:     if ($resourceTitle) {
  923:         push @{$printChoices}, ["<b>$resourceTitle</b> (prints what you just saw on the screen)", 'current_document', 'PAGESIZE'];
  924:     }
  925: 
  926:     $r->print($helper->{VARS}->{'postdata'});
  927: 
  928:     # If we're in a sequence...
  929:     if ($helper->{'VARS'}->{'construction'} ne '1') {
  930:         # Allow problems from sequence
  931:         push @{$printChoices}, ["Problem(s) from <b>$sequenceTitle</b>", 'map_problems', 'CHOOSE_PROBLEMS'];
  932:         # Allow all resources from sequence
  933:         push @{$printChoices}, ["Everything (problem(s), page(s), html/xml file(s)) from <b>$sequenceTitle</b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
  934: 
  935:         my $isProblem = '$res->is_problem();';
  936:         my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
  937:         my $isNotMap = '!$res->is_map();';
  938:         my $symb = '$res->symb();';
  939:         my $helperFragment = <<HELPERFRAGMENT;
  940:   <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
  941:     <message>(mark them then click "next" button) <br /></message>
  942:     <resource variable="RESOURCES" multichoice="1" toponly='1'>
  943:       <nextstate>PAGESIZE</nextstate>
  944:       <filterfunc>return $isProblem</filterfunc>
  945:       <mapurl>$map</mapurl>
  946:       <valuefunc>return $symb</valuefunc>
  947:       </resource>
  948:     </state>
  949: 
  950:   <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">
  951:     <message>(mark them then click "next" button) <br /></message>
  952:     <resource variable="RESOURCES" multichoice="1" toponly='1'>
  953:       <nextstate>PAGESIZE</nextstate>
  954:       <filterfunc>return $isNotMap;</filterfunc>
  955:       <mapurl>$map</mapurl>
  956:       <valuefunc>return $symb</valuefunc>
  957:       </resource>
  958:     </state>
  959: HELPERFRAGMENT
  960: 
  961:         &Apache::lonxml::xmlparse($r, 'helper', $helperFragment); 
  962:     }
  963: 
  964:     # If the user is priviledged, allow them to print all 
  965:     # problems in the course, optionally for selected students
  966:     if (($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) and ($helper->{VARS}->{'postdata'}=~/\/res\//)) { 
  967:         push @{$printChoices}, ['<b>Problems</b> in this course', 'all_problems', 'ALL_PROBLEMS'];
  968:         push @{$printChoices}, ["Problems from <b>$sequenceTitle</b> for selected students", 'problems_for_students', 'CHOOSE_STUDENTS'];
  969: 
  970:         my $isProblem = '$res->is_problem();';
  971:         my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
  972:         my $symb = '$res->symb();';
  973:         &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
  974:   <state name="ALL_PROBLEMS" title="Select Problem(s) to print">
  975:     <message>(mark them then click "next" button) <br /></message>
  976:     <resource variable="RESOURCES" multichoice="1" suppressEmptySequences='1'>
  977:       <nextstate>PAGESIZE</nextstate>
  978:       <filterfunc>return $isProblemOrMap</filterfunc>
  979:       <choicefunc>return $isProblem</choicefunc>
  980:       <valuefunc>return $symb</valuefunc>
  981:       </resource>
  982:     </state>
  983: 
  984:   <state name="CHOOSE_STUDENTS" title="Choose Students whose assignments you want to print">
  985:     <message>(do not forget to select assignment itself - make another selection below) <br /></message>
  986:     <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />
  987:     <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
  988:     <resource variable="RESOURCES" multichoice="1">
  989:       <filterfunc>return $isProblem</filterfunc>
  990:       <mapurl>$map</mapurl>
  991:       <valuefunc>return $symb</valuefunc>
  992:       </resource>
  993:     <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
  994:     <choices variable="EMPTY_PAGES">
  995:       <choice computer='0'>Start student assignment from new page (add pagefeed after each student)</choice>
  996:       <choice computer='1'>Add one emty page after each student assignment</choice> 
  997:       <choice computer='2'>Add two emty page after each student assignment</choice> 
  998:       </choices>
  999:     </state>
 1000: CHOOSE_STUDENTS
 1001:     }
 1002: 
 1003:     # FIXME: That RE should come from a library somewhere.
 1004:     if (((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) {    
 1005:         push @{$printChoices}, ["Problems from current subdirectory <b>$subdir</b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
 1006:         
 1007:         my $f = '$filename';
 1008:         my $xmlfrag = <<CHOOSE_FROM_SUBDIR;
 1009:   <state name="CHOOSE_FROM_SUBDIR" title="Select File(s) from <b><small>$subdir</small></b> to print">
 1010:     <message>(mark them then click "next" button) <br /></message>
 1011:     <files variable="FILES" multichoice='1'>
 1012:       <nextstate>PAGESIZE</nextstate>
 1013:       <filechoice>return '$subdir';</filechoice>
 1014: CHOOSE_FROM_SUBDIR
 1015:         
 1016:         $xmlfrag .= <<'CHOOSE_FROM_SUBDIR';
 1017:       <filefilter>return $filename =~ 
 1018:            m/^[^\.]+\.(problem|exam|quiz|assess|survey|form|library)$/;
 1019:       </filefilter>
 1020:       </files>
 1021:     </state>
 1022: CHOOSE_FROM_SUBDIR
 1023:         &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
 1024:     }
 1025: 
 1026:     # Generate the first state, to select which resources get printed.
 1027:     Apache::lonhelper::state->new("START", "What do you want to print? Make a choice.");
 1028:     $paramHash = Apache::lonhelper::getParamHash();
 1029:     $paramHash->{MESSAGE_TEXT} = "";
 1030:     Apache::lonhelper::message->new();
 1031:     $paramHash = Apache::lonhelper::getParamHash();
 1032:     $paramHash->{'variable'} = 'PRINT_TYPE';
 1033:     $helper->declareVar('PRINT_TYPE');
 1034:     $paramHash->{CHOICES} = $printChoices;
 1035:     Apache::lonhelper::choices->new();
 1036: 
 1037:     if (($ENV{'request.role.adv'} and &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) or 
 1038: 	($helper->{VARS}->{'construction'} eq '1')) {
 1039:         $paramHash = Apache::lonhelper::getParamHash();
 1040:         $paramHash->{MESSAGE_TEXT} = "<br /><big><b><i>Next option is available only for advanced users:</i></b></big><br />";
 1041:         Apache::lonhelper::message->new();
 1042:         $paramHash = Apache::lonhelper::getParamHash();
 1043: 	$paramHash->{'variable'} = 'ANSWER_TYPE';   
 1044: 	$helper->declareVar('ANSWER_TYPE');         
 1045:         $paramHash->{CHOICES} = [
 1046:                                    ['Print without answer', 'yes'],
 1047:                                    ['Print with answers', 'no'] ];
 1048:         Apache::lonhelper::choices->new();
 1049:     }
 1050: 
 1051:     Apache::lonprintout::page_format_state->new("FORMAT");
 1052: 
 1053:     # Generate the PAGESIZE state which will offer the user the margin
 1054:     # choices if they select one column
 1055:     Apache::lonhelper::state->new("PAGESIZE", "Set Margins");
 1056:     Apache::lonprintout::page_size_state->new('pagesize', 'FORMAT', 'FINAL');
 1057: 
 1058: 
 1059:     $helper->process();
 1060: 
 1061:     # MANUAL BAILOUT CONDITION:
 1062:     # If we're in the "final" state, bailout and return to handler
 1063:     if ($helper->{STATE} eq 'FINAL') {
 1064:         return $helper;
 1065:     }    
 1066: 
 1067:     $r->print($helper->display());
 1068: 
 1069:     Apache::lonhelper::unregisterHelperTags();
 1070: 
 1071:     untie %hash;
 1072: 
 1073:     return OK;
 1074: }
 1075: 
 1076: 
 1077: 1;
 1078: 
 1079: package Apache::lonprintout::page_format_state;
 1080: 
 1081: =pod
 1082: 
 1083: =head1 Helper element: page_format_state
 1084: 
 1085: See lonhelper.pm documentation for discussion of the helper framework.
 1086: 
 1087: Apache::lonprintout::page_format_state is an element that gives the 
 1088: user an opportunity to select the page layout they wish to print 
 1089: with: Number of columns, portrait/landscape, and paper size. If you 
 1090: want to change the paper size choices, change the @paperSize array 
 1091: contents in this package.
 1092: 
 1093: page_format_state is always directly invoked in lonprintout.pm, so there
 1094: is no tag interface. You actually pass parameters to the constructor.
 1095: 
 1096: =over 4
 1097: 
 1098: =item * B<new>(varName): varName is where the print information will be stored in the format FIXME.
 1099: 
 1100: =back
 1101: 
 1102: =cut
 1103: 
 1104: use Apache::lonhelper;
 1105: 
 1106: no strict;
 1107: @ISA = ("Apache::lonhelper::element");
 1108: use strict;
 1109: 
 1110: my $maxColumns = 2;
 1111: my @paperSize = ("Letter [8 1/2x11 in]", "Legal [8 1/2x14 in]", 
 1112:                  "Ledger/Tabloid [11x17 in]", "Executive [7 1/2x10 in]",
 1113:                  "A2 [420x594 mm]", "A3 [297x420 mm]", "A4 [210x297 mm]", 
 1114:                  "A5 [148x210 mm]", "A6 [105x148 mm]" );
 1115: 
 1116: # Tentative format: Orientation (L = Landscape, P = portrait) | Colnum |
 1117: #                   Paper type
 1118: 
 1119: sub new { 
 1120:     my $self = Apache::lonhelper::element->new();
 1121: 
 1122:     shift;
 1123: 
 1124:     $self->{'variable'} = shift;
 1125:     my $helper = Apache::lonhelper::getHelper();
 1126:     $helper->declareVar($self->{'variable'});
 1127:     bless($self);
 1128:     return $self;
 1129: }
 1130: 
 1131: sub render {
 1132:     my $self = shift;
 1133:     my $helper = Apache::lonhelper::getHelper();
 1134:     my $result = '';
 1135:     my $var = $self->{'variable'};
 1136: 
 1137:     $result .= <<STATEHTML;
 1138: 
 1139: <p><big><i><b>What page format do you prefer?</b></i></big></p>
 1140: <table cellpadding="3">
 1141:   <tr>
 1142:     <td align="center"><b>Page layout</b></td>
 1143:     <td align="center"><b>Number of columns</b></td>
 1144:     <td align="center"><b>Paper type</b></td>
 1145:   </tr>
 1146:   <tr>
 1147:     <td>
 1148:       <input type="radio" name="${var}.layout" value="L" /> Landscape<br />
 1149:       <input type="radio" name="${var}.layout" value="P" checked='1'  /> Portrait
 1150:     </td>
 1151:     <td align="center">
 1152:       <select name="${var}.cols">
 1153: STATEHTML
 1154: 
 1155:     my $i;
 1156:     for ($i = 1; $i <= $maxColumns; $i++) {
 1157:         if ($i == 2) {
 1158:             $result .= "<option value='$i' selected>$i</option>\n";
 1159:         } else {
 1160:             $result .= "<option value='$i'>$i</option>\n";
 1161:         }
 1162:     }
 1163: 
 1164:     $result .= "</select></td><td>\n";
 1165:     $result .= "<select name='${var}.paper'>\n";
 1166: 
 1167:     $i = 0;
 1168:     foreach (@paperSize) {
 1169:         if ($i == 0) {
 1170:             $result .= "<option selected value='$i'>" . $paperSize[$i] . "</option>\n";
 1171:         } else {
 1172:             $result .= "<option value='$i'>" . $paperSize[$i] . "</option>\n";
 1173:         }
 1174:         $i++;
 1175:     }
 1176: 
 1177:     $result .= "</select></td></tr></table>";
 1178:     return $result;
 1179: }
 1180: 
 1181: sub postprocess {
 1182:     my $self = shift;
 1183: 
 1184:     my $var = $self->{'variable'};
 1185:     my $helper = Apache::lonhelper->getHelper();
 1186:     $helper->{VARS}->{$var} = 
 1187:         $ENV{"form.$var.layout"} . '|' . $ENV{"form.$var.cols"} . '|' .
 1188:         $ENV{"form.$var.paper"};
 1189:     return 1;
 1190: }
 1191: 
 1192: 1;
 1193: 
 1194: package Apache::lonprintout::page_size_state;
 1195: 
 1196: =pod
 1197: 
 1198: =head1 Helper element: page_size_state
 1199: 
 1200: See lonhelper.pm documentation for discussion of the helper framework.
 1201: 
 1202: Apache::lonprintout::page_size_state is an element that gives the 
 1203: user the opportunity to further refine the page settings if they
 1204: select a single-column page.
 1205: 
 1206: page_size_state is always directly invoked in lonprintout.pm, so there
 1207: is no tag interface. You actually pass parameters to the constructor.
 1208: 
 1209: =over 4
 1210: 
 1211: =item * B<new>(varName): varName is where the print information will be stored in the format FIXME.
 1212: 
 1213: =back
 1214: 
 1215: =cut
 1216: 
 1217: use Apache::lonhelper;
 1218: 
 1219: no strict;
 1220: @ISA = ("Apache::lonhelper::element");
 1221: use strict;
 1222: 
 1223: 
 1224: 
 1225: sub new { 
 1226:     my $self = Apache::lonhelper::element->new();
 1227: 
 1228:     shift; # disturbs me (probably prevents subclassing) but works (drops
 1229:            # package descriptor)... - Jeremy
 1230: 
 1231:     $self->{'variable'} = shift;
 1232:     my $helper = Apache::lonhelper::getHelper();
 1233:     $helper->declareVar($self->{'variable'});
 1234: 
 1235:     # The variable name of the format element, so we can look into 
 1236:     # $helper->{VARS} to figure out whether the columns are one or two
 1237:     $self->{'formatvar'} = shift;
 1238: 
 1239:     # The state to transition to after selection, or after discovering
 1240:     # the cols are not set to 1
 1241:     $self->{NEXTSTATE} = shift;
 1242:     bless($self);
 1243:     return $self;
 1244: }
 1245: 
 1246: sub render {
 1247:     my $self = shift;
 1248:     my $helper = Apache::lonhelper::getHelper();
 1249:     my $result = '';
 1250:     my $var = $self->{'variable'};
 1251: 
 1252:     if (defined $self->{ERROR_MSG}) {
 1253:         $result .= '<br /><font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br />';
 1254:     }
 1255: 
 1256:     $result .= <<ELEMENTHTML;
 1257: 
 1258: <p>How should the column be formatted?</p>
 1259: 
 1260: <table cellpadding='3'>
 1261:   <tr>
 1262:     <td align='right'><b>Width</b>:</td>
 1263:     <td align='left'><input type='text' name='$var.width' value='18' size='4'></td>
 1264:     <td align='left'>
 1265:       <select name='$var.widthunit'>
 1266:         <option>cm</option><option>in</option>
 1267:       </select>
 1268:     </td>
 1269:   </tr>
 1270:   <tr>
 1271:     <td align='right'><b>Height</b>:</td>
 1272:     <td align='left'><input type='text' name="$var.height" value="25.9" size='4'></td>
 1273:     <td align='left'>
 1274:       <select name='$var.heightunit'>
 1275:         <option>cm</option><option>in</option>
 1276:       </select>
 1277:     </td>
 1278:   </tr>
 1279:   <tr>
 1280:     <td align='right'><b>Left margin</b>:</td>
 1281:     <td align='left'><input type='text' name='$var.lmargin' value='-1.5' size='4'></td>
 1282:     <td align='left'>
 1283:       <select name='$var.heightunit'>
 1284:         <option>cm</option><option>in</option>
 1285:       </select>
 1286:     </td>
 1287:   </tr>
 1288: </table>
 1289: 
 1290: <p>Hint: Some instructors like to leave scratch space for the student by
 1291: making the width much smaller then the width of the page.</p>
 1292: 
 1293: ELEMENTHTML
 1294: 
 1295:     return $result;
 1296: }
 1297: 
 1298: # If the user didn't select 1 column, skip this state.
 1299: sub preprocess {
 1300:     my $self = shift;
 1301:     my $helper = Apache::lonhelper::getHelper();
 1302: 
 1303:     my $format = $helper->{VARS}->{$self->{'formatvar'}};
 1304:     if (substr($format, 2, 1) ne '1') {
 1305:         $helper->changeState($self->{NEXTSTATE});
 1306:     }
 1307:    
 1308:     return 1;
 1309: }
 1310: 
 1311: sub postprocess {
 1312:     my $self = shift;
 1313: 
 1314:     my $var = $self->{'variable'};
 1315:     my $helper = Apache::lonhelper->getHelper();
 1316:     my $width = $helper->{VARS}->{$var .'.width'} = $ENV{"form.${var}.width"}; 
 1317:     my $height = $helper->{VARS}->{$var .'.height'} = $ENV{"form.${var}.height"}; 
 1318:     my $lmargin = $helper->{VARS}->{$var .'.lmargin'} = $ENV{"form.${var}.lmargin"}; 
 1319:     $helper->{VARS}->{$var .'.widthunit'} = $ENV{"form.${var}.widthunit"}; 
 1320:     $helper->{VARS}->{$var .'.heightunit'} = $ENV{"form.${var}.heightunit"}; 
 1321:     $helper->{VARS}->{$var .'.lmarginunit'} = $ENV{"form.${var}.lmarginunit"}; 
 1322: 
 1323:     my $error = '';
 1324: 
 1325:     # /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed 
 1326:     # by an optional period, followed by digits, ending the string
 1327: 
 1328:     if ($width !~  /^-?[0-9]+(\.[0-9]*)?$/) {
 1329:         $error .= "Invalid width; please type only a number.<br />\n";
 1330:     }
 1331:     if ($height !~  /^-?[0-9]+(\.[0-9]*)?$/) {
 1332:         $error .= "Invalid height; please type only a number.<br />\n";
 1333:     }
 1334:     if ($lmargin !~  /^-?[0-9]+(\.[0-9]*)?$/) {
 1335:         $error .= "Invalid left margin; please type only a number.<br />\n";
 1336:     }
 1337: 
 1338:     if (!$error) {
 1339:         Apache::lonhelper::getHelper()->changeState($self->{NEXTSTATE});
 1340:         return 1;
 1341:     } else {
 1342:         $self->{ERROR_MSG} = $error;
 1343:         return 0;
 1344:     }
 1345: }
 1346: 
 1347: 
 1348: 
 1349: __END__
 1350: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>