--- loncom/interface/lonnavmaps.pm 2002/09/02 18:25:55 1.45
+++ loncom/interface/lonnavmaps.pm 2003/01/14 14:59:47 1.128
@@ -1,7 +1,8 @@
+
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.45 2002/09/02 18:25:55 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.128 2003/01/14 14:59:47 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,62 +37,1227 @@
# 3/1/1,6/1,17/1,29/1,30/1,2/8,9/21,9/24,9/25 Gerd Kortemeyer
# YEAR=2002
# 1/1 Gerd Kortemeyer
-#
+# Oct-Nov Jeremy Bowers
package Apache::lonnavmaps;
use strict;
use Apache::Constants qw(:common :http);
-use Apache::lonnet();
use Apache::loncommon();
-use HTML::TokeParser;
+use POSIX qw (floor strftime);
+
+sub handler {
+ my $r = shift;
+ real_handler($r);
+}
+
+sub real_handler {
+ my $r = shift;
+
+ &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
+
+ # Handle header-only request
+ if ($r->header_only) {
+ if ($ENV{'browser.mathml'}) {
+ $r->content_type('text/xml');
+ } else {
+ $r->content_type('text/html');
+ }
+ $r->send_http_header;
+ return OK;
+ }
+
+ # Send header, don't cache this page
+ if ($ENV{'browser.mathml'}) {
+ $r->content_type('text/xml');
+ } else {
+ $r->content_type('text/html');
+ }
+ &Apache::loncommon::no_cache($r);
+ $r->send_http_header;
+
+ # Create the nav map
+ my $navmap = Apache::lonnavmaps::navmap->new(
+ $ENV{"request.course.fn"}.".db",
+ $ENV{"request.course.fn"}."_parms.db", 1, 1);
+
+
+ if (!defined($navmap)) {
+ my $requrl = $r->uri;
+ $ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized";
+ return HTTP_NOT_ACCEPTABLE;
+ }
+
+ $r->print("
\n");
+ $r->print("Navigate Course Contents");
+
+ # Header
+ $r->print(&Apache::loncommon::bodytag('Navigate Course Contents','',
+ ''));
+ $r->print('');
+
+ $r->rflush();
+
+ # Now that we've displayed some stuff to the user, init the navmap
+ $navmap->init();
+
+ $r->print('');
+
+ my $condition = 0;
+ if ($ENV{'form.condition'}) {
+ $condition = 1;
+ }
+
+ # Determine where the "here" marker is and where the screen jumps to.
+ my $SYMB = 1; my $URL = 2; my $NOTHING = 3; # symbolic constants
+ my $hereType; # the type of marker, $SYMB, $URL, or $NOTHING
+ my $here; # the actual URL or SYMB for the here marker
+ my $jumpType; # The type of the thing we have a jump for, $SYMB or $URL
+ my $jump; # the SYMB/URL of the resource we need to jump to
+
+ if ( $ENV{'form.alreadyHere'} ) { # we came from a user's manipulation of the nav page
+ # If this is a click on a folder or something, we want to preserve the "here"
+ # from the querystring, and get the new "jump" marker
+ $hereType = $ENV{'form.hereType'};
+ $here = $ENV{'form.here'};
+ $jumpType = $ENV{'form.jumpType'} || $NOTHING;
+ $jump = $ENV{'form.jump'};
+ } else { # the user is visiting the nav map from the remote
+ # We're coming from the remote. We have either a url, a symb, or nothing,
+ # and we need to figure out what.
+ # Preference: Symb
+
+ if ($ENV{'form.symb'}) {
+ $hereType = $jumpType = $SYMB;
+ $here = $jump = $ENV{'form.symb'};
+ } elsif ($ENV{'form.postdata'}) {
+ # couldn't find a symb, is there a URL?
+ my $currenturl = $ENV{'form.postdata'};
+ $currenturl=~s/^http\:\/\///;
+ $currenturl=~s/^[^\/]+//;
+
+ $hereType = $jumpType = $URL;
+ $here = $jump = $currenturl;
+ } else {
+ # Nothing
+ $hereType = $jumpType = $NOTHING;
+ }
+ }
+
+
+ # alreadyHere allows us to only open the maps necessary to view
+ # the current location once, while at the same time remembering
+ # the current location. Without that check, the user would never
+ # be able to close those maps; the user would close it, and the
+ # currenturl scan would re-open it.
+ my $queryAdd = "&alreadyHere=1";
+
+ if ($condition) {
+ $r->print("Close All Folders");
+ } else {
+ $r->print("Open All Folders");
+ }
+
+ $r->print('
');
+ $r->rflush();
+
+ # Check that it's defined
+ if (!($navmap->courseMapDefined())) {
+ $r->print('Coursemap undefined.' .
+ '