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

# The LearningOnline Network with CAPA
#
# Page flip handler
#
# (Page Handler
#
# (TeX Content Handler
#
# 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 Gerd Kortemeyer)
#
# 10/03,10/05,10/06,10/07 Gerd Kortemeyer

package Apache::lonpageflip;

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

# ========================================================== Module Global Hash
  
my %hash;

sub addrid {
    my ($current,$new)=@_;
    if (&Apache::lonnet::allowed('bre',$hash{'src_'.$new})) {
	if ($current) {
	    $current.=','.$new;
        } else {
            $current=''.$new;
        }
    }
    return $current;
}

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

sub handler {
   my $r=shift;

# ------------------------------------------- Set document type for header only

  if ($r->header_only) {
     $r->content_type('text/html');
     $r->send_http_header;
     return OK;
  }


# --------BEGIN DEBUG ONLY TRASH
    $r->content_type('text/html');
     $r->send_http_header;

  $r->print('<html><body>');
# --------END DEBUG ONLY TRASH

  my %cachehash=();
  my $redir=0;

  if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) {
      $ENV{'form.postdata'}=~/(\w+)\:(.*)/;
      my $direction=$1;
      my $currenturl=$2;
      my $redirecturl=$currenturl;
      $currenturl=~s/^http\:\/\///;
      $currenturl=~s/^[^\/]+//;
# ------------------------------------------- Do we have any idea where we are?
      my $position;
      if ($position=Apache::lonnet::symbread($currenturl)) {
# ------------------------------------------------------------------------- Yes
	  my ($mapurl,$mapnum,$thisurl)=split(/\_\_\_/,$position);
          $cachehash{$thisurl}=$mapnum;
          if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
                        &GDBM_READER,0640)) {
              my $rid=$hash{'map_pc_/res/'.$mapurl}.'.'.$mapnum;
              my $next='';
              if ($direction eq 'forward') {
                 map {
		    $next=&addrid($next,$hash{'goesto_'.$_});
                  } split(/\,/,$hash{'to_'.$rid});
                  my @possibilities=split(/,/,$next);
                  if ($#possibilities==1) {
	              my $goto=$possibilities[0];
		  }
              } elsif ($direction eq 'back') {
	      } elsif ($direction eq 'up') {
              } elsif ($direction eq 'down') {
              }
	      untie(%hash);
              $r->print($rid.' - '.$next);
          }
      } else {
# -------------------------------------------------------------------------- No
	  $r->print('No idea '.$currenturl);
      }
# -------------------------- Class was not initialized or page fliped strangely
  } else {
      $ENV{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";
      return HTTP_NOT_ACCEPTABLE; 
  } 




# ------TRASH BELOW
# --------------------------- TRASH

  $r->print('</body></html>');
  return OK;


# ========================================================= TOTAL TRASH

#                  &Apache::lonnet::symblist($requrl,%symbhash);

}

1;
__END__








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