--- loncom/interface/lonsearchcat.pm 2003/03/08 01:43:12 1.167 +++ loncom/interface/lonsearchcat.pm 2003/06/16 19:42:02 1.179 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.167 2003/03/08 01:43:12 www Exp $ +# $Id: lonsearchcat.pm,v 1.179 2003/06/16 19:42:02 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -142,9 +142,13 @@ my %persistent_db; my $hidden_fields; my $bodytag; +# +# For course search +# my %alreadyseen; my $hashtied; my %hash; +my $totalfound; ###################################################################### ###################################################################### @@ -210,8 +214,7 @@ sub handler { ## Initialize global variables ## my $domain = $r->dir_config('lonDefDomain'); - $diropendb= "/home/httpd/perl/tmp/".&Apache::lonnet::escape($domain). - "\_".&Apache::lonnet::escape($ENV{'user.name'})."_searchcat.db"; + $diropendb= "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db"; # # set the name of the persistent database # $ENV{'form.persistent_db_id'} can only have digits in it. @@ -418,6 +421,7 @@ sub course_search { } my $fulltext=$ENV{'form.crsfulltext'}; my @allwords=($search_string,@New_Words); + $totalfound=0; $r->print('LON-CAPA Course Search'. $bodytag.$pretty_search_string); $r->rflush(); @@ -425,13 +429,18 @@ sub course_search { $hashtied=0; undef %alreadyseen; %alreadyseen=(); + my $c=$r->connection; &tiehash(); foreach (keys %hash) { + if ($c->aborted()) { last; } if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) { - &checkonthis($r,$hash{$_},0,$hash{'title_'.$1},@allwords,$fulltext); + &checkonthis($r,$hash{$_},0,$hash{'title_'.$1},$fulltext,@allwords); } } &untiehash(); + unless ($totalfound) { + $r->print('

No resources found.

'); + } # =================================================== Done going through course $r->print(''); } @@ -456,7 +465,7 @@ sub untiehash { # =============================== This pulls up a resource and its dependencies sub checkonthis { - my ($r,$url,$level,$title,@allwords,$fulltext)=@_; + my ($r,$url,$level,$title,$fulltext,@allwords)=@_; $alreadyseen{$url}=1; $r->rflush(); my $result=&Apache::lonnet::metadata($url,'title').' '. @@ -464,7 +473,7 @@ sub checkonthis { &Apache::lonnet::metadata($url,'abstract').' '. &Apache::lonnet::metadata($url,'keywords'); if (($url) && ($fulltext)) { - $result.=&Apache::lonnet::ssibody($url); + $result.=&Apache::lonnet::ssi_body($url); } $result=~s/\s+/ /gs; my $applies=0; @@ -482,15 +491,18 @@ sub checkonthis { $r->print(' '); } $r->print(''. - ($title?$title:$url).''); - $r->rflush(); + ($title?$title:$url).'
'); + $totalfound++; + } elsif ($fulltext) { + $r->print(' .'); } + $r->rflush(); # Check also the dependencies of this one my $dependencies= &Apache::lonnet::metadata($url,'dependencies'); foreach (split(/\,/,$dependencies)) { if (($_=~/^\/res\//) && (!$alreadyseen{$_})) { - &checkonthis($r,$_,$level+1,'',@allwords,$fulltext); + &checkonthis($r,$_,$level+1,'',$fulltext,@allwords); } } } @@ -707,7 +719,7 @@ ENDHEADER my $size = 4; $size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size); $scrout.="\n".''. - 'DOMAINS
'. + 'DOMAINS TO BE SEARCHED
'. '