File:  [LON-CAPA] / rat / lonpage.pm
Revision 1.80: download - view: text, annotated - select for diffs
Fri Jun 22 21:24:54 2007 UTC (16 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- allow anything but ' or " in the name field on input elements
  (needed to get .problem wioth part id with spaces in the ids to work)

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

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