--- loncom/interface/lonnavmaps.pm 2003/03/21 22:41:12 1.165 +++ loncom/interface/lonnavmaps.pm 2003/04/04 19:08:46 1.172 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.165 2003/03/21 22:41:12 albertel Exp $ +# $Id: lonnavmaps.pm,v 1.172 2003/04/04 19:08:46 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,6 @@ # Jeremy Bowers ... lots of days package Apache::lonnavmaps; -use vars qw($test @refsToUntie); use strict; use Apache::Constants qw(:common :http); @@ -50,10 +49,6 @@ use Apache::loncommon(); use Apache::lonmenu(); use POSIX qw (floor strftime); -my %navmaphash; -my %parmhash; -@refsToUntie; - # symbolic constants sub SYMB { return 1; } sub URL { return 2; } @@ -100,33 +95,6 @@ my %colormap = # And a special case in the nav map; what to do when the assignment # is not yet done and due in less then 24 hours my $hurryUpColor = "#FF0000"; -$test = 'abc'; -sub cleanup { - &Apache::lonnet::logthis("Cleanup called."); - &Apache::lonnet::logthis("refs size".scalar(@refsToUntie)); - &Apache::lonnet::logthis("test is ".$test); - $test = '467'; - if (tied(%navmaphash)){ - &Apache::lonnet::logthis('Cleanup navmaps: navmaphash'); - unless (untie(%navmaphash)) { - &Apache::lonnet::logthis('Failed cleanup navmaps: navmaphash'); - } - } - if (tied(%parmhash)){ - &Apache::lonnet::logthis('Cleanup navmaps: parmhash'); - unless (untie(%parmhash)) { - &Apache::lonnet::logthis('Failed cleanup navmaps: parmhash'); - } - } - # Apparently, if you take a reference to a tied hash, both the - # original hash and the tied hash must be untied. Bleh. - for my $ref (@refsToUntie) { - &Apache::lonnet::logthis('Cleanup navmaps: reference'); - unless (untie($ref)) { - &Apache::lonnet::logthis('Failed cleanup navmaps: reference'); - } - } -} sub handler { my $r = shift; @@ -157,7 +125,7 @@ sub real_handler { $r->send_http_header; # Create the nav map - my $navmap = Apache::lonnavmaps::navmap->new($r, + my $navmap = Apache::lonnavmaps::navmap->new( $ENV{"request.course.fn"}.".db", $ENV{"request.course.fn"}."_parms.db", 1, 1); @@ -231,22 +199,11 @@ sub real_handler { # renderer call my $render = render({ 'cols' => [0,1,2,3], 'url' => '/adm/navmaps', + 'navmap' => $navmap, 'suppressNavmap' => 1, 'r' => $r}); - #$navmap->untieHashes(); - - if (tied(%navmaphash)) { - $r->print("Dang it."); - } else { - $r->print("It's out."); - } - - if (tied(%parmhash)) { - $r->print("Dang it."); - } else { - $r->print("It's out."); - } + $navmap->untieHashes(); $r->print(""); $r->rflush(); @@ -534,7 +491,7 @@ The pre-packaged column names are refere =item * B: If true (default), the resource will show a part count if the full part list is not displayed. If false, the resource will never show a part count. -=item * B: If true, the resource's folder will not be clickable to open or close it. Default is false. +=item * B: If true, the resource's folder will not be clickable to open or close it. Default is false. True implies printCloseAll is false, since you can't close or open folders when this is on anyhow. =back @@ -891,7 +848,7 @@ sub render { if (!$ENV{'form.folderManip'} && !defined($args->{'iterator'})) { # Step 1: Check to see if we have a navmap if (!defined($navmap)) { - $navmap = Apache::lonnavmaps::navmap->new($r, + $navmap = Apache::lonnavmaps::navmap->new( $ENV{"request.course.fn"}.".db", $ENV{"request.course.fn"}."_parms.db", 1, 1); $mustCloseNavMap = 1; @@ -1036,7 +993,7 @@ sub render { $result .= ''; } - if ($printCloseAll) { + if ($printCloseAll && !$args->{'resource_no_folder_link'}) { if ($condition) { $result.="{NAV_HASH} = \%navmaphash; + $self->{PARM_HASH} = \%parmhash; $self->{INITED} = 0; - $self->{RESPONSE}->register_cleanup(\&Apache::lonnavmaps::cleanup); - Apache::lonnet::logthis("Pushed cleanup."); - bless($self); return $self; @@ -1475,18 +1433,11 @@ sub getIterator { # unties the hash when done sub untieHashes { -# my $self = shift; -# untie $self->{NAV_HASH}; -# untie $self->{PARM_HASH}; -# &Apache::lonnavmaps::cleanup(); + my $self = shift; + untie %{$self->{NAV_HASH}}; + untie %{$self->{PARM_HASH}}; } -# when the object is destroyed, be sure to untie all the hashes we tied. -#sub DESTROY { -# my $self = shift; -# $self->untieHashes(); -#} - # Private method: Does the given resource (as a symb string) have # current discussion? Returns 0 if chat/mail data not extracted. sub hasDiscussion { @@ -1546,6 +1497,14 @@ sub getById { return "Apache::lonnavmaps::resource"->new($self, $id); } +sub getBySymb { + my $self = shift; + my $symb = shift; + my ($mapUrl, $id, $filename) = split (/___/, $symb); + my $map = $self->getResourceByUrl($mapUrl); + return $self->getById($map->map_pc() . '.' . $id); +} + =pod =item * B(): Returns a resource object reference corresponding to the first resource in the navmap. @@ -1713,7 +1672,7 @@ sub retrieveResources { # Create the necessary iterator. if (!ref($map)) { # assume it's a url of a map. - $map = $self->getMapByUrl($map); + $map = $self->getResourceByUrl($map); } # Check the map's validity.