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