Annotation of rat/lonpage.pm, revision 1.53

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Page Handler
                      3: #
1.53    ! www         4: # $Id: lonpage.pm,v 1.52 2003/07/19 13:11:41 ng 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.33      www        36: # YEAR=2002
                     37: # 03/19 Gerd Kortemeyer
1.30      harris41   38: #
                     39: ###
1.1       www        40: 
                     41: package Apache::lonpage;
                     42: 
                     43: use strict;
                     44: use Apache::Constants qw(:common :http);
                     45: use Apache::lonnet();
1.30      harris41   46: use Apache::loncommon();
1.21      www        47: use Apache::lonxml();
1.49      www        48: use Apache::lonmenu;
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'}) {
1.53    ! www       148:            &Apache::loncommon::content_type($r,'text/xml');
1.3       www       149:        } else {
1.53    ! www       150:            &Apache::loncommon::content_type($r,'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.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.9       www       184:                            $symbhash{$hash{'src_'.$_}}='';
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.5       www       224:                           $src=~/\.(\w+)$/;
1.14      www       225:                           $metalink{$_}=$src.'.meta';
1.30      harris41  226:                           $cellemb{$_}=Apache::loncommon::fileembstyle($1);
1.3       www       227:                           if ($cellemb{$_} eq 'ssi') {
                    228: # --------------------------------------------------------- This is an SSI cell
1.5       www       229: 			      my $prefix=$_.'_';
                    230:                               my %posthash=('request.prefix' => $prefix);
1.8       www       231:                               if (($ENV{'form.'.$prefix.'submit'}) 
1.7       www       232:                                || ($ENV{'form.all_submit'})) {
1.30      harris41  233:                                foreach (keys %ENV) {
1.5       www       234: 				  if ($_=~/^form.$prefix/) {
                    235: 				      my $name=$_;
                    236:                                       $name=~s/^form.$prefix//;
                    237:                                       $posthash{$name}=$ENV{$_};
                    238:                                   }
1.30      harris41  239:                                }
1.7       www       240: 			      }
1.5       www       241:                               my $output=Apache::lonnet::ssi($src,%posthash);
1.50      www       242: 			      $output=~
                    243: 	    s/\/\/ BEGIN LON\-CAPA Internal.+\/\/ END LON\-CAPA Internal\s//gs;
1.46      sakharuk  244:                               if ($target eq 'tex') {
                    245: 				  $output =~ s/^([^&]+)\\begin{document}//;
                    246: 				  $output =~ s/\\end{document}//;
                    247: 				  $output = '\parbox{\minipagewidth}{ '.$output.' }';
                    248:                                   #some additional cleanup necessary for LateX (due to limitations of table environment 
                    249: 				  $output =~ s/(\\vskip\s*\d+mm)\s*(\\\\)+/$1/g;
                    250: 			      }
1.6       www       251:                               my $parser=HTML::TokeParser->new(\$output);
                    252:                               my $token;
1.12      www       253:                               my $thisdir=$src;
1.6       www       254:                               my $bodydef=0;
1.7       www       255:                               my $thisxml=0;
1.12      www       256:                               my @rlinks=();
1.7       www       257:                               if ($output=~/\?xml/) {
                    258:                                  $isxml=1;
                    259:                                  $thisxml=1;
                    260:                                  $output=~
                    261:          /((?:\<(?:\?xml|\!DOC|html)[^\>]*(?:\>|\>\]\>)\s*)+)\<body[^\>]*\>/si;
                    262:                                  $xmlheader=$1;
                    263: 			      }
1.12      www       264:                               while ($token=$parser->get_token) {
                    265: 				if ($token->[0] eq 'S') {
                    266:                                   if ($token->[1] eq 'a') {
                    267: 				      if ($token->[2]->{'href'}) {
                    268:                                          $rlinks[$#rlinks+1]=
                    269: 					     $token->[2]->{'href'};
                    270: 				      }
                    271: 				  } elsif ($token->[1] eq 'img') {
                    272:                                          $rlinks[$#rlinks+1]=
                    273: 					     $token->[2]->{'src'};
                    274: 				  } elsif ($token->[1] eq 'embed') {
                    275:                                          $rlinks[$#rlinks+1]=
                    276: 					     $token->[2]->{'src'};
                    277: 				  } elsif ($token->[1] eq 'base') {
                    278: 				      $thisdir=$token->[2]->{'href'};
                    279: 				  } elsif ($token->[1] eq 'body') {
1.7       www       280: 				      $bodydef=1;
                    281:                                       $ssibgcolor{$_}=$token->[2]->{'bgcolor'};
                    282:                                       $ssitext{$_}=$token->[2]->{'text'};
                    283:                                       $ssilink{$_}=$token->[2]->{'link'};
                    284:                                       $ssivlink{$_}=$token->[2]->{'vlink'};
                    285:                                       $ssialink{$_}=$token->[2]->{'alink'};
                    286:                                       if ($thisxml) {
                    287: 					  $xmlbody=$token->[4];
                    288:                                       }
1.12      www       289:                                   } elsif ($token->[1] eq 'meta') {
1.28      albertel  290: 				    if ($token->[4] !~ m:/>$:) {
1.7       www       291: 				      $allmeta.="\n".$token->[4].'</meta>';
1.28      albertel  292: 				    } else {
                    293: 				      $allmeta.="\n".$token->[4];
                    294: 				    }
1.12      www       295:                                   } elsif (($token->[1] eq 'script') &&
                    296:                                            ($bodydef==0)) {
1.7       www       297: 				      $allscript.="\n\n"
                    298:                                                 .$parser->get_text('/script');
1.6       www       299:                                   }
1.12      www       300: 			        }
                    301: 			      }
1.6       www       302:                               if ($output=~/\<body[^\>]*\>(.*)/si) {
                    303:                                  $output=$1; 
                    304:                               }
                    305:                               $output=~s/\<\/body\>.*//si;
1.7       www       306:                               if ($output=~/\<form/si) {
                    307: 				  $nforms++;
                    308:                                   $output=~s/\<form[^\>]*\>//gsi;
                    309:                                   $output=~s/\<\/form[^\>]*\>//gsi;
1.17      www       310:                                   $output=~
1.18      www       311: 				      s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([\w\.\:]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi;
1.7       www       312:                               }
1.12      www       313:                               $thisdir=~s/\/[^\/]*$//;
1.30      harris41  314: 			      foreach (@rlinks) {
1.12      www       315: 				  unless (($_=~/^http:\/\//i) ||
1.31      albertel  316: 					  ($_=~/^\//) ||
                    317: 					  ($_=~/^javascript:/i) ||
                    318: 					  ($_=~/^mailto:/i) ||
                    319: 					  ($_=~/^\#/)) {
1.12      www       320: 				      my $newlocation=
                    321: 				    &Apache::lonnet::hreflocation($thisdir,$_);
                    322:                      $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/;
                    323: 				  }
1.30      harris41  324: 			      }
1.24      www       325: # -------------------------------------------------- Deal with Applet codebases
                    326:   $output=~s/(\<applet[^\>]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei;
1.5       www       327: 			      $ssibody{$_}=$output;
1.3       www       328: # ---------------------------------------------------------------- End SSI cell
                    329:                           }
1.30      harris41  330:                       }
1.4       www       331:                      } 
1.2       www       332:                   }
1.6       www       333:                   unless ($contents) {
1.53    ! www       334:                       &Apache::loncommon::content_type($r,'text/html');
1.3       www       335:                       $r->send_http_header;
1.53    ! www       336:                       $r->print('<html><body>'.&mt('Empty page').'.</body></html>');
1.3       www       337:                   } else {
                    338: # ------------------------------------------------------------------ Build page
1.7       www       339: 
                    340: # ---------------------------------------------------------------- Send headers
1.37      sakharuk  341: 		      unless ($target eq 'tex') {
                    342: 			  if ($isxml) {
1.53    ! www       343: 			      &Apache::loncommon::content_type($r,'text/xml');
1.37      sakharuk  344: 			      $r->send_http_header;
                    345: 			      $r->print($xmlheader);
                    346: 			  } else {
1.53    ! www       347: 			      &Apache::loncommon::content_type($r,'text/html');
1.37      sakharuk  348: 			      $r->send_http_header;
                    349: 			      $r->print('<html>');
                    350: 			  }
1.7       www       351: # ------------------------------------------------------------------------ Head
1.37      sakharuk  352: 			  $r->print("\n<head>\n".$allmeta);
                    353: 			  if ($allscript) {
                    354: 			      $r->print("\n<script language='JavaScript'>\n".
                    355: 					$allscript."\n</script>\n");
                    356: 			  }
1.49      www       357: 			  $r->print(&Apache::lonmenu::registerurl(1,undef));
1.37      sakharuk  358: 			  $r->print("\n</head>\n");
1.7       www       359: # ------------------------------------------------------------------ Start body
1.37      sakharuk  360: 			  if ($isxml) {
                    361: 			      $r->print($xmlbody);
                    362: 			  } else {
1.51      www       363: 			      $r->print(
                    364:                '<body bgcolor="#FFFFFF" onLoad="'.&Apache::lonmenu::loadevents.
                    365:                '" onUnload="'.&Apache::lonmenu::unloadevents.'">'.
                    366:                               &Apache::lonmenu::menubuttons(undef,$target,1)
                    367: 					);
1.37      sakharuk  368: 			  }
1.7       www       369: # ------------------------------------------------------------------ Start form
1.37      sakharuk  370: 			  if ($nforms) {
                    371: 			      $r->print('<form method="post" action="'.
                    372: 					$requrl.'">');
1.40      sakharuk  373: 			  }
                    374: 		      } else {
1.47      sakharuk  375: 			  $r->print('\documentclass{article}
1.40      sakharuk  376:                                  \newcommand{\keephidden}[1]{}           
                    377:                                  \usepackage[dvips]{graphicx}
                    378:                                  \usepackage{epsfig}
                    379:                                  \usepackage{calc}
1.42      sakharuk  380:                                  \usepackage{longtable}
1.40      sakharuk  381:                                  \begin{document}');
                    382: 		      }
1.7       www       383: # ----------------------------------------------------------------- Start table
1.40      sakharuk  384: 		      if ($target eq 'tex') {
1.42      sakharuk  385: 			  $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead ');
1.43      sakharuk  386: 			  if ($number_of_columns le $lcm) {$number_of_columns=$lcm;};
1.40      sakharuk  387: 		      } else {
1.37      sakharuk  388: 			  $r->print('<table cols="'.$lcm.'" border="0">');
                    389: 		      }
1.5       www       390:                       for ($i=0;$i<=$#rows;$i++) {
                    391: 			if ($rows[$i]) {
1.37      sakharuk  392: 			    unless ($target eq 'tex') {
                    393: 				$r->print("\n<tr>");
                    394: 			    }
1.4       www       395:                           my @colcont=split(/\&/,$rows[$i]);
1.6       www       396:                           my $avespan=$lcm/($#colcont+1);
                    397:                           for ($j=0;$j<=$#colcont;$j++) {
                    398:                               my $rid=$colcont[$j];
1.23      www       399:                               my $metainfo='<a href="'.
                    400:                                     $metalink{$rid}.'" target="LONcatInfo">'.
                    401:                           '<img src="/adm/lonMisc/cat_button.gif" border=0>'.
1.34      www       402: 			  '</img></a><a href="/adm/evaluate?postdata='.
1.35      www       403:       &Apache::lonnet::escape(&Apache::lonnet::declutter($hash{'src_'.$rid}))
                    404:       .'" target="LONcatInfo">'.
1.33      www       405:                           '<img src="/adm/lonMisc/eval_button.gif" border=0>'.
                    406:                           '</img></a>';
1.27      www       407:                               if (
                    408:  ($hash{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
                    409:  (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}))) {
                    410: 				  my ($mapid,$resid)=split(/\./,$rid);
                    411:                                  my $symb=
                    412:                 &Apache::lonnet::declutter($hash{'map_id_'.$mapid}).
                    413:                 '___'.$resid.'___'.
                    414: 		&Apache::lonnet::declutter($hash{'src_'.$rid});
                    415:                                  $metainfo.=
1.36      www       416:                   '<a href="/adm/grades?symb='.&Apache::lonnet::escape($symb).
1.52      ng        417: #                 '&command=submission" target="LONcatInfo">'.
                    418:                   '&command=submission">'.
1.27      www       419:                           '<img src="/adm/lonMisc/subm_button.gif" border=0>'.
                    420: 			  '</img></a>'.
1.36      www       421:                   '<a href="/adm/grades?symb='.&Apache::lonnet::escape($symb).
1.52      ng        422: #                  '&command=gradingmenu" target="LONcatInfo">'.
                    423:                   '&command=gradingmenu">'.
1.27      www       424:                           '<img src="/adm/lonMisc/pgrd_button.gif" border=0>'.
                    425: 			  '</img></a>'.
1.36      www       426:                   '<a href="/adm/parmset?symb='.&Apache::lonnet::escape($symb).
1.52      ng        427: #                          '" target="LONcatInfo">'.
                    428:                           '" >'.
1.27      www       429:                           '<img src="/adm/lonMisc/pprm_button.gif" border=0>'.
                    430: 			      '</img></a>';
                    431:                               }
                    432:                               $metainfo.='<br></br>';
1.37      sakharuk  433: 			    unless ($target eq 'tex') {
                    434: 				$r->print('<td colspan="'.$avespan.'"');
                    435: 			    }
1.6       www       436:                               if ($cellemb{$rid} eq 'ssi') {
1.37      sakharuk  437: 				  unless ($target eq 'tex') {
                    438: 				      if ($ssibgcolor{$rid}) {
                    439: 					  $r->print(' bgcolor="'.
                    440: 						    $ssibgcolor{$rid}.'"');
                    441: 				      }
                    442: 				      $r->print('>'.$metainfo.'<font');
                    443: 		    
                    444: 				      if ($ssitext{$rid}) {
                    445: 					  $r->print(' text="'.$ssitext{$rid}.'"');
                    446: 				      }
                    447: 				      if ($ssilink{$rid}) {
                    448: 					  $r->print(' link="'.$ssilink{$rid}.'"');
                    449: 				      }
                    450: 				      if ($ssitext{$rid}) {
                    451: 					  $r->print(' vlink="'.$ssivlink{$rid}.'"');
                    452: 				      }
                    453: 				      if ($ssialink{$rid}) {
                    454: 					  $r->print(' alink="'.$ssialink{$rid}.'"');
                    455: 				      }             
                    456: 				      $r->print('>');
                    457: 				  }
                    458:                                   $r->print($ssibody{$rid});	
                    459: 				  unless ($target eq 'tex') {
                    460: 				      $r->print('</font>');
1.41      www       461:                                   }
                    462:                                   if ($ENV{'course.'.
                    463:                                       $ENV{'request.course.id'}.
                    464:                                       '.pageseparators'} eq 'yes') {
                    465:                                       unless($target eq 'tex') {
                    466:                                           $r->print('<hr />');
                    467:                                       } else {
                    468:                                           $r->print('\hline');
                    469:                                       }
1.37      sakharuk  470: 				  }
                    471: 			      } elsif ($cellemb{$rid} eq 'img') {
1.14      www       472:                                   $r->print('>'.$metainfo.'<img src="'.
1.7       www       473:                                     $hash{'src_'.$rid}.'"></img>');
1.13      www       474: 			      } elsif ($cellemb{$rid} eq 'emb') {
1.14      www       475:                                   $r->print('>'.$metainfo.'<embed src="'.
1.13      www       476:                                     $hash{'src_'.$rid}.'"></embed>');
                    477:                               }
1.37      sakharuk  478: 			      unless ($target eq 'tex') {
                    479: 				  $r->print('</td>');
1.40      sakharuk  480: 			      } else {
1.43      sakharuk  481:                                   for (my $incol=1;$incol<=$avespan;$incol++) {
                    482: 				      $r->print(' & ');
                    483: 				  }
1.37      sakharuk  484: 			      }
1.4       www       485:                           }
1.37      sakharuk  486: 			      unless ($target eq 'tex') {
                    487: 				  $r->print('</tr>');
1.40      sakharuk  488: 			      } else {
1.42      sakharuk  489: 				  $r->print('REMOVETHEHEADOFLONGTABLE\\\\');
1.37      sakharuk  490: 			      }
1.5       www       491: 		        }
1.4       www       492:                       }
1.37      sakharuk  493: 		      unless ($target eq 'tex') {
                    494: 			  $r->print("\n</table>");
1.40      sakharuk  495: 		      } else {
1.47      sakharuk  496: 			  $r->print('\end{longtable}\strut');
1.37      sakharuk  497: 		      }
1.7       www       498: # ---------------------------------------------------------------- Submit, etc.
                    499:                       if ($nforms) {
                    500:                           $r->print(
                    501: 	                  '<input name="all_submit" value="Submit All" type="'.
                    502: 			  (($nforms>1)?'submit':'hidden').'"></input></form>');
                    503:                       }
1.40      sakharuk  504: 		      unless ($target eq 'tex') {
                    505: 			  $r->print('</body>'.&Apache::lonxml::xmlend());
                    506: 		      } else {
                    507: 			  $r->print('\end{document}'.$number_of_columns);
                    508: 		      }
1.3       www       509: # -------------------------------------------------------------------- End page
                    510:                   }                  
1.1       www       511: # ------------------------------------------------------------- End render page
                    512:               } else {
1.3       www       513:                   $r->content_type('text/html');
                    514:                   $r->send_http_header;
1.39      www       515:                   &Apache::lonsequence::viewmap($r,$requrl);
1.1       www       516:               }
                    517: # ------------------------------------------------------------------ Untie hash
                    518:               unless (untie(%hash)) {
                    519:                    &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                    520:                        "Could not untie coursemap $fn (browse).</font>"); 
                    521:               }
                    522: # -------------------------------------------------------------------- All done
                    523: 	      return OK;
                    524: # ----------------------------------------------- Errors, hash could no be tied
                    525:           }
                    526:       } 
                    527:   }
1.39      www       528:   $r->content_type('text/html');
                    529:   $r->send_http_header;
                    530:   &Apache::lonsequence::viewmap($r,$requrl);
                    531:   return OK; 
1.1       www       532: }
                    533: 
                    534: 1;
                    535: __END__
                    536: 
1.30      harris41  537: =head1 NAME
                    538: 
                    539: Apache::lonpage - Page Handler
                    540: 
                    541: =head1 SYNOPSIS
                    542: 
                    543: Invoked by /etc/httpd/conf/srm.conf:
                    544: 
                    545:  <LocationMatch "^/res/.*\.page$>
                    546:  SetHandler perl-script
                    547:  PerlHandler Apache::lonpage
                    548:  </LocationMatch>
                    549: 
                    550: =head1 INTRODUCTION
                    551: 
                    552: This module renders a .page resource.
                    553: 
                    554: This is part of the LearningOnline Network with CAPA project
                    555: described at http://www.lon-capa.org.
                    556: 
                    557: =head1 HANDLER SUBROUTINE
                    558: 
                    559: This routine is called by Apache and mod_perl.
                    560: 
                    561: =over 4
                    562: 
                    563: =item *
                    564: 
                    565: set document type for header only
                    566: 
                    567: =item *
                    568: 
                    569: tie db file
                    570: 
                    571: =item *
                    572: 
                    573: render page
                    574: 
                    575: =item *
                    576: 
                    577: add to symb list
                    578: 
                    579: =item *
                    580: 
                    581: page parms
                    582: 
                    583: =item *
                    584: 
                    585: Get SSI output, post parameters
                    586: 
                    587: =item *
                    588: 
                    589: SSI cell rendering
                    590: 
                    591: =item *
                    592: 
                    593: Deal with Applet codebases
                    594: 
                    595: =item *
                    596: 
                    597: Build page
                    598: 
                    599: =item *
                    600: 
                    601: send headers
                    602: 
                    603: =item *
                    604: 
                    605: start body
                    606: 
                    607: =item *
                    608: 
                    609: start form
                    610: 
                    611: =item *
                    612: 
                    613: start table
                    614: 
                    615: =item *
                    616: 
                    617: submit element, etc, render page, untie hash
                    618: 
                    619: =back
                    620: 
                    621: =head1 OTHER SUBROUTINES
                    622: 
                    623: =over 4
                    624: 
                    625: =item *
                    626: 
                    627: euclid() : Euclid's method for determining the greatest common denominator.
                    628: 
                    629: =item *
                    630: 
                    631: tracetable() : Build page table.
1.1       www       632: 
1.30      harris41  633: =back
1.1       www       634: 
1.30      harris41  635: =cut
1.1       www       636: 
                    637: 
                    638: 
                    639: 

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