Annotation of rat/lonpageflip.pm, revision 1.3

1.1       www         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: #
1.3     ! www        13: # 10/03,10/05,10/06,10/07 Gerd Kortemeyer
1.1       www        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: 
1.3     ! www        23: # ========================================================== Module Global Hash
        !            24:   
1.1       www        25: my %hash;
                     26: 
1.3     ! www        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:         }
1.1       www        35:     }
1.3     ! www        36:     return $current;
1.1       www        37: }
                     38: 
                     39: # ================================================================ Main Handler
                     40: 
                     41: sub handler {
1.2       www        42:    my $r=shift;
1.1       www        43: 
                     44: # ------------------------------------------- Set document type for header only
                     45: 
1.2       www        46:   if ($r->header_only) {
1.1       www        47:      $r->content_type('text/html');
                     48:      $r->send_http_header;
1.2       www        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: 
1.3     ! www        60:   my %cachehash=();
        !            61:   my $redir=0;
1.2       www        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/^[^\/]+//;
1.3     ! www        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:           }
1.2       www        95:       } else {
1.3     ! www        96: # -------------------------------------------------------------------------- No
        !            97: 	  $r->print('No idea '.$currenturl);
1.2       www        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:   } 
1.1       www       104: 
                    105: 
                    106: 
                    107: 
1.2       www       108: # ------TRASH BELOW
                    109: # --------------------------- TRASH
1.1       www       110: 
1.2       www       111:   $r->print('</body></html>');
1.1       www       112:   return OK;
                    113: 
                    114: 
1.2       www       115: # ========================================================= TOTAL TRASH
1.1       www       116: 
1.3     ! www       117: #                  &Apache::lonnet::symblist($requrl,%symbhash);
1.1       www       118: 
                    119: }
                    120: 
                    121: 1;
                    122: __END__
                    123: 
                    124: 
                    125: 
                    126: 
                    127: 
                    128: 
                    129: 

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