--- loncom/interface/lonnavmaps.pm 2003/03/20 18:03:14 1.162 +++ 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.162 2003/03/20 18:03:14 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.172 2003/04/04 19:08:46 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,9 +49,6 @@ use Apache::loncommon(); use Apache::lonmenu(); use POSIX qw (floor strftime); -my %navmaphash; -my %parmhash; - # symbolic constants sub SYMB { return 1; } sub URL { return 2; } @@ -99,21 +96,6 @@ my %colormap = # is not yet done and due in less then 24 hours my $hurryUpColor = "#FF0000"; -sub cleanup { - 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'); - } - } -} - sub handler { my $r = shift; real_handler($r); @@ -217,6 +199,7 @@ sub real_handler { # renderer call my $render = render({ 'cols' => [0,1,2,3], 'url' => '/adm/navmaps', + 'navmap' => $navmap, 'suppressNavmap' => 1, 'r' => $r}); @@ -508,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 @@ -544,6 +527,8 @@ Most of these parameters are only useful =item * B: A reference to a navmap, used only if an iterator is not passed in. If this is necessary to make an iterator but it is not passed in, a new one will be constructed based on ENV info. This is useful to do basic error checking before passing it off to render. +=item * B: The standard Apache response object. This must be passed to the renderer or the course hash will be locked. + =item * B: An array reference =item * B: A flag. If yes (default), a line for the resource itself, and a line for each part will be displayed. If not, only one line for each resource will be displayed. @@ -562,8 +547,6 @@ Most of these parameters are only useful =item * B: Describes the currently-open row number to cause the browser to jump to, because the user just opened that folder. By default, pulled from the Jump information in the ENV{'form.*'}. -=item * B: The standard Apache response object. If you pass this to the render, it will use it to flush the table every 20 rows and handle the rendering itself. - =item * B: If true, print the key that appears on the top of the standard navmaps. Default is false. =item * B: If true, print the "Close all folders" or "open all folders" links. Default is true. @@ -700,7 +683,7 @@ sub render_resource { $title = ""; } - if ($params->{'multipart'} && $params->{'condensed'}) { + if ($params->{'condensed'} && $resource->countParts() > 1) { $nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; } @@ -931,7 +914,7 @@ sub render { # Step 1: Check to see if we have a navmap if (!defined($navmap)) { - $navmap = Apache::lonnavmaps::navmap->new( + $navmap = Apache::lonnavmaps::navmap->new($r, $ENV{"request.course.fn"}.".db", $ENV{"request.course.fn"}."_parms.db", 1, 1); $mustCloseNavMap = 1; @@ -1010,7 +993,7 @@ sub render { $result .= ''; } - if ($printCloseAll) { + if ($printCloseAll && !$args->{'resource_no_folder_link'}) { if ($condition) { $result.="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. @@ -1678,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. @@ -2698,14 +2692,16 @@ sub countParts { my $self = shift; my $parts = $self->parts(); + my $delta = 0; + for my $part (@$parts) { + if ($part eq '0') { $delta--; } + } if ($self->{RESOURCE_ERROR}) { return 0; } - if (scalar(@{$parts}) < 2) { return 1;} - - return scalar(@{$parts}) - 1; + return scalar(@{$parts}) + $delta; } # Private function: Extracts the parts information and saves it