--- rat/lonpageflip.pm 2005/03/01 00:22:57 1.52 +++ rat/lonpageflip.pm 2005/08/02 20:51:18 1.54 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.52 2005/03/01 00:22:57 albertel Exp $ +# $Id: lonpageflip.pm,v 1.54 2005/08/02 20:51:18 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,7 +31,7 @@ package Apache::lonpageflip; use strict; use Apache::Constants qw(:common :http REDIRECT); -use Apache::lonnet(); +use Apache::lonnet; use HTML::TokeParser; use GDBM_File; @@ -63,7 +63,7 @@ sub addrid { sub fullmove { my ($rid,$mapurl,$direction)=@_; - if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db', + if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db', &GDBM_READER(),0640)) { ($rid,$mapurl)=&move($rid,$mapurl,$direction); untie(%hash); @@ -171,6 +171,28 @@ sub move { return ($next,$mapurl); } +sub navlaunch { + my ($r)=@_; + &Apache::loncommon::content_type($r,'text/html'); + &Apache::loncommon::no_cache($r); + $r->send_http_header; + my $html=&Apache::lonxml::xmlbegin(); + $r->print("$html\n"); + $r->print(''. + &Apache::loncommon::bodytag('Launched')); + $r->print(<Goto first resource

+ +

Collapse External Navigation Window

+ENDNAV + $r->print(&Apache::loncommon::endbodytag().''); +} # ================================================================ Main Handler sub handler { @@ -191,24 +213,37 @@ sub handler { my $next=''; my @possibilities=(); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']); - if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) { - $ENV{'form.postdata'}=~/(\w+)\:(.*)/; + if (($env{'form.postdata'})&&($env{'request.course.fn'})) { + $env{'form.postdata'}=~/(\w+)\:(.*)/; my $direction=$1; my $currenturl=$2; if ($currenturl=~m|^/enc/|) { $currenturl=&Apache::lonenc::unencrypted($currenturl); } $currenturl=~s/\.\d+\.(\w+)$/\.$1/; - if ($direction eq 'return') { + if ($direction eq 'firstres') { + my $furl; + if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db', + &GDBM_READER(),0640)) { + $furl=$bighash{'first_url'}; + untie(%bighash); + } + &Apache::loncommon::content_type($r,'text/html'); + $r->header_out(Location => + 'http://'.$ENV{'HTTP_HOST'}.$furl); + + return REDIRECT; + } + if ($direction eq 'return' || $direction eq 'navlaunch') { # -------------------------------------------------------- Return to last known my $last; - if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', + if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', &GDBM_READER(),0640)) { $last=$hash{'last_known'}; untie(%hash); } my $newloc; - if (($last) && (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db', + if (($last) && (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db', &GDBM_READER(),0640))) { my ($murl,$id,$fn)=&Apache::lonnet::decode_symb($last); $id=$hash{'map_pc_'.&Apache::lonnet::clutter($murl)}.'.'.$id; @@ -223,11 +258,16 @@ sub handler { } else { $newloc='/adm/noidea.html'; } - &Apache::loncommon::content_type($r,'text/html'); - $r->header_out(Location => - 'http://'.$ENV{'HTTP_HOST'}.$newloc); - - return REDIRECT; + if ($newloc eq '/adm/noidea.html' && $direction eq 'navlaunch') { + &navlaunch($r); + return OK; + } else { + &Apache::loncommon::content_type($r,'text/html'); + $r->header_out(Location => + 'http://'.$ENV{'HTTP_HOST'}.$newloc); + + return REDIRECT; + } } $currenturl=~s/^http\:\/\///; $currenturl=~s/^[^\/]+//; @@ -236,7 +276,7 @@ sub handler { # unless (&Apache::lonnet::is_on_map($currenturl)) { my $last; - if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', + if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', &GDBM_READER(),0640)) { $last=$hash{'last_known'}; untie(%hash); @@ -244,10 +284,15 @@ sub handler { if ($last) { $currenturl=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($last))[2]); } else { - &Apache::loncommon::content_type($r,'text/html'); - $r->header_out(Location => - 'http://'.$ENV{'HTTP_HOST'}.'/adm/noidea.html'); - return REDIRECT; + if ($direction eq 'return') { + &Apache::loncommon::content_type($r,'text/html'); + $r->header_out(Location => + 'http://'.$ENV{'HTTP_HOST'}.'/adm/noidea.html'); + return REDIRECT; + } else { + &navlaunch($r); + return OK; + } } } # ------------------------------------------- Do we have any idea where we are? @@ -260,7 +305,7 @@ sub handler { [&Apache::lonnet::declutter($currenturl),$mapnum]; # ============================================================ Tie the big hash - if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db', + if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db', &GDBM_READER(),0640)) { my $rid=$hash{'map_pc_'.&Apache::lonnet::clutter($startoutmap)}. '.'.$mapnum; @@ -272,7 +317,7 @@ sub handler { my $safecount=0; while (($next) && ($next!~/\,/) && ((!$hash{'src_'.$next}) || - ((!$ENV{'request.role.adv'}) && $hash{'randomout_'.$next})) + ((!$env{'request.role.adv'}) && $hash{'randomout_'.$next})) && ($safecount<10000)) { ($next,$endupmap)=&move($next,$endupmap,$direction); $safecount++; @@ -329,10 +374,10 @@ sub handler { &Apache::lonnet::linklog($redirecturl,$currenturl); } # ------------------------------------------------- Check for critical messages - if ((time-$ENV{'user.criticalcheck.time'})>300) { + if ((time-$env{'user.criticalcheck.time'})>300) { my @what=&Apache::lonnet::dump - ('critical',$ENV{'user.domain'}, - $ENV{'user.name'}); + ('critical',$env{'user.domain'}, + $env{'user.name'}); if ($what[0]) { if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) { @@ -394,7 +439,7 @@ ENDNONE } } else { # ------------------------------------------------- Problem, could not tie hash - $ENV{'user.error.msg'}="/adm/flip:bre:0:1:Course Data Missing"; + $env{'user.error.msg'}="/adm/flip:bre:0:1:Course Data Missing"; return HTTP_NOT_ACCEPTABLE; } } else { @@ -406,7 +451,7 @@ ENDNONE } } else { # -------------------------- Class was not initialized or page fliped strangely - $ENV{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course"; + $env{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course"; return HTTP_NOT_ACCEPTABLE; } }