version 1.5, 2001/03/08 16:55:43
|
version 1.7, 2001/03/12 17:28:32
|
Line 7 package Apache::lonsearchcat;
|
Line 7 package Apache::lonsearchcat;
|
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
|
use Apache::lonnet(); |
|
use Apache::File(); |
|
use CGI qw(:standard); |
|
|
my %language; |
my %language; |
my $scrout; |
my $scrout; |
Line 16 my %mimetag;
|
Line 19 my %mimetag;
|
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
|
|
# -------------------------------------- see if called from an interactive mode |
|
map { |
|
my ($name, $value) = split(/=/,$_); |
|
$value =~ tr/+/ /; |
|
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
|
if ($name eq 'catalogmode') { |
|
$ENV{'form.'.$name}=$value; |
|
} |
|
} (split(/&/,$ENV{'QUERY_STRING'})); |
|
|
$r->content_type('text/html'); |
$r->content_type('text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
Line 56 sub handler {
|
Line 70 sub handler {
|
} <$fh>; |
} <$fh>; |
} |
} |
|
|
|
if ($ENV{'form.basicsubmit'} eq 'SEARCH') { |
|
return &basicsearch($r,$ENV{'form.basicexp'}); |
|
} |
|
|
$scrout=""; |
$scrout=""; |
$scrout.=&searchphrasefield('Limit by title','title', |
$scrout.=&searchphrasefield('Limit by title','title', |
''); |
''); |
Line 616 LASTREVISIONDATEEND
|
Line 634 LASTREVISIONDATEEND
|
<html> |
<html> |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
|
<script> |
|
function select_data() { |
|
changeTitle(); |
|
changeURL(); |
|
} |
|
function changeTitle() { |
|
if (opener.inf.document.forms.resinfo.elements.t) { |
|
opener.inf.document.forms.resinfo.elements.t.value="ABC"; |
|
} |
|
} |
|
function changeURL() { |
|
if (opener.inf.document.forms.resinfo.elements.u) { |
|
opener.inf.document.forms.resinfo.elements.u.value="DEF"; |
|
} |
|
} |
|
</script> |
</head> |
</head> |
<body bgcolor="#FFFFFF"> |
<body bgcolor="#FFFFFF"> |
<img align=right src=/adm/lonIcons/lonlogos.gif> |
<img align=right src=/adm/lonIcons/lonlogos.gif> |
Line 624 LASTREVISIONDATEEND
|
Line 658 LASTREVISIONDATEEND
|
<hr> |
<hr> |
<h3>Basic Search</h3> |
<h3>Basic Search</h3> |
<p> |
<p> |
|
<INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT" |
|
onClick="javascript:select_data()"> |
|
</p> |
|
<p> |
Enter terms or phrases separated by search operators |
Enter terms or phrases separated by search operators |
such as AND or OR then press SEARCH below. Terms should be specific |
such as AND or OR then press SEARCH below. Terms should be specific |
to the title, author, subject, notes, or abstract information associated |
to the title, author, subject, notes, or abstract information associated |
Line 681 sub selectbox {
|
Line 719 sub selectbox {
|
return $selout.'</select>'; |
return $selout.'</select>'; |
} |
} |
|
|
|
# --------------------------------------------------- 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=<<END; |
|
<p> |
|
<b>Title:</b> $title<br> |
|
<b>Author(s):</b> $author<br> |
|
<b>Subject:</b> $subject<br> |
|
<b>Keyword(s):</b> <i>not available yet</i><br> |
|
<b>Notes:</b> $notes<br> |
|
<b>Abstract:</b> $shortabstract<br> |
|
<b>MIME Type:</b> $mimetag{$mime}<br> |
|
<b>Language:</b> $language{$lang}<br> |
|
<b>Creation Date:</b> $creationdate<br> |
|
<b>Last Revision Date:</b> $lastrevisiondate<br> |
|
<b>Publisher/Owner:</b> $owner<br> |
|
<b>Copyright/Distribution:</b> $copyright<br> |
|
<b>Repository Location:</b> $hostname |
|
</p> |
|
END |
|
} |
|
|
|
unless ($compiledresult) { |
|
$compiledresult="There were no results that matched your query"; |
|
} |
|
|
|
# Question... allow to ask question from this page, or click to |
|
# search again? |
|
$r->print(<<RESULTS); |
|
<html> |
|
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
</head> |
|
<body bgcolor="#ffffff"> |
|
<img align=right src=/adm/lonIcons/lonlogos.gif> |
|
<h1>Search Catalog</h1> |
|
<form method="post" action="/adm/searchcat"> |
|
<hr> |
|
<h3>Search Query</h3> |
|
<p> |
|
$expression |
|
</p> |
|
<h3>Search Results</h3> |
|
$compiledresult |
|
</body> |
|
</html> |
|
RESULTS |
|
|
|
return OK; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |