Annotation of rat/lonpageflip.pm, revision 1.4
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.4 ! www 13: # 10/03,10/05,10/06,10/07,10/09 Gerd Kortemeyer
1.1 www 14:
15: package Apache::lonpageflip;
16:
17: use strict;
1.4 ! www 18: use Apache::Constants qw(:common :http REDIRECT);
1.1 www 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 {
1.4 ! www 28: my ($current,$new,$condid)=@_;
! 29: unless ($condid) { $condid=0; }
1.3 www 30: if (&Apache::lonnet::allowed('bre',$hash{'src_'.$new})) {
31: if ($current) {
1.4 ! www 32: $current.=','.$new.':'.$condid;
1.3 www 33: } else {
1.4 ! www 34: $current=''.$new.':'.$condid;
1.3 www 35: }
1.1 www 36: }
1.3 www 37: return $current;
1.1 www 38: }
39:
40: # ================================================================ Main Handler
41:
42: sub handler {
1.2 www 43: my $r=shift;
1.1 www 44:
45: # ------------------------------------------- Set document type for header only
46:
1.2 www 47: if ($r->header_only) {
1.1 www 48: $r->content_type('text/html');
49: $r->send_http_header;
1.2 www 50: return OK;
51: }
52:
1.3 www 53: my %cachehash=();
1.4 ! www 54: my $redirecturl='';
! 55: my $next='';
! 56: my @possibilities=();
1.2 www 57:
58: if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) {
59: $ENV{'form.postdata'}=~/(\w+)\:(.*)/;
60: my $direction=$1;
61: my $currenturl=$2;
62: my $redirecturl=$currenturl;
63: $currenturl=~s/^http\:\/\///;
64: $currenturl=~s/^[^\/]+//;
1.3 www 65: # ------------------------------------------- Do we have any idea where we are?
66: my $position;
67: if ($position=Apache::lonnet::symbread($currenturl)) {
68: # ------------------------------------------------------------------------- Yes
69: my ($mapurl,$mapnum,$thisurl)=split(/\_\_\_/,$position);
70: $cachehash{$thisurl}=$mapnum;
71: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
72: &GDBM_READER,0640)) {
73: my $rid=$hash{'map_pc_/res/'.$mapurl}.'.'.$mapnum;
74: my $next='';
75: if ($direction eq 'forward') {
76: map {
1.4 ! www 77: $next=&addrid($next,$hash{'goesto_'.$_},
! 78: $hash{'condid_'.$hash{'undercond_'.$_}});
1.3 www 79: } split(/\,/,$hash{'to_'.$rid});
80: } elsif ($direction eq 'back') {
1.4 ! www 81: map {
! 82: $next=&addrid($next,$hash{'comesfrom_'.$_},
! 83: $hash{'condid_'.$hash{'undercond_'.$_}});
! 84: } split(/\,/,$hash{'from_'.$rid});
! 85: } elsif ($direction eq 'up') {
1.3 www 86: } elsif ($direction eq 'down') {
87: }
1.4 ! www 88: my $redirectid='';
! 89: # ----------------------------------------------------- Check out possibilities
! 90: if ($next) {
! 91: @possibilities=split(/\,/,$next);
! 92: if ($#possibilities==0) {
! 93: $redirectid=(split(/\:/,$next))[0];
! 94: } else {
! 95: }
! 96: }
! 97: if ($redirectid) {
! 98: $redirecturl=$hash{'src_'.$redirectid};
! 99: }
1.3 www 100: untie(%hash);
1.4 ! www 101: if ($redirecturl) {
! 102: $r->content_type('text/html');
! 103: $r->header_out(Location =>
! 104: 'http://'.$ENV{'HTTP_HOST'}.$redirecturl);
! 105: return REDIRECT;
! 106: }
1.3 www 107: }
1.2 www 108: }
1.4 ! www 109: # -------------------------------------------------------- No, could not decide
! 110: }
! 111: $r->content_type('text/html');
! 112: $r->send_http_header;
! 113:
! 114: $r->print('<html><body>');
! 115:
1.2 www 116: # -------------------------- Class was not initialized or page fliped strangely
117: } else {
118: $ENV{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";
119: return HTTP_NOT_ACCEPTABLE;
120: }
1.1 www 121:
122:
123:
124:
1.2 www 125: # ------TRASH BELOW
126: # --------------------------- TRASH
1.1 www 127:
1.2 www 128: $r->print('</body></html>');
1.1 www 129: return OK;
130:
131:
1.2 www 132: # ========================================================= TOTAL TRASH
1.1 www 133:
1.3 www 134: # &Apache::lonnet::symblist($requrl,%symbhash);
1.1 www 135:
136: }
137:
138: 1;
139: __END__
140:
141:
142:
143:
144:
145:
146:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>