File:  [LON-CAPA] / rat / lonpage.pm
Revision 1.1: download - view: text, annotated - select for diffs
Wed Aug 30 11:10:23 2000 UTC (23 years, 7 months ago) by www
Branches: MAIN
CVS tags: HEAD
Page Handler

# The LearningOnline Network with CAPA
# Page Handler
#
# (TeX Content Handler
#
# 05/29/00,05/30 Gerd Kortemeyer)
# 08/30 Gerd Kortemeyer

package Apache::lonpage;

use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet();
use GDBM_File;

# ================================================================ Main Handler

sub handler {
  my $r=shift;

# ----------------------------------------------------------- Set document type

  if ($ENV{'browser.mathml'}) {
    $r->content_type('text/xml');
  } else {
    $r->content_type('text/html');
  }
  $r->send_http_header;

  return OK if $r->header_only;

  my $requrl=$r->uri;
# ----------------------------------------------------------------- Tie db file
  if ($ENV{'request.course.fn'}) {
      my $fn=$ENV{'request.course.fn'};
      if (-e "$fn.db") {
          my %hash;
          if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT,0640)) {
# ------------------------------------------------------------------- Hash tied
              my $firstres=$hash{'map_start_'.$requrl};
              my $lastres=$hash{'map_finish_'.$requrl};
              if (($firstres) && ($lastres)) {
# ----------------------------------------------------------------- Render page

		  $r->print("<h2>All is cool.</h2>");

# ------------------------------------------------------------- End render page
              } else {
		  $r->print("<h2>Page undefined.</h2>");
              }
# ------------------------------------------------------------------ Untie hash
              unless (untie(%hash)) {
                   &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                       "Could not untie coursemap $fn (browse).</font>"); 
              }
# -------------------------------------------------------------------- All done
	      return OK;
# ----------------------------------------------- Errors, hash could no be tied
          }
      } 
  }
  $ENV{'user.error.msg'}="$requrl:bre:1:1:Course not initialized";
  return HTTP_NOT_ACCEPTABLE; 
}

1;
__END__








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