Annotation of rat/lonpage.pm, revision 1.72
1.1 www 1: # The LearningOnline Network with CAPA
2: # Page Handler
3: #
1.72 ! albertel 4: # $Id: lonpage.pm,v 1.71 2005/06/29 19:02:14 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.30 harris41 183: foreach (@colcont) {
1.68 albertel 184: $symbhash{$hash{'src_'.$_}}=['page','notasymb'];
1.30 harris41 185: }
1.9 www 186: }
187: }
188: &Apache::lonnet::symblist($requrl,%symbhash);
189:
190: # ------------------------------------------------------------------ Page parms
191:
1.4 www 192: my $j;
1.6 www 193: my $lcm=1;
194: my $contents=0;
1.7 www 195: my $nforms=0;
1.6 www 196:
197: my %ssibody=();
198: my %ssibgcolor=();
199: my %ssitext=();
200: my %ssilink=();
201: my %ssivlink=();
202: my %ssialink=();
1.14 www 203:
204: my %metalink=();
205:
1.6 www 206: my %cellemb=();
1.3 www 207:
1.7 www 208: my $allscript='';
209: my $allmeta='';
210:
211: my $isxml=0;
212: my $xmlheader='';
213: my $xmlbody='';
214:
1.3 www 215: # --------------------------------------------- Get SSI output, post parameters
216:
1.2 www 217: for ($i=0;$i<=$#rows;$i++) {
1.4 www 218: if ($rows[$i]) {
1.6 www 219: $contents++;
1.3 www 220: my @colcont=split(/\&/,$rows[$i]);
1.6 www 221: $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
1.30 harris41 222: foreach (@colcont) {
1.3 www 223: my $src=$hash{'src_'.$_};
1.61 albertel 224: my ($extension)=($src=~/\.(\w+)$/);
225: if ($hash{'encrypted_'.$_}) {
226: $src=&Apache::lonenc::encrypted($src);
227: }
1.14 www 228: $metalink{$_}=$src.'.meta';
1.61 albertel 229: $cellemb{$_}=
230: &Apache::loncommon::fileembstyle($extension);
1.3 www 231: if ($cellemb{$_} eq 'ssi') {
232: # --------------------------------------------------------- This is an SSI cell
1.64 albertel 233: my ($mapid,$resid)=split(/\./,$_);
234: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
235:
1.5 www 236: my $prefix=$_.'_';
1.64 albertel 237: my %posthash=('request.prefix' => $prefix,
1.71 albertel 238: 'LONCAPA_INTERNAL_no_discussion' => 'true',
1.64 albertel 239: 'symb' => $symb);
1.70 albertel 240: if ($env{'form.grade_target'} eq 'tex') {
241: $posthash{'grade_target'}=$env{'form.grade_target'};
242: $posthash{'textwidth'}=$env{'form.textwidth'};
243: $posthash{'problem_split'}=$env{'form.problem_split'};
244: $posthash{'latex_type'}=$env{'form.latex_type'};
245: $posthash{'rndseed'}=$env{'form.rndseed'};
1.56 sakharuk 246: }
1.72 ! albertel 247: my $submitted=exists($env{'form.all_submit'});
! 248: if (!$submitted) {
! 249: foreach my $key (keys(%env)) {
! 250: if ($key=~/^form.\Q$prefix\Esubmit_/) {
! 251: $submitted=1;last;
! 252: }
! 253: }
! 254: }
! 255: if ($submitted) {
! 256: foreach my $key (keys(%env)) {
! 257: if ($key=~/^form.\Q$prefix\E/) {
! 258: my $name=$key;
! 259: $name=~s/^form.\Q$prefix\E//;
! 260: $posthash{$name}=$env{$key};
! 261: }
! 262: }
! 263: if (exists($env{'form.all_submit'})) {
! 264: $posthash{'all_submit'}='yes';
! 265: }
1.7 www 266: }
1.5 www 267: my $output=Apache::lonnet::ssi($src,%posthash);
1.61 albertel 268: $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+// END LON-CAPA Internal\s*(-->)?\s||gs;
1.46 sakharuk 269: if ($target eq 'tex') {
270: $output =~ s/^([^&]+)\\begin{document}//;
271: $output =~ s/\\end{document}//;
272: $output = '\parbox{\minipagewidth}{ '.$output.' }';
273: #some additional cleanup necessary for LateX (due to limitations of table environment
274: $output =~ s/(\\vskip\s*\d+mm)\s*(\\\\)+/$1/g;
275: }
1.6 www 276: my $parser=HTML::TokeParser->new(\$output);
277: my $token;
1.12 www 278: my $thisdir=$src;
1.6 www 279: my $bodydef=0;
1.7 www 280: my $thisxml=0;
1.12 www 281: my @rlinks=();
1.7 www 282: if ($output=~/\?xml/) {
283: $isxml=1;
284: $thisxml=1;
285: $output=~
286: /((?:\<(?:\?xml|\!DOC|html)[^\>]*(?:\>|\>\]\>)\s*)+)\<body[^\>]*\>/si;
287: $xmlheader=$1;
288: }
1.12 www 289: while ($token=$parser->get_token) {
290: if ($token->[0] eq 'S') {
291: if ($token->[1] eq 'a') {
292: if ($token->[2]->{'href'}) {
293: $rlinks[$#rlinks+1]=
294: $token->[2]->{'href'};
295: }
296: } elsif ($token->[1] eq 'img') {
297: $rlinks[$#rlinks+1]=
298: $token->[2]->{'src'};
299: } elsif ($token->[1] eq 'embed') {
300: $rlinks[$#rlinks+1]=
301: $token->[2]->{'src'};
302: } elsif ($token->[1] eq 'base') {
303: $thisdir=$token->[2]->{'href'};
304: } elsif ($token->[1] eq 'body') {
1.7 www 305: $bodydef=1;
306: $ssibgcolor{$_}=$token->[2]->{'bgcolor'};
307: $ssitext{$_}=$token->[2]->{'text'};
308: $ssilink{$_}=$token->[2]->{'link'};
309: $ssivlink{$_}=$token->[2]->{'vlink'};
310: $ssialink{$_}=$token->[2]->{'alink'};
311: if ($thisxml) {
312: $xmlbody=$token->[4];
313: }
1.12 www 314: } elsif ($token->[1] eq 'meta') {
1.28 albertel 315: if ($token->[4] !~ m:/>$:) {
1.7 www 316: $allmeta.="\n".$token->[4].'</meta>';
1.28 albertel 317: } else {
318: $allmeta.="\n".$token->[4];
319: }
1.12 www 320: } elsif (($token->[1] eq 'script') &&
321: ($bodydef==0)) {
1.7 www 322: $allscript.="\n\n"
323: .$parser->get_text('/script');
1.6 www 324: }
1.12 www 325: }
326: }
1.6 www 327: if ($output=~/\<body[^\>]*\>(.*)/si) {
328: $output=$1;
329: }
330: $output=~s/\<\/body\>.*//si;
1.7 www 331: if ($output=~/\<form/si) {
332: $nforms++;
333: $output=~s/\<form[^\>]*\>//gsi;
334: $output=~s/\<\/form[^\>]*\>//gsi;
1.17 www 335: $output=~
1.18 www 336: s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([\w\.\:]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi;
1.7 www 337: }
1.12 www 338: $thisdir=~s/\/[^\/]*$//;
1.30 harris41 339: foreach (@rlinks) {
1.12 www 340: unless (($_=~/^http:\/\//i) ||
1.31 albertel 341: ($_=~/^\//) ||
342: ($_=~/^javascript:/i) ||
343: ($_=~/^mailto:/i) ||
344: ($_=~/^\#/)) {
1.12 www 345: my $newlocation=
346: &Apache::lonnet::hreflocation($thisdir,$_);
347: $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/;
348: }
1.30 harris41 349: }
1.24 www 350: # -------------------------------------------------- Deal with Applet codebases
351: $output=~s/(\<applet[^\>]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei;
1.5 www 352: $ssibody{$_}=$output;
1.3 www 353: # ---------------------------------------------------------------- End SSI cell
354: }
1.30 harris41 355: }
1.4 www 356: }
1.2 www 357: }
1.6 www 358: unless ($contents) {
1.53 www 359: &Apache::loncommon::content_type($r,'text/html');
1.3 www 360: $r->send_http_header;
1.59 raeburn 361: $r->print('<html>'."\n".
362: '<head>'."\n".
363: &Apache::lonmenu::registerurl(1,undef)."\n".
364: '</head>'."\n".
365: '<body bgcolor="#FFFFFF" onLoad="'
366: .&Apache::lonmenu::loadevents.
367: '" onUnload="'.&Apache::lonmenu::unloadevents.'">'.
368: &Apache::lonmenu::menubuttons(undef,$target,1)
369: );
370: $r->print(&mt('This page is either empty or it only contains resources that are currently hidden').'. ');
371: $r->print('<br /><br />'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').'.</body></html>');
1.3 www 372: } else {
373: # ------------------------------------------------------------------ Build page
1.7 www 374:
375: # ---------------------------------------------------------------- Send headers
1.37 sakharuk 376: unless ($target eq 'tex') {
377: if ($isxml) {
1.53 www 378: &Apache::loncommon::content_type($r,'text/xml');
1.37 sakharuk 379: $r->send_http_header;
380: $r->print($xmlheader);
381: } else {
1.53 www 382: &Apache::loncommon::content_type($r,'text/html');
1.37 sakharuk 383: $r->send_http_header;
384: $r->print('<html>');
385: }
1.7 www 386: # ------------------------------------------------------------------------ Head
1.37 sakharuk 387: $r->print("\n<head>\n".$allmeta);
388: if ($allscript) {
389: $r->print("\n<script language='JavaScript'>\n".
390: $allscript."\n</script>\n");
391: }
1.49 www 392: $r->print(&Apache::lonmenu::registerurl(1,undef));
1.37 sakharuk 393: $r->print("\n</head>\n");
1.7 www 394: # ------------------------------------------------------------------ Start body
1.37 sakharuk 395: if ($isxml) {
396: $r->print($xmlbody);
397: } else {
1.51 www 398: $r->print(
399: '<body bgcolor="#FFFFFF" onLoad="'.&Apache::lonmenu::loadevents.
400: '" onUnload="'.&Apache::lonmenu::unloadevents.'">'.
401: &Apache::lonmenu::menubuttons(undef,$target,1)
402: );
1.37 sakharuk 403: }
1.7 www 404: # ------------------------------------------------------------------ Start form
1.37 sakharuk 405: if ($nforms) {
406: $r->print('<form method="post" action="'.
1.61 albertel 407: &Apache::lonenc::check_encrypt($requrl)
408: .'">');
1.40 sakharuk 409: }
1.56 sakharuk 410: } elsif ($target eq 'tex') {
1.47 sakharuk 411: $r->print('\documentclass{article}
1.40 sakharuk 412: \newcommand{\keephidden}[1]{}
413: \usepackage[dvips]{graphicx}
414: \usepackage{epsfig}
415: \usepackage{calc}
1.42 sakharuk 416: \usepackage{longtable}
1.40 sakharuk 417: \begin{document}');
418: }
1.7 www 419: # ----------------------------------------------------------------- Start table
1.40 sakharuk 420: if ($target eq 'tex') {
1.42 sakharuk 421: $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead ');
1.43 sakharuk 422: if ($number_of_columns le $lcm) {$number_of_columns=$lcm;};
1.40 sakharuk 423: } else {
1.63 albertel 424: $r->print('<table width="100%" cols="'.$lcm.'" border="0">');
1.37 sakharuk 425: }
1.5 www 426: for ($i=0;$i<=$#rows;$i++) {
427: if ($rows[$i]) {
1.37 sakharuk 428: unless ($target eq 'tex') {
429: $r->print("\n<tr>");
430: }
1.4 www 431: my @colcont=split(/\&/,$rows[$i]);
1.6 www 432: my $avespan=$lcm/($#colcont+1);
433: for ($j=0;$j<=$#colcont;$j++) {
434: my $rid=$colcont[$j];
1.60 raeburn 435: my $metainfo = '';
1.62 albertel 436: my $esrc=&Apache::lonnet::declutter($hash{'src_'.$rid});
1.65 albertel 437: my ($mapid,$resid)=split(/\./,$rid);
438: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
1.62 albertel 439: if ($hash{'encrypted_'.$rid}) {
1.65 albertel 440: $symb=&Apache::lonenc::encrypted($symb);
1.62 albertel 441: $esrc=&Apache::lonenc::encrypted($esrc);
442: }
1.60 raeburn 443: unless ($hash{'src_'.$rid} =~ m-^/uploaded/-) {
1.65 albertel 444: $metainfo ='<a name="'.&Apache::lonnet::escape($symb).'" />'.
1.60 raeburn 445: '<a href="'.$metalink{$rid}.'" target="LONcatInfo">'.
446: '<img src="/adm/lonMisc/cat_button.gif" border=0>'.
447: '</img></a>';
448: }
449: $metainfo .= '<a href="/adm/evaluate?postdata='.
1.62 albertel 450: &Apache::lonnet::escape($esrc).
1.60 raeburn 451: '" target="LONcatInfo">'.
452: '<img src="/adm/lonMisc/eval_button.gif" border=0>'.
453: '</img></a>';
1.27 www 454: if (
455: ($hash{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
1.70 albertel 456: (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) &&
1.60 raeburn 457: ($hash{'src_'.$rid} !~ m-^/uploaded/-)) {
1.27 www 458: my ($mapid,$resid)=split(/\./,$rid);
459: my $symb=
460: &Apache::lonnet::declutter($hash{'map_id_'.$mapid}).
461: '___'.$resid.'___'.
462: &Apache::lonnet::declutter($hash{'src_'.$rid});
463: $metainfo.=
1.36 www 464: '<a href="/adm/grades?symb='.&Apache::lonnet::escape($symb).
1.52 ng 465: # '&command=submission" target="LONcatInfo">'.
466: '&command=submission">'.
1.27 www 467: '<img src="/adm/lonMisc/subm_button.gif" border=0>'.
468: '</img></a>'.
1.36 www 469: '<a href="/adm/grades?symb='.&Apache::lonnet::escape($symb).
1.52 ng 470: # '&command=gradingmenu" target="LONcatInfo">'.
471: '&command=gradingmenu">'.
1.27 www 472: '<img src="/adm/lonMisc/pgrd_button.gif" border=0>'.
473: '</img></a>'.
1.36 www 474: '<a href="/adm/parmset?symb='.&Apache::lonnet::escape($symb).
1.52 ng 475: # '" target="LONcatInfo">'.
476: '" >'.
1.27 www 477: '<img src="/adm/lonMisc/pprm_button.gif" border=0>'.
478: '</img></a>';
479: }
480: $metainfo.='<br></br>';
1.37 sakharuk 481: unless ($target eq 'tex') {
482: $r->print('<td colspan="'.$avespan.'"');
483: }
1.6 www 484: if ($cellemb{$rid} eq 'ssi') {
1.37 sakharuk 485: unless ($target eq 'tex') {
486: if ($ssibgcolor{$rid}) {
487: $r->print(' bgcolor="'.
488: $ssibgcolor{$rid}.'"');
489: }
490: $r->print('>'.$metainfo.'<font');
491:
492: if ($ssitext{$rid}) {
493: $r->print(' text="'.$ssitext{$rid}.'"');
494: }
495: if ($ssilink{$rid}) {
496: $r->print(' link="'.$ssilink{$rid}.'"');
497: }
498: if ($ssitext{$rid}) {
499: $r->print(' vlink="'.$ssivlink{$rid}.'"');
500: }
501: if ($ssialink{$rid}) {
502: $r->print(' alink="'.$ssialink{$rid}.'"');
503: }
504: $r->print('>');
505: }
506: $r->print($ssibody{$rid});
507: unless ($target eq 'tex') {
508: $r->print('</font>');
1.41 www 509: }
1.70 albertel 510: if ($env{'course.'.
511: $env{'request.course.id'}.
1.41 www 512: '.pageseparators'} eq 'yes') {
513: unless($target eq 'tex') {
514: $r->print('<hr />');
515: } else {
516: $r->print('\hline');
517: }
1.37 sakharuk 518: }
519: } elsif ($cellemb{$rid} eq 'img') {
1.14 www 520: $r->print('>'.$metainfo.'<img src="'.
1.7 www 521: $hash{'src_'.$rid}.'"></img>');
1.13 www 522: } elsif ($cellemb{$rid} eq 'emb') {
1.14 www 523: $r->print('>'.$metainfo.'<embed src="'.
1.13 www 524: $hash{'src_'.$rid}.'"></embed>');
1.60 raeburn 525: } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
526: $r->print($metainfo.'<b>'.$hash{'title_'.$rid}.'</b><br />'.
527: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'</p><p><table>'.
528: &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 529: }
1.37 sakharuk 530: unless ($target eq 'tex') {
531: $r->print('</td>');
1.40 sakharuk 532: } else {
1.43 sakharuk 533: for (my $incol=1;$incol<=$avespan;$incol++) {
534: $r->print(' & ');
535: }
1.37 sakharuk 536: }
1.4 www 537: }
1.37 sakharuk 538: unless ($target eq 'tex') {
539: $r->print('</tr>');
1.40 sakharuk 540: } else {
1.42 sakharuk 541: $r->print('REMOVETHEHEADOFLONGTABLE\\\\');
1.37 sakharuk 542: }
1.5 www 543: }
1.4 www 544: }
1.37 sakharuk 545: unless ($target eq 'tex') {
546: $r->print("\n</table>");
1.40 sakharuk 547: } else {
1.47 sakharuk 548: $r->print('\end{longtable}\strut');
1.37 sakharuk 549: }
1.7 www 550: # ---------------------------------------------------------------- Submit, etc.
551: if ($nforms) {
552: $r->print(
553: '<input name="all_submit" value="Submit All" type="'.
554: (($nforms>1)?'submit':'hidden').'"></input></form>');
555: }
1.40 sakharuk 556: unless ($target eq 'tex') {
557: $r->print('</body>'.&Apache::lonxml::xmlend());
558: } else {
559: $r->print('\end{document}'.$number_of_columns);
560: }
1.66 albertel 561: &Apache::lonnet::symblist($requrl,%symbhash);
1.69 albertel 562: my ($map,$id,$url)=&Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
563: &Apache::lonnet::symblist($map,'last_known'=>[$url,$id]);
1.3 www 564: # -------------------------------------------------------------------- End page
565: }
1.1 www 566: # ------------------------------------------------------------- End render page
567: } else {
1.67 albertel 568: &Apache::loncommon::content_type($r,'text/html');
1.3 www 569: $r->send_http_header;
1.39 www 570: &Apache::lonsequence::viewmap($r,$requrl);
1.1 www 571: }
572: # ------------------------------------------------------------------ Untie hash
573: unless (untie(%hash)) {
574: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
575: "Could not untie coursemap $fn (browse).</font>");
576: }
577: # -------------------------------------------------------------------- All done
578: return OK;
579: # ----------------------------------------------- Errors, hash could no be tied
580: }
581: }
582: }
1.67 albertel 583: &Apache::loncommon::content_type($r,'text/html');
1.39 www 584: $r->send_http_header;
585: &Apache::lonsequence::viewmap($r,$requrl);
586: return OK;
1.1 www 587: }
588:
589: 1;
590: __END__
591:
1.30 harris41 592: =head1 NAME
593:
594: Apache::lonpage - Page Handler
595:
596: =head1 SYNOPSIS
597:
598: Invoked by /etc/httpd/conf/srm.conf:
599:
600: <LocationMatch "^/res/.*\.page$>
601: SetHandler perl-script
602: PerlHandler Apache::lonpage
603: </LocationMatch>
604:
605: =head1 INTRODUCTION
606:
607: This module renders a .page resource.
608:
609: This is part of the LearningOnline Network with CAPA project
610: described at http://www.lon-capa.org.
611:
612: =head1 HANDLER SUBROUTINE
613:
614: This routine is called by Apache and mod_perl.
615:
616: =over 4
617:
618: =item *
619:
620: set document type for header only
621:
622: =item *
623:
624: tie db file
625:
626: =item *
627:
628: render page
629:
630: =item *
631:
632: add to symb list
633:
634: =item *
635:
636: page parms
637:
638: =item *
639:
640: Get SSI output, post parameters
641:
642: =item *
643:
644: SSI cell rendering
645:
646: =item *
647:
648: Deal with Applet codebases
649:
650: =item *
651:
652: Build page
653:
654: =item *
655:
656: send headers
657:
658: =item *
659:
660: start body
661:
662: =item *
663:
664: start form
665:
666: =item *
667:
668: start table
669:
670: =item *
671:
672: submit element, etc, render page, untie hash
673:
674: =back
675:
676: =head1 OTHER SUBROUTINES
677:
678: =over 4
679:
680: =item *
681:
682: euclid() : Euclid's method for determining the greatest common denominator.
683:
684: =item *
685:
686: tracetable() : Build page table.
1.1 www 687:
1.30 harris41 688: =back
1.1 www 689:
1.30 harris41 690: =cut
1.1 www 691:
692:
693:
694:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>