Diff for /loncom/interface/lonsearchcat.pm between versions 1.167 and 1.169

version 1.167, 2003/03/08 01:43:12 version 1.169, 2003/03/10 14:20:07
Line 142  my %persistent_db; Line 142  my %persistent_db;
 my $hidden_fields;  my $hidden_fields;
 my $bodytag;  my $bodytag;
   
   #
   # For course search
   #
 my %alreadyseen;  my %alreadyseen;
 my $hashtied;  my $hashtied;
 my %hash;  my %hash;
   my $totalfound;
     
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 418  sub course_search { Line 422  sub course_search {
     }      }
     my $fulltext=$ENV{'form.crsfulltext'};      my $fulltext=$ENV{'form.crsfulltext'};
     my @allwords=($search_string,@New_Words);      my @allwords=($search_string,@New_Words);
       $totalfound=0;
     $r->print('<html><head><title>LON-CAPA Course Search</title></head>'.      $r->print('<html><head><title>LON-CAPA Course Search</title></head>'.
       $bodytag.$pretty_search_string);        $bodytag.$pretty_search_string);
     $r->rflush();      $r->rflush();
Line 425  sub course_search { Line 430  sub course_search {
    $hashtied=0;     $hashtied=0;
    undef %alreadyseen;     undef %alreadyseen;
    %alreadyseen=();     %alreadyseen=();
       my $c=$r->connection;
    &tiehash();     &tiehash();
    foreach (keys %hash) {     foreach (keys %hash) {
          if ($c->aborted()) { last; }
        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {         if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1},@allwords,$fulltext);             &checkonthis($r,$hash{$_},0,$hash{'title_'.$1},$fulltext,@allwords);
        }         }
    }     }
    &untiehash();     &untiehash();
       unless ($totalfound) {
    $r->print('<p>No resources found.</p>');
       }
 # =================================================== Done going through course  # =================================================== Done going through course
     $r->print('</body></html>');      $r->print('</body></html>');
 }  }
Line 456  sub untiehash { Line 466  sub untiehash {
 # =============================== This pulls up a resource and its dependencies  # =============================== This pulls up a resource and its dependencies
   
 sub checkonthis {  sub checkonthis {
     my ($r,$url,$level,$title,@allwords,$fulltext)=@_;      my ($r,$url,$level,$title,$fulltext,@allwords)=@_;
     $alreadyseen{$url}=1;      $alreadyseen{$url}=1;
     $r->rflush();      $r->rflush();
     my $result=&Apache::lonnet::metadata($url,'title').' '.      my $result=&Apache::lonnet::metadata($url,'title').' '.
Line 464  sub checkonthis { Line 474  sub checkonthis {
                &Apache::lonnet::metadata($url,'abstract').' '.                 &Apache::lonnet::metadata($url,'abstract').' '.
                &Apache::lonnet::metadata($url,'keywords');                 &Apache::lonnet::metadata($url,'keywords');
     if (($url) && ($fulltext)) {      if (($url) && ($fulltext)) {
  $result.=&Apache::lonnet::ssibody($url);   $result.=&Apache::lonnet::ssi_body($url);
     }      }
     $result=~s/\s+/ /gs;      $result=~s/\s+/ /gs;
     my $applies=0;      my $applies=0;
Line 482  sub checkonthis { Line 492  sub checkonthis {
            $r->print('&nbsp;');             $r->print('&nbsp;');
        }         }
        $r->print('<a href="'.$url.'" target="cat">'.         $r->print('<a href="'.$url.'" target="cat">'.
  ($title?$title:$url).'</a>');   ($title?$title:$url).'</a><br />');
        $r->rflush();         $totalfound++;
       } elsif ($fulltext) {
          $r->print(' .');
     }      }
       $r->rflush();
 # Check also the dependencies of this one  # Check also the dependencies of this one
     my $dependencies=      my $dependencies=
                 &Apache::lonnet::metadata($url,'dependencies');                  &Apache::lonnet::metadata($url,'dependencies');
     foreach (split(/\,/,$dependencies)) {      foreach (split(/\,/,$dependencies)) {
        if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {         if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
           &checkonthis($r,$_,$level+1,'',@allwords,$fulltext);            &checkonthis($r,$_,$level+1,'',$fulltext,@allwords);
        }         }
     }      }
 }  }

Removed from v.1.167  
changed lines
  Added in v.1.169


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