File:  [LON-CAPA] / rat / lonpageflip.pm
Revision 1.3: download - view: text, annotated - select for diffs
Sat Oct 7 22:30:30 2000 UTC (23 years, 6 months ago) by www
Branches: MAIN
CVS tags: HEAD
Slowly (slowly!!!) starting to make some kind of remote sense

    1: # The LearningOnline Network with CAPA
    2: #
    3: # Page flip handler
    4: #
    5: # (Page Handler
    6: #
    7: # (TeX Content Handler
    8: #
    9: # 05/29/00,05/30 Gerd Kortemeyer)
   10: # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23,
   11: # 10/02 Gerd Kortemeyer)
   12: #
   13: # 10/03,10/05,10/06,10/07 Gerd Kortemeyer
   14: 
   15: package Apache::lonpageflip;
   16: 
   17: use strict;
   18: use Apache::Constants qw(:common :http);
   19: use Apache::lonnet();
   20: use HTML::TokeParser;
   21: use GDBM_File;
   22: 
   23: # ========================================================== Module Global Hash
   24:   
   25: my %hash;
   26: 
   27: sub addrid {
   28:     my ($current,$new)=@_;
   29:     if (&Apache::lonnet::allowed('bre',$hash{'src_'.$new})) {
   30: 	if ($current) {
   31: 	    $current.=','.$new;
   32:         } else {
   33:             $current=''.$new;
   34:         }
   35:     }
   36:     return $current;
   37: }
   38: 
   39: # ================================================================ Main Handler
   40: 
   41: sub handler {
   42:    my $r=shift;
   43: 
   44: # ------------------------------------------- Set document type for header only
   45: 
   46:   if ($r->header_only) {
   47:      $r->content_type('text/html');
   48:      $r->send_http_header;
   49:      return OK;
   50:   }
   51: 
   52: 
   53: # --------BEGIN DEBUG ONLY TRASH
   54:     $r->content_type('text/html');
   55:      $r->send_http_header;
   56: 
   57:   $r->print('<html><body>');
   58: # --------END DEBUG ONLY TRASH
   59: 
   60:   my %cachehash=();
   61:   my $redir=0;
   62: 
   63:   if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) {
   64:       $ENV{'form.postdata'}=~/(\w+)\:(.*)/;
   65:       my $direction=$1;
   66:       my $currenturl=$2;
   67:       my $redirecturl=$currenturl;
   68:       $currenturl=~s/^http\:\/\///;
   69:       $currenturl=~s/^[^\/]+//;
   70: # ------------------------------------------- Do we have any idea where we are?
   71:       my $position;
   72:       if ($position=Apache::lonnet::symbread($currenturl)) {
   73: # ------------------------------------------------------------------------- Yes
   74: 	  my ($mapurl,$mapnum,$thisurl)=split(/\_\_\_/,$position);
   75:           $cachehash{$thisurl}=$mapnum;
   76:           if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
   77:                         &GDBM_READER,0640)) {
   78:               my $rid=$hash{'map_pc_/res/'.$mapurl}.'.'.$mapnum;
   79:               my $next='';
   80:               if ($direction eq 'forward') {
   81:                  map {
   82: 		    $next=&addrid($next,$hash{'goesto_'.$_});
   83:                   } split(/\,/,$hash{'to_'.$rid});
   84:                   my @possibilities=split(/,/,$next);
   85:                   if ($#possibilities==1) {
   86: 	              my $goto=$possibilities[0];
   87: 		  }
   88:               } elsif ($direction eq 'back') {
   89: 	      } elsif ($direction eq 'up') {
   90:               } elsif ($direction eq 'down') {
   91:               }
   92: 	      untie(%hash);
   93:               $r->print($rid.' - '.$next);
   94:           }
   95:       } else {
   96: # -------------------------------------------------------------------------- No
   97: 	  $r->print('No idea '.$currenturl);
   98:       }
   99: # -------------------------- Class was not initialized or page fliped strangely
  100:   } else {
  101:       $ENV{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";
  102:       return HTTP_NOT_ACCEPTABLE; 
  103:   } 
  104: 
  105: 
  106: 
  107: 
  108: # ------TRASH BELOW
  109: # --------------------------- TRASH
  110: 
  111:   $r->print('</body></html>');
  112:   return OK;
  113: 
  114: 
  115: # ========================================================= TOTAL TRASH
  116: 
  117: #                  &Apache::lonnet::symblist($requrl,%symbhash);
  118: 
  119: }
  120: 
  121: 1;
  122: __END__
  123: 
  124: 
  125: 
  126: 
  127: 
  128: 
  129: 

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