Annotation of rat/lonpage.pm, revision 1.43

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.