--- loncom/interface/lonsearchcat.pm 2001/03/08 16:55:43 1.5
+++ loncom/interface/lonsearchcat.pm 2001/03/08 20:54:53 1.6
@@ -7,6 +7,8 @@ package Apache::lonsearchcat;
use strict;
use Apache::Constants qw(:common);
+use Apache::lonnet();
+use Apache::File();
my %language;
my $scrout;
@@ -56,6 +58,10 @@ sub handler {
} <$fh>;
}
+ if ($ENV{'form.basicsubmit'} eq 'SEARCH') {
+ return &basicsearch($r,$ENV{'form.basicexp'});
+ }
+
$scrout="";
$scrout.=&searchphrasefield('Limit by title','title',
'');
@@ -681,5 +687,92 @@ sub selectbox {
return $selout.'';
}
+# --------------------------------------------------- Performing a basic search
+sub basicsearch {
+ my ($r,$expression)=@_;
+
+ my $query=$expression;
+# $query="select * from metadata where concat(title,':\@:',author) like '\%Sci\%'";
+ $query="select * from metadata where concat(title,\" \",author) like '\%$expression\%'";
+# my $reply=&Apache::lonnet::reply("querysend:DESCRIBE metadata","msul3");
+ my $reply=&Apache::lonnet::reply("querysend:$query",'msul3');
+# my $reply=&Apache::lonnet::reply('querysend:select * from metadata','msul3');
+
+ my @results;
+
+ my $replyfile='';
+ $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting
+ $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
+ $reply=~/(.*?)\_/;
+ my $hostname=$1;
+
+ {
+ while (1) {
+ last if -e $replyfile;
+ sleep 1;
+ }
+ # QUESTION: how should I handle this error condition..
+ # I'm sure there is syntax elsewhere I can use..
+ my $fh=Apache::File->new($replyfile) or
+ ($r->print('file cannot be opened') and return OK);
+ @results=<$fh>;
+ }
+
+ my $compiledresult='';
+
+ foreach my $result (@results) {
+ my ($title,$author,$subject,$notes,$abstract,$mime,$lang,
+ $creationdate,$lastrevisiondate,$owner,$copyright
+ )=map {&Apache::lonnet::unescape($_)} (split(/\,/,$result));
+ my $shortabstract=$abstract;
+ $shortabstract=substr($abstract,0,200) if length($abstract)>200;
+ $compiledresult=<
+Author(s): $author
+Subject: $subject
+Keyword(s): not available yet
+Notes: $notes
+Abstract: $shortabstract
+MIME Type: $mimetag{$mime}
+Language: $language{$lang}
+Creation Date: $creationdate
+Last Revision Date: $lastrevisiondate
+Publisher/Owner: $owner
+Copyright/Distribution: $copyright
+Repository Location: $hostname
+