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, 8 months ago) by www
Branches: MAIN
CVS tags: HEAD
Page Handler

    1: # The LearningOnline Network with CAPA
    2: # Page Handler
    3: #
    4: # (TeX Content Handler
    5: #
    6: # 05/29/00,05/30 Gerd Kortemeyer)
    7: # 08/30 Gerd Kortemeyer
    8: 
    9: package Apache::lonpage;
   10: 
   11: use strict;
   12: use Apache::Constants qw(:common :http);
   13: use Apache::lonnet();
   14: use GDBM_File;
   15: 
   16: # ================================================================ Main Handler
   17: 
   18: sub handler {
   19:   my $r=shift;
   20: 
   21: # ----------------------------------------------------------- Set document type
   22: 
   23:   if ($ENV{'browser.mathml'}) {
   24:     $r->content_type('text/xml');
   25:   } else {
   26:     $r->content_type('text/html');
   27:   }
   28:   $r->send_http_header;
   29: 
   30:   return OK if $r->header_only;
   31: 
   32:   my $requrl=$r->uri;
   33: # ----------------------------------------------------------------- Tie db file
   34:   if ($ENV{'request.course.fn'}) {
   35:       my $fn=$ENV{'request.course.fn'};
   36:       if (-e "$fn.db") {
   37:           my %hash;
   38:           if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT,0640)) {
   39: # ------------------------------------------------------------------- Hash tied
   40:               my $firstres=$hash{'map_start_'.$requrl};
   41:               my $lastres=$hash{'map_finish_'.$requrl};
   42:               if (($firstres) && ($lastres)) {
   43: # ----------------------------------------------------------------- Render page
   44: 
   45: 		  $r->print("<h2>All is cool.</h2>");
   46: 
   47: # ------------------------------------------------------------- End render page
   48:               } else {
   49: 		  $r->print("<h2>Page undefined.</h2>");
   50:               }
   51: # ------------------------------------------------------------------ Untie hash
   52:               unless (untie(%hash)) {
   53:                    &Apache::lonnet::logthis("<font color=blue>WARNING: ".
   54:                        "Could not untie coursemap $fn (browse).</font>"); 
   55:               }
   56: # -------------------------------------------------------------------- All done
   57: 	      return OK;
   58: # ----------------------------------------------- Errors, hash could no be tied
   59:           }
   60:       } 
   61:   }
   62:   $ENV{'user.error.msg'}="$requrl:bre:1:1:Course not initialized";
   63:   return HTTP_NOT_ACCEPTABLE; 
   64: }
   65: 
   66: 1;
   67: __END__
   68: 
   69: 
   70: 
   71: 
   72: 
   73: 
   74: 

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