Annotation of rat/lonpage.pm, revision 1.76
1.1 www 1: # The LearningOnline Network with CAPA
2: # Page Handler
3: #
1.76 ! albertel 4: # $Id: lonpage.pm,v 1.75 2006/05/30 17:15:10 www Exp $
1.29 www 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.30 harris41 28: ###
1.1 www 29:
30: package Apache::lonpage;
31:
32: use strict;
33: use Apache::Constants qw(:common :http);
1.70 albertel 34: use Apache::lonnet;
1.30 harris41 35: use Apache::loncommon();
1.21 www 36: use Apache::lonxml();
1.57 raeburn 37: use Apache::lonlocal;
1.49 www 38: use Apache::lonmenu;
1.6 www 39: use HTML::TokeParser;
1.1 www 40: use GDBM_File;
1.39 www 41: use Apache::lonsequence;
1.75 www 42: use lib '/home/httpd/lib/perl/';
43: use LONCAPA;
44:
1.1 www 45:
1.2 www 46: # -------------------------------------------------------------- Module Globals
47: my %hash;
48: my @rows;
1.6 www 49:
50: # ------------------------------------------------------------------ Euclid gcd
51:
52: sub euclid {
53: my ($e,$f)=@_;
54: my $a; my $b; my $r;
55: if ($e>$f) { $b=$e; $r=$f; } else { $r=$e; $b=$f; }
56: while ($r!=0) {
57: $a=$b; $b=$r;
58: $r=$a%$b;
59: }
60: return $b;
61: }
1.2 www 62:
63: # ------------------------------------------------------------ Build page table
64:
65: sub tracetable {
66: my ($sofar,$rid,$beenhere)=@_;
67: my $further=$sofar;
1.57 raeburn 68: my $randomout=0;
1.70 albertel 69: unless ($env{'request.role.adv'}) {
1.57 raeburn 70: $randomout = $hash{'randomout_'.$rid};
71: }
1.2 www 72: unless ($beenhere=~/\&$rid\&/) {
1.57 raeburn 73: $beenhere.=$rid.'&';
74: unless ($randomout) {
75: if (defined($hash{'is_map_'.$rid})) {
76: if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
77: (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
78: my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
79: $sofar=
80: &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
81: '&'.$frid.'&');
82: $sofar++;
83: if ($hash{'src_'.$frid}) {
84: my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid});
85: if (($brepriv eq '2') || ($brepriv eq 'F')) {
86: if (defined($rows[$sofar])) {
87: $rows[$sofar].='&'.$frid;
88: } else {
89: $rows[$sofar]=$frid;
90: }
91: }
92: }
93: }
94: } else {
95: $sofar++;
96: if ($hash{'src_'.$rid}) {
97: my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid});
98: if (($brepriv eq '2') || ($brepriv eq 'F')) {
99: if (defined($rows[$sofar])) {
100: $rows[$sofar].='&'.$rid;
101: } else {
102: $rows[$sofar]=$rid;
103: }
104: }
105: }
106: }
107: }
108:
109: if (defined($hash{'to_'.$rid})) {
110: my $mincond=1;
111: my $next='';
112: foreach (split(/\,/,$hash{'to_'.$rid})) {
113: my $thiscond=
1.11 www 114: &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});
1.57 raeburn 115: if ($thiscond>=$mincond) {
116: if ($next) {
117: $next.=','.$_.':'.$thiscond;
118: } else {
119: $next=$_.':'.$thiscond;
120: }
121: if ($thiscond>$mincond) { $mincond=$thiscond; }
122: }
123: }
124: foreach (split(/\,/,$next)) {
125: my ($linkid,$condval)=split(/\:/,$_);
126: if ($condval>=$mincond) {
127: my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere);
128: if ($now>$further) { $further=$now; }
129: }
130: }
131: }
1.2 www 132: }
133: return $further;
134: }
135:
1.1 www 136: # ================================================================ Main Handler
137:
138: sub handler {
139: my $r=shift;
140:
1.3 www 141: # ------------------------------------------- Set document type for header only
1.1 www 142:
1.3 www 143: if ($r->header_only) {
1.70 albertel 144: if ($env{'browser.mathml'}) {
1.53 www 145: &Apache::loncommon::content_type($r,'text/xml');
1.3 www 146: } else {
1.53 www 147: &Apache::loncommon::content_type($r,'text/html');
1.3 www 148: }
149: $r->send_http_header;
150: return OK;
151: }
1.43 sakharuk 152:
1.39 www 153: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
154: ['forceselect','launch']);
1.43 sakharuk 155: my $number_of_columns = 1;
1.37 sakharuk 156: my $requrl=$r->uri;
1.70 albertel 157: my $target = $env{'form.grade_target'};
1.55 www 158: # &Apache::lonnet::logthis("Got a target of $target");
1.54 albertel 159: if ($target eq 'meta') {
160: &Apache::loncommon::content_type($r,'text/html');
161: $r->send_http_header;
162: return OK;
163: }
1.1 www 164: # ----------------------------------------------------------------- Tie db file
1.70 albertel 165: if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) {
166: my $fn=$env{'request.course.fn'};
1.1 www 167: if (-e "$fn.db") {
1.44 albertel 168: if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
1.1 www 169: # ------------------------------------------------------------------- Hash tied
170: my $firstres=$hash{'map_start_'.$requrl};
171: my $lastres=$hash{'map_finish_'.$requrl};
172: if (($firstres) && ($lastres)) {
173: # ----------------------------------------------------------------- Render page
174:
1.3 www 175: @rows=();
1.2 www 176:
1.45 www 177: &tracetable(0,$firstres,'&');
1.2 www 178:
1.9 www 179: # ------------------------------------------------------------ Add to symb list
180:
1.2 www 181: my $i;
1.9 www 182: my %symbhash=();
183: for ($i=0;$i<=$#rows;$i++) {
184: if ($rows[$i]) {
185: my @colcont=split(/\&/,$rows[$i]);
1.73 albertel 186: foreach my $rid (@colcont) {
187: my ($mapid,$resid)=split(/\./,$rid);
188: $symbhash{$hash{'src_'.$rid}}=
189: [$hash{'src_'.$rid},$resid];
1.30 harris41 190: }
1.9 www 191: }
192: }
193: &Apache::lonnet::symblist($requrl,%symbhash);
194:
195: # ------------------------------------------------------------------ Page parms
196:
1.4 www 197: my $j;
1.6 www 198: my $lcm=1;
199: my $contents=0;
1.7 www 200: my $nforms=0;
1.6 www 201:
202: my %ssibody=();
203: my %ssibgcolor=();
204: my %ssitext=();
205: my %ssilink=();
206: my %ssivlink=();
207: my %ssialink=();
1.14 www 208:
209: my %metalink=();
210:
1.6 www 211: my %cellemb=();
1.3 www 212:
1.7 www 213: my $allscript='';
214: my $allmeta='';
215:
216: my $isxml=0;
217: my $xmlheader='';
218: my $xmlbody='';
219:
1.3 www 220: # --------------------------------------------- Get SSI output, post parameters
221:
1.2 www 222: for ($i=0;$i<=$#rows;$i++) {
1.4 www 223: if ($rows[$i]) {
1.6 www 224: $contents++;
1.3 www 225: my @colcont=split(/\&/,$rows[$i]);
1.6 www 226: $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
1.30 harris41 227: foreach (@colcont) {
1.3 www 228: my $src=$hash{'src_'.$_};
1.61 albertel 229: my ($extension)=($src=~/\.(\w+)$/);
230: if ($hash{'encrypted_'.$_}) {
231: $src=&Apache::lonenc::encrypted($src);
232: }
1.14 www 233: $metalink{$_}=$src.'.meta';
1.61 albertel 234: $cellemb{$_}=
235: &Apache::loncommon::fileembstyle($extension);
1.3 www 236: if ($cellemb{$_} eq 'ssi') {
237: # --------------------------------------------------------- This is an SSI cell
1.64 albertel 238: my ($mapid,$resid)=split(/\./,$_);
239: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
240:
1.5 www 241: my $prefix=$_.'_';
1.64 albertel 242: my %posthash=('request.prefix' => $prefix,
1.71 albertel 243: 'LONCAPA_INTERNAL_no_discussion' => 'true',
1.64 albertel 244: 'symb' => $symb);
1.70 albertel 245: if ($env{'form.grade_target'} eq 'tex') {
246: $posthash{'grade_target'}=$env{'form.grade_target'};
247: $posthash{'textwidth'}=$env{'form.textwidth'};
248: $posthash{'problem_split'}=$env{'form.problem_split'};
249: $posthash{'latex_type'}=$env{'form.latex_type'};
250: $posthash{'rndseed'}=$env{'form.rndseed'};
1.56 sakharuk 251: }
1.72 albertel 252: my $submitted=exists($env{'form.all_submit'});
253: if (!$submitted) {
254: foreach my $key (keys(%env)) {
255: if ($key=~/^form.\Q$prefix\Esubmit_/) {
256: $submitted=1;last;
257: }
258: }
259: }
260: if ($submitted) {
261: foreach my $key (keys(%env)) {
262: if ($key=~/^form.\Q$prefix\E/) {
263: my $name=$key;
264: $name=~s/^form.\Q$prefix\E//;
265: $posthash{$name}=$env{$key};
266: }
267: }
268: if (exists($env{'form.all_submit'})) {
269: $posthash{'all_submit'}='yes';
270: }
1.7 www 271: }
1.5 www 272: my $output=Apache::lonnet::ssi($src,%posthash);
1.61 albertel 273: $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+// END LON-CAPA Internal\s*(-->)?\s||gs;
1.46 sakharuk 274: if ($target eq 'tex') {
275: $output =~ s/^([^&]+)\\begin{document}//;
276: $output =~ s/\\end{document}//;
277: $output = '\parbox{\minipagewidth}{ '.$output.' }';
278: #some additional cleanup necessary for LateX (due to limitations of table environment
279: $output =~ s/(\\vskip\s*\d+mm)\s*(\\\\)+/$1/g;
280: }
1.6 www 281: my $parser=HTML::TokeParser->new(\$output);
282: my $token;
1.12 www 283: my $thisdir=$src;
1.6 www 284: my $bodydef=0;
1.7 www 285: my $thisxml=0;
1.12 www 286: my @rlinks=();
1.7 www 287: if ($output=~/\?xml/) {
288: $isxml=1;
289: $thisxml=1;
290: $output=~
291: /((?:\<(?:\?xml|\!DOC|html)[^\>]*(?:\>|\>\]\>)\s*)+)\<body[^\>]*\>/si;
292: $xmlheader=$1;
293: }
1.12 www 294: while ($token=$parser->get_token) {
295: if ($token->[0] eq 'S') {
296: if ($token->[1] eq 'a') {
297: if ($token->[2]->{'href'}) {
298: $rlinks[$#rlinks+1]=
299: $token->[2]->{'href'};
300: }
301: } elsif ($token->[1] eq 'img') {
302: $rlinks[$#rlinks+1]=
303: $token->[2]->{'src'};
304: } elsif ($token->[1] eq 'embed') {
305: $rlinks[$#rlinks+1]=
306: $token->[2]->{'src'};
307: } elsif ($token->[1] eq 'base') {
308: $thisdir=$token->[2]->{'href'};
309: } elsif ($token->[1] eq 'body') {
1.7 www 310: $bodydef=1;
311: $ssibgcolor{$_}=$token->[2]->{'bgcolor'};
312: $ssitext{$_}=$token->[2]->{'text'};
313: $ssilink{$_}=$token->[2]->{'link'};
314: $ssivlink{$_}=$token->[2]->{'vlink'};
315: $ssialink{$_}=$token->[2]->{'alink'};
316: if ($thisxml) {
317: $xmlbody=$token->[4];
318: }
1.12 www 319: } elsif ($token->[1] eq 'meta') {
1.28 albertel 320: if ($token->[4] !~ m:/>$:) {
1.7 www 321: $allmeta.="\n".$token->[4].'</meta>';
1.28 albertel 322: } else {
323: $allmeta.="\n".$token->[4];
324: }
1.12 www 325: } elsif (($token->[1] eq 'script') &&
326: ($bodydef==0)) {
1.7 www 327: $allscript.="\n\n"
328: .$parser->get_text('/script');
1.6 www 329: }
1.12 www 330: }
331: }
1.6 www 332: if ($output=~/\<body[^\>]*\>(.*)/si) {
333: $output=$1;
334: }
335: $output=~s/\<\/body\>.*//si;
1.7 www 336: if ($output=~/\<form/si) {
337: $nforms++;
338: $output=~s/\<form[^\>]*\>//gsi;
339: $output=~s/\<\/form[^\>]*\>//gsi;
1.17 www 340: $output=~
1.18 www 341: s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([\w\.\:]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi;
1.7 www 342: }
1.12 www 343: $thisdir=~s/\/[^\/]*$//;
1.30 harris41 344: foreach (@rlinks) {
1.12 www 345: unless (($_=~/^http:\/\//i) ||
1.31 albertel 346: ($_=~/^\//) ||
347: ($_=~/^javascript:/i) ||
348: ($_=~/^mailto:/i) ||
349: ($_=~/^\#/)) {
1.12 www 350: my $newlocation=
351: &Apache::lonnet::hreflocation($thisdir,$_);
352: $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/;
353: }
1.30 harris41 354: }
1.24 www 355: # -------------------------------------------------- Deal with Applet codebases
356: $output=~s/(\<applet[^\>]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei;
1.5 www 357: $ssibody{$_}=$output;
1.3 www 358: # ---------------------------------------------------------------- End SSI cell
359: }
1.30 harris41 360: }
1.4 www 361: }
1.2 www 362: }
1.6 www 363: unless ($contents) {
1.53 www 364: &Apache::loncommon::content_type($r,'text/html');
1.3 www 365: $r->send_http_header;
1.74 albertel 366: $r->print(&Apache::loncommon::start_page(undef,undef,
367: {'force_register' => 1,}));
1.59 raeburn 368: $r->print(&mt('This page is either empty or it only contains resources that are currently hidden').'. ');
1.74 albertel 369: $r->print('<br /><br />'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').
370: &Apache::loncommon::end_page());
1.3 www 371: } else {
372: # ------------------------------------------------------------------ Build page
1.7 www 373:
374: # ---------------------------------------------------------------- Send headers
1.37 sakharuk 375: unless ($target eq 'tex') {
376: if ($isxml) {
1.53 www 377: &Apache::loncommon::content_type($r,'text/xml');
1.37 sakharuk 378: } else {
1.53 www 379: &Apache::loncommon::content_type($r,'text/html');
1.37 sakharuk 380: }
1.74 albertel 381: $r->send_http_header;
1.7 www 382: # ------------------------------------------------------------------------ Head
1.37 sakharuk 383: if ($allscript) {
1.74 albertel 384: $allscript .=
385: "\n<script type=\"text/javascript\">\n".
386: $allscript."\n</script>\n";
1.37 sakharuk 387: }
1.7 www 388: # ------------------------------------------------------------------ Start body
1.74 albertel 389: $r->print(&Apache::loncommon::start_page(undef,undef,
390: {'force_register' => 1,
391: 'bgcolor' => '#ffffff',}));
1.7 www 392: # ------------------------------------------------------------------ Start form
1.37 sakharuk 393: if ($nforms) {
394: $r->print('<form method="post" action="'.
1.61 albertel 395: &Apache::lonenc::check_encrypt($requrl)
396: .'">');
1.40 sakharuk 397: }
1.56 sakharuk 398: } elsif ($target eq 'tex') {
1.47 sakharuk 399: $r->print('\documentclass{article}
1.40 sakharuk 400: \newcommand{\keephidden}[1]{}
401: \usepackage[dvips]{graphicx}
402: \usepackage{epsfig}
403: \usepackage{calc}
1.42 sakharuk 404: \usepackage{longtable}
1.40 sakharuk 405: \begin{document}');
406: }
1.7 www 407: # ----------------------------------------------------------------- Start table
1.40 sakharuk 408: if ($target eq 'tex') {
1.42 sakharuk 409: $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead ');
1.43 sakharuk 410: if ($number_of_columns le $lcm) {$number_of_columns=$lcm;};
1.40 sakharuk 411: } else {
1.63 albertel 412: $r->print('<table width="100%" cols="'.$lcm.'" border="0">');
1.37 sakharuk 413: }
1.5 www 414: for ($i=0;$i<=$#rows;$i++) {
415: if ($rows[$i]) {
1.37 sakharuk 416: unless ($target eq 'tex') {
417: $r->print("\n<tr>");
418: }
1.4 www 419: my @colcont=split(/\&/,$rows[$i]);
1.6 www 420: my $avespan=$lcm/($#colcont+1);
421: for ($j=0;$j<=$#colcont;$j++) {
422: my $rid=$colcont[$j];
1.60 raeburn 423: my $metainfo = '';
1.62 albertel 424: my $esrc=&Apache::lonnet::declutter($hash{'src_'.$rid});
1.65 albertel 425: my ($mapid,$resid)=split(/\./,$rid);
426: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
1.62 albertel 427: if ($hash{'encrypted_'.$rid}) {
1.65 albertel 428: $symb=&Apache::lonenc::encrypted($symb);
1.62 albertel 429: $esrc=&Apache::lonenc::encrypted($esrc);
430: }
1.60 raeburn 431: unless ($hash{'src_'.$rid} =~ m-^/uploaded/-) {
1.75 www 432: $metainfo ='<a name="'.&escape($symb).'" />'.
1.60 raeburn 433: '<a href="'.$metalink{$rid}.'" target="LONcatInfo">'.
434: '<img src="/adm/lonMisc/cat_button.gif" border=0>'.
435: '</img></a>';
436: }
437: $metainfo .= '<a href="/adm/evaluate?postdata='.
1.75 www 438: &escape($esrc).
1.60 raeburn 439: '" target="LONcatInfo">'.
440: '<img src="/adm/lonMisc/eval_button.gif" border=0>'.
441: '</img></a>';
1.27 www 442: if (
443: ($hash{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
1.70 albertel 444: (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) &&
1.60 raeburn 445: ($hash{'src_'.$rid} !~ m-^/uploaded/-)) {
1.27 www 446: my ($mapid,$resid)=split(/\./,$rid);
447: my $symb=
448: &Apache::lonnet::declutter($hash{'map_id_'.$mapid}).
449: '___'.$resid.'___'.
450: &Apache::lonnet::declutter($hash{'src_'.$rid});
451: $metainfo.=
1.75 www 452: '<a href="/adm/grades?symb='.&escape($symb).
1.52 ng 453: # '&command=submission" target="LONcatInfo">'.
454: '&command=submission">'.
1.27 www 455: '<img src="/adm/lonMisc/subm_button.gif" border=0>'.
456: '</img></a>'.
1.75 www 457: '<a href="/adm/grades?symb='.&escape($symb).
1.52 ng 458: # '&command=gradingmenu" target="LONcatInfo">'.
459: '&command=gradingmenu">'.
1.27 www 460: '<img src="/adm/lonMisc/pgrd_button.gif" border=0>'.
461: '</img></a>'.
1.75 www 462: '<a href="/adm/parmset?symb='.&escape($symb).
1.52 ng 463: # '" target="LONcatInfo">'.
464: '" >'.
1.27 www 465: '<img src="/adm/lonMisc/pprm_button.gif" border=0>'.
466: '</img></a>';
467: }
468: $metainfo.='<br></br>';
1.37 sakharuk 469: unless ($target eq 'tex') {
470: $r->print('<td colspan="'.$avespan.'"');
471: }
1.6 www 472: if ($cellemb{$rid} eq 'ssi') {
1.37 sakharuk 473: unless ($target eq 'tex') {
474: if ($ssibgcolor{$rid}) {
475: $r->print(' bgcolor="'.
476: $ssibgcolor{$rid}.'"');
477: }
478: $r->print('>'.$metainfo.'<font');
479:
480: if ($ssitext{$rid}) {
481: $r->print(' text="'.$ssitext{$rid}.'"');
482: }
483: if ($ssilink{$rid}) {
484: $r->print(' link="'.$ssilink{$rid}.'"');
485: }
486: if ($ssitext{$rid}) {
487: $r->print(' vlink="'.$ssivlink{$rid}.'"');
488: }
489: if ($ssialink{$rid}) {
490: $r->print(' alink="'.$ssialink{$rid}.'"');
491: }
492: $r->print('>');
493: }
494: $r->print($ssibody{$rid});
495: unless ($target eq 'tex') {
496: $r->print('</font>');
1.41 www 497: }
1.70 albertel 498: if ($env{'course.'.
499: $env{'request.course.id'}.
1.41 www 500: '.pageseparators'} eq 'yes') {
501: unless($target eq 'tex') {
502: $r->print('<hr />');
503: } else {
504: $r->print('\hline');
505: }
1.37 sakharuk 506: }
507: } elsif ($cellemb{$rid} eq 'img') {
1.14 www 508: $r->print('>'.$metainfo.'<img src="'.
1.7 www 509: $hash{'src_'.$rid}.'"></img>');
1.13 www 510: } elsif ($cellemb{$rid} eq 'emb') {
1.14 www 511: $r->print('>'.$metainfo.'<embed src="'.
1.13 www 512: $hash{'src_'.$rid}.'"></embed>');
1.60 raeburn 513: } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
514: $r->print($metainfo.'<b>'.$hash{'title_'.$rid}.'</b><br />'.
515: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'</p><p><table>'.
516: &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).'</table></p><br />');
1.13 www 517: }
1.37 sakharuk 518: unless ($target eq 'tex') {
519: $r->print('</td>');
1.40 sakharuk 520: } else {
1.43 sakharuk 521: for (my $incol=1;$incol<=$avespan;$incol++) {
522: $r->print(' & ');
523: }
1.37 sakharuk 524: }
1.4 www 525: }
1.37 sakharuk 526: unless ($target eq 'tex') {
527: $r->print('</tr>');
1.40 sakharuk 528: } else {
1.42 sakharuk 529: $r->print('REMOVETHEHEADOFLONGTABLE\\\\');
1.37 sakharuk 530: }
1.5 www 531: }
1.4 www 532: }
1.37 sakharuk 533: unless ($target eq 'tex') {
534: $r->print("\n</table>");
1.40 sakharuk 535: } else {
1.47 sakharuk 536: $r->print('\end{longtable}\strut');
1.37 sakharuk 537: }
1.7 www 538: # ---------------------------------------------------------------- Submit, etc.
539: if ($nforms) {
540: $r->print(
541: '<input name="all_submit" value="Submit All" type="'.
542: (($nforms>1)?'submit':'hidden').'"></input></form>');
543: }
1.40 sakharuk 544: unless ($target eq 'tex') {
1.76 ! albertel 545: $r->print(&Apache::loncommon::end_page({'discussion'
! 546: => 1,}));
1.40 sakharuk 547: } else {
548: $r->print('\end{document}'.$number_of_columns);
549: }
1.66 albertel 550: &Apache::lonnet::symblist($requrl,%symbhash);
1.69 albertel 551: my ($map,$id,$url)=&Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
552: &Apache::lonnet::symblist($map,'last_known'=>[$url,$id]);
1.3 www 553: # -------------------------------------------------------------------- End page
554: }
1.1 www 555: # ------------------------------------------------------------- End render page
556: } else {
1.67 albertel 557: &Apache::loncommon::content_type($r,'text/html');
1.3 www 558: $r->send_http_header;
1.39 www 559: &Apache::lonsequence::viewmap($r,$requrl);
1.1 www 560: }
561: # ------------------------------------------------------------------ Untie hash
562: unless (untie(%hash)) {
563: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
564: "Could not untie coursemap $fn (browse).</font>");
565: }
566: # -------------------------------------------------------------------- All done
567: return OK;
568: # ----------------------------------------------- Errors, hash could no be tied
569: }
570: }
571: }
1.67 albertel 572: &Apache::loncommon::content_type($r,'text/html');
1.39 www 573: $r->send_http_header;
574: &Apache::lonsequence::viewmap($r,$requrl);
575: return OK;
1.1 www 576: }
577:
578: 1;
579: __END__
580:
1.30 harris41 581: =head1 NAME
582:
583: Apache::lonpage - Page Handler
584:
585: =head1 SYNOPSIS
586:
587: Invoked by /etc/httpd/conf/srm.conf:
588:
589: <LocationMatch "^/res/.*\.page$>
590: SetHandler perl-script
591: PerlHandler Apache::lonpage
592: </LocationMatch>
593:
594: =head1 INTRODUCTION
595:
596: This module renders a .page resource.
597:
598: This is part of the LearningOnline Network with CAPA project
599: described at http://www.lon-capa.org.
600:
601: =head1 HANDLER SUBROUTINE
602:
603: This routine is called by Apache and mod_perl.
604:
605: =over 4
606:
607: =item *
608:
609: set document type for header only
610:
611: =item *
612:
613: tie db file
614:
615: =item *
616:
617: render page
618:
619: =item *
620:
621: add to symb list
622:
623: =item *
624:
625: page parms
626:
627: =item *
628:
629: Get SSI output, post parameters
630:
631: =item *
632:
633: SSI cell rendering
634:
635: =item *
636:
637: Deal with Applet codebases
638:
639: =item *
640:
641: Build page
642:
643: =item *
644:
645: send headers
646:
647: =item *
648:
649: start body
650:
651: =item *
652:
653: start form
654:
655: =item *
656:
657: start table
658:
659: =item *
660:
661: submit element, etc, render page, untie hash
662:
663: =back
664:
665: =head1 OTHER SUBROUTINES
666:
667: =over 4
668:
669: =item *
670:
671: euclid() : Euclid's method for determining the greatest common denominator.
672:
673: =item *
674:
675: tracetable() : Build page table.
1.1 www 676:
1.30 harris41 677: =back
1.1 www 678:
1.30 harris41 679: =cut
1.1 www 680:
681:
682:
683:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>