--- loncom/interface/lonsearchcat.pm 2001/03/15 18:43:30 1.18 +++ loncom/interface/lonsearchcat.pm 2001/03/15 19:16:42 1.22 @@ -77,7 +77,7 @@ END } if ($ENV{'form.basicsubmit'} eq 'SEARCH') { - return &basicsearch($r,$ENV{'form.basicexp'}); + return &basicsearch($r,\%ENV); } elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') { return &advancedsearch($r,\%ENV); @@ -424,22 +424,74 @@ sub advancedsearch { my ($r,$envhash)=@_; my %ENV=%{$envhash}; + return <<(END); +Advanced searching is not yet implemented. +END + } # --------------------------------------------------- Performing a basic search sub basicsearch { - my ($r,$expression)=@_; + my ($r,$envhash)=@_; + my %ENV=%{$envhash}; - my $query=$expression; - $query="select * from metadata where concat(title,\" \",author) like '\%$expression\%'"; + &output_blank_field_error($r) unless length($ENV{'form.basicexp'}); + + my $query=$ENV{'form.basicexp'}; + $query="select * from metadata where concat(title,\" \",author) like '\%$ENV{'form.basicexp'}\%'"; my $reply=&Apache::lonnet::metadata_query($query); - &output_results($reply); + &output_results($r,$envhash,$reply); return OK; } +sub output_blank_field_error { + my ($r)=@_; + # make query information persistent to allow for subsequent revision + my $persistent=''; + map { + if (/^form\./ && !/submit/) { + my $name=$_; + my $key=$name; + $name=~s/^form\.//; + $persistent.=< +END + } + } (keys %ENV); + + $r->print(< + +The LearningOnline Network with CAPA +BEGINNING + $r->print(< + + +

Search Catalog

+
+$persistent + + +
+

Helpful Message

+

+Incorrect search query due to blank entry fields. +You need to fill in the relevant +fields on the search page in order for a query to be +processed. +

+ + +RESULTS +} + # ----------------------------- format and output results based on a reply list sub output_results { - my (@replylist)=@_; + my ($r,$envhash,@replylist)=@_; + my %ENV=%{$envhash}; foreach my $reply (@replylist) { my @results; @@ -481,7 +533,7 @@ onClick="javascript:select_data('$title'
END $compiledresult.=<URL: $url +URL: $url
Title: $title
Author(s): $author
@@ -554,7 +606,7 @@ $persistent

Search Query

-Basic search: $expression +Basic search: $ENV{'form.basicexp'}

Search Results

$compiledresult