version 1.62, 2001/03/21 12:51:15
|
version 1.66, 2001/03/22 13:26:59
|
Line 477 sub advancedsearch {
|
Line 477 sub advancedsearch {
|
my %ENV=%{$envhash}; |
my %ENV=%{$envhash}; |
|
|
my $fillflag=0; |
my $fillflag=0; |
|
# Clean up fields for safety |
|
for my $field ('title','author','subject','keywords','url','version', |
|
'creationdatestart_month','creationdatestart_day', |
|
'creationdatestart_year','creationdateend_month', |
|
'creationdateend_day','creationdateend_year', |
|
'lastrevisiondatestart_month','lastrevisiondatestart_day', |
|
'lastrevisiondatestart_year','lastrevisiondateend_month', |
|
'lastrevisiondateend_day','lastrevisiondateend_year', |
|
'notes','abstract','mime','language','owner', |
|
'custommetadata') { |
|
$ENV{"form.$field"}=~s/[^\w\s\(\)\-\"\']//g; |
|
} |
for my $field ('title','author','subject','keywords','url','version', |
for my $field ('title','author','subject','keywords','url','version', |
'notes','abstract','mime','language','owner', |
'notes','abstract','mime','language','owner', |
'custommetadata') { |
'custommetadata') { |
Line 531 sub advancedsearch {
|
Line 543 sub advancedsearch {
|
elsif ($datequery) { |
elsif ($datequery) { |
push @queries,$datequery; |
push @queries,$datequery; |
} |
} |
|
my $customquery; |
|
if ($ENV{'form.custommetadata'}) { |
|
$customquery=&build_custommetadata_query('custommetadata', |
|
$ENV{'form.custommetadata'}); |
|
} |
if (@queries) { |
if (@queries) { |
$query=join(" AND ",@queries); |
$query=join(" AND ",@queries); |
$query="select * from metadata where $query"; |
$query="select * from metadata where $query"; |
my $reply=&Apache::lonnet::metadata_query($query); |
my $reply=&Apache::lonnet::metadata_query($query); |
&output_results('Advanced',$r,$envhash,$query,$reply); |
&output_results('Advanced',$r,$envhash,$customquery,$reply); |
} |
} |
else { |
else { |
&output_results('Advanced',$r,$envhash,$query); |
&output_results('Advanced',$r,$envhash,$query); |
Line 559 sub basicsearch {
|
Line 576 sub basicsearch {
|
my ($r,$envhash)=@_; |
my ($r,$envhash)=@_; |
my %ENV=%{$envhash}; |
my %ENV=%{$envhash}; |
|
|
|
# Clean up fields for safety |
|
for my $field ('basicexp') { |
|
$ENV{"form.$field"}=~s/[^\w\s\(\)\-]//g; |
|
} |
|
|
unless (&filled($ENV{'form.basicexp'})) { |
unless (&filled($ENV{'form.basicexp'})) { |
&output_blank_field_error($r); |
&output_blank_field_error($r); |
return OK; |
return OK; |
Line 578 sub basicsearch {
|
Line 600 sub basicsearch {
|
sub output_blank_field_error { |
sub output_blank_field_error { |
my ($r)=@_; |
my ($r)=@_; |
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
my $persistent=''; |
my $persistent=&make_persistent(); |
map { |
|
if (/^form\./ && !/submit/) { |
|
my $name=$_; |
|
my $key=$name; |
|
$name=~s/^form\.//; |
|
$persistent.=<<END; |
|
<INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'> |
|
END |
|
} |
|
} (keys %ENV); |
|
|
|
$r->print(<<BEGINNING); |
$r->print(<<BEGINNING); |
<html> |
<html> |
Line 697 END
|
Line 709 END
|
} |
} |
|
|
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
my $persistent=''; |
my $persistent=&make_persistent(); |
map { |
|
if (/^form\./ && !/submit/) { |
|
my $name=$_; |
|
my $key=$name; |
|
$name=~s/^form\.//; |
|
$persistent.=<<END; |
|
<INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'> |
|
END |
|
} |
|
} (keys %ENV); |
|
|
|
$r->print(<<BEGINNING); |
$r->print(<<BEGINNING); |
<html> |
<html> |
Line 781 sub build_SQL_query {
|
Line 783 sub build_SQL_query {
|
return $sql_query; |
return $sql_query; |
} |
} |
|
|
|
# ------------------------------------------------- build custom metadata query |
|
sub build_custommetadata_query { |
|
my ($field_name,$logic_statement)=@_; |
|
my $q=new Text::Query('abc', |
|
-parse => 'Text::Query::ParseAdvanced', |
|
-build => 'Text::Query::BuildAdvancedString'); |
|
$q->prepare($logic_statement); |
|
my $matchexp=${$q}{'-parse'}{'-build'}{'matchstring'}; |
|
return $matchexp; |
|
} |
|
|
# - Recursively parse a reverse notation expression into a SQL query expression |
# - Recursively parse a reverse notation expression into a SQL query expression |
sub recursive_SQL_query_build { |
sub recursive_SQL_query_build { |
my ($dkey,$pattern)=@_; |
my ($dkey,$pattern)=@_; |
Line 926 sub build_date_queries {
|
Line 939 sub build_date_queries {
|
"a starting month, day, and year and an ending month, ". |
"a starting month, day, and year and an ending month, ". |
"day, and year."; |
"day, and year."; |
} |
} |
my $cnumeric1="$cyear1$cmonth1$cday1"; |
my $cnumeric1=sprintf("%d%2d%2d",$cyear1,$cmonth1,$cday1); |
$cnumeric1+=0; |
$cnumeric1+=0; |
my $cnumeric2="$cyear2$cmonth2$cday2"; |
my $cnumeric2=sprintf("%d%2d%2d",$cyear2,$cmonth2,$cday2); |
$cnumeric2+=0; |
$cnumeric2+=0; |
if ($cnumeric1>$cnumeric2) { |
if ($cnumeric1>$cnumeric2) { |
return "Incorrect entry for the creation date. The starting ". |
return "Incorrect entry for the creation date. The starting ". |
Line 945 sub build_date_queries {
|
Line 958 sub build_date_queries {
|
"specify a starting month, day, and year and an ending ". |
"specify a starting month, day, and year and an ending ". |
"month, day, and year."; |
"month, day, and year."; |
} |
} |
my $lnumeric1="$lyear1$lmonth1$lday1"; |
my $lnumeric1=sprintf("%d%2d%2d",$lyear1,$lmonth1,$lday1); |
$lnumeric1+=0; |
$lnumeric1+=0; |
my $lnumeric2="$lyear2$lmonth2$lday2"; |
my $lnumeric2=sprintf("%d%2d%2d",$lyear2,$lmonth2,$lday2); |
$lnumeric2+=0; |
$lnumeric2+=0; |
if ($lnumeric1>$lnumeric2) { |
if ($lnumeric1>$lnumeric2) { |
return "Incorrect entry for the last revision date. The ". |
return "Incorrect entry for the last revision date. The ". |
Line 966 sub build_date_queries {
|
Line 979 sub build_date_queries {
|
sub output_date_error { |
sub output_date_error { |
my ($r,$message)=@_; |
my ($r,$message)=@_; |
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
my $persistent=''; |
my $persistent=&make_persistent(); |
map { |
|
if (/^form\./ && !/submit/) { |
|
my $name=$_; |
|
my $key=$name; |
|
$name=~s/^form\.//; |
|
$persistent.=<<END; |
|
<INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'> |
|
END |
|
} |
|
} (keys %ENV); |
|
|
|
$r->print(<<BEGINNING); |
$r->print(<<BEGINNING); |
<html> |
<html> |
Line 1003 $message
|
Line 1006 $message
|
RESULTS |
RESULTS |
} |
} |
|
|
|
sub make_persistent { |
|
my $persistent=''; |
|
|
|
map { |
|
if (/^form\./ && !/submit/) { |
|
my $name=$_; |
|
my $key=$name; |
|
$ENV{$key}=~s/\"/\\\"/g; |
|
$name=~s/^form\.//; |
|
$persistent.=<<END; |
|
<INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'> |
|
END |
|
} |
|
} (keys %ENV); |
|
return $persistent; |
|
} |
1; |
1; |
__END__ |
__END__ |