Diff for /loncom/interface/lonnavmaps.pm between versions 1.351 and 1.352

version 1.351, 2005/11/22 16:39:45 version 1.352, 2005/12/02 23:06:02
Line 2578  sub parmval_real { Line 2578  sub parmval_real {
   
 =pod  =pod
   
 =item * B<getResourceByUrl>(url):  =item * B<getResourceByUrl>(url,multiple):
   
 Retrieves a resource object by URL of the resource. If passed a  Retrieves a resource object by URL of the resource, unless the optional
 resource object, it will simply return it, so it is safe to use this  multiple parameter is included in wahich caes an array of resource 
 method in code like "$res = $navmap->getResourceByUrl($res)", if  objects is returned. If passed a resource object, it will simply return  
 you're not sure if $res is already an object, or just a URL. If the  it, so it is safe to use this method in code like
 resource appears multiple times in the course, only the first instance  "$res = $navmap->getResourceByUrl($res)"
 will be returned. As a result, this is probably useful only for maps.  if you're not sure if $res is already an object, or just a URL. If the
   resource appears multiple times in the course, only the first instance 
   will be returned (useful for maps), unless the multiple parameter has
   been included, in which case all instances are returned in an array.
   
 =item * B<retrieveResources>(map, filterFunc, recursive, bailout, showall):  =item * B<retrieveResources>(map, filterFunc, recursive, bailout, showall):
   
Line 2620  Convience method for Line 2623  Convience method for
 which will tell whether the map has resources matching the description  which will tell whether the map has resources matching the description
 in the filter function.  in the filter function.
   
   =item * B<usedVersion>(url):
   
   Retrieves version infomation for a url. Returns the version (a number, or 
   the string "mostrecent") for resources which have version information in  
   the big hash.
       
 =cut  =cut
   
   
 sub getResourceByUrl {  sub getResourceByUrl {
     my $self = shift;      my $self = shift;
     my $resUrl = shift;      my $resUrl = shift;
       my $multiple = shift;
   
     if (ref($resUrl)) { return $resUrl; }      if (ref($resUrl)) { return $resUrl; }
   
     $resUrl = &Apache::lonnet::clutter($resUrl);      $resUrl = &Apache::lonnet::clutter($resUrl);
     my $resId = $self->{NAV_HASH}->{'ids_' . $resUrl};      if (defined($multiple)) {
     if ($resId =~ /,/) {          if ($multiple) {
         $resId = (split (/,/, $resId))[0];              my @resIds = $self->{NAV_HASH}->{'ids_' . $resUrl};
           }
     }      }
       my $resId = $self->{NAV_HASH}->{'ids_' . $resUrl};
     if (!$resId) { return ''; }      if (!$resId) { return ''; }
     return $self->getById($resId);      if ($multiple) {
           my @resources = ();
           my @resIds = split (/,/, $resId);
           foreach my $id (@resIds) {
               if ($id) { 
                   push(@resources,$self->getById($id));
               }
           }
           return @resources;
       } else {
           if ($resId =~ /,/) {
               $resId = (split (/,/, $resId))[0];
           }
           return $self->getById($resId);
       }
 }  }
   
 sub retrieveResources {  sub retrieveResources {
Line 2703  sub hasResource { Line 2729  sub hasResource {
     return scalar($self->retrieveResources($map, $filterFunc, $recursive, 1, $showall)) > 0;      return scalar($self->retrieveResources($map, $filterFunc, $recursive, 1, $showall)) > 0;
 }  }
   
   sub usedVersion {
       my $self = shift;
       my $linkurl = shift;
       return $self->navhash("version_$linkurl");
   }
   
 1;  1;
   
 package Apache::lonnavmaps::iterator;  package Apache::lonnavmaps::iterator;

Removed from v.1.351  
changed lines
  Added in v.1.352


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>