--- rat/lonpage.pm 2001/11/29 19:23:48 1.29 +++ rat/lonpage.pm 2001/12/17 00:57:59 1.30 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.29 2001/11/29 19:23:48 www Exp $ +# $Id: lonpage.pm,v 1.30 2001/12/17 00:57:59 harris41 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,16 +27,22 @@ # # (TeX Content Handler # +# YEAR=2000 # 05/29/00,05/30 Gerd Kortemeyer) # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, # 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16, +# YEAR=2001 # 08/13/01,08/30,10/1 Gerd Kortemeyer +# 12/16 Scott Harrison +# +### package Apache::lonpage; use strict; use Apache::Constants qw(:common :http); use Apache::lonnet(); +use Apache::loncommon(); use Apache::lonxml(); use HTML::TokeParser; use GDBM_File; @@ -102,7 +108,7 @@ sub tracetable { if (defined($hash{'to_'.$rid})) { my $mincond=1; my $next=''; - map { + foreach (split(/\,/,$hash{'to_'.$rid})) { my $thiscond= &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}}); if ($thiscond>=$mincond) { @@ -113,14 +119,14 @@ sub tracetable { } if ($thiscond>$mincond) { $mincond=$thiscond; } } - } split(/\,/,$hash{'to_'.$rid}); - map { + } + foreach (split(/\,/,$next)) { my ($linkid,$condval)=split(/\:/,$_); if ($condval>=$mincond) { my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere); if ($now>$further) { $further=$now; } } - } split(/\,/,$next); + } } } @@ -174,9 +180,9 @@ sub handler { for ($i=0;$i<=$#rows;$i++) { if ($rows[$i]) { my @colcont=split(/\&/,$rows[$i]); - map { + foreach (@colcont) { $symbhash{$hash{'src_'.$_}}=''; - } @colcont; + } } } &Apache::lonnet::symblist($requrl,%symbhash); @@ -213,24 +219,24 @@ sub handler { $contents++; my @colcont=split(/\&/,$rows[$i]); $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1)); - map { + foreach (@colcont) { my $src=$hash{'src_'.$_}; $src=~/\.(\w+)$/; $metalink{$_}=$src.'.meta'; - $cellemb{$_}=Apache::lonnet::fileembstyle($1); + $cellemb{$_}=Apache::loncommon::fileembstyle($1); if ($cellemb{$_} eq 'ssi') { # --------------------------------------------------------- This is an SSI cell my $prefix=$_.'_'; my %posthash=('request.prefix' => $prefix); if (($ENV{'form.'.$prefix.'submit'}) || ($ENV{'form.all_submit'})) { - map { + foreach (keys %ENV) { if ($_=~/^form.$prefix/) { my $name=$_; $name=~s/^form.$prefix//; $posthash{$name}=$ENV{$_}; } - } keys %ENV; + } } my $output=Apache::lonnet::ssi($src,%posthash); my $parser=HTML::TokeParser->new(\$output); @@ -296,20 +302,20 @@ sub handler { s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([\w\.\:]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi; } $thisdir=~s/\/[^\/]*$//; - map { + foreach (@rlinks) { unless (($_=~/^http:\/\//i) || ($_=~/^\//)) { my $newlocation= &Apache::lonnet::hreflocation($thisdir,$_); $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/; } - } @rlinks; + } # -------------------------------------------------- Deal with Applet codebases $output=~s/(\]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei; $ssibody{$_}=$output; # ---------------------------------------------------------------- End SSI cell } - } @colcont; + } } } unless ($contents) { @@ -454,8 +460,105 @@ sub handler { 1; __END__ +=head1 NAME + +Apache::lonpage - Page Handler + +=head1 SYNOPSIS + +Invoked by /etc/httpd/conf/srm.conf: + + + SetHandler perl-script + PerlHandler Apache::lonpage + + +=head1 INTRODUCTION + +This module renders a .page resource. + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 HANDLER SUBROUTINE + +This routine is called by Apache and mod_perl. + +=over 4 + +=item * + +set document type for header only + +=item * + +tie db file + +=item * + +render page + +=item * + +add to symb list + +=item * + +page parms + +=item * + +Get SSI output, post parameters + +=item * + +SSI cell rendering + +=item * + +Deal with Applet codebases + +=item * + +Build page + +=item * + +send headers + +=item * + +start body + +=item * + +start form + +=item * + +start table + +=item * + +submit element, etc, render page, untie hash + +=back + +=head1 OTHER SUBROUTINES + +=over 4 + +=item * + +euclid() : Euclid's method for determining the greatest common denominator. + +=item * + +tracetable() : Build page table. +=back +=cut