version 1.160, 2002/11/03 19:03:29
|
version 1.165, 2003/02/10 21:22:59
|
Line 79 use Apache::lonnet();
|
Line 79 use Apache::lonnet();
|
use Apache::File(); |
use Apache::File(); |
use CGI qw(:standard); |
use CGI qw(:standard); |
use Text::Query; |
use Text::Query; |
use DBI; |
|
use GDBM_File; |
use GDBM_File; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonmysql(); |
use Apache::lonmysql(); |
Line 544 ENDHEADER
|
Line 543 ENDHEADER
|
$ENV{'form.abstract'}); |
$ENV{'form.abstract'}); |
# Hack - an empty table row. |
# Hack - an empty table row. |
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
$scrout.=&searchphrasefield('file<br />extension','mime', |
$scrout.=&searchphrasefield('file<br />extension','extension', |
$ENV{'form.mime'}); |
$ENV{'form.extension'}); |
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
$scrout.=&searchphrasefield('publisher<br />owner','owner', |
$scrout.=&searchphrasefield('publisher<br />owner','owner', |
$ENV{'form.owner'}); |
$ENV{'form.owner'}); |
$scrout.="</table>\n"; |
$scrout.="</table>\n"; |
$ENV{'form.category'}='any' unless length($ENV{'form.category'}); |
$ENV{'form.category'}='any' if (! defined($ENV{'form.category'})); |
$scrout.=&selectbox('File Category','category', |
$scrout.=&selectbox('File Category','category', |
$ENV{'form.category'}, |
$ENV{'form.category'}, |
'any','Any category', |
'any','Any category', |
Line 571 ENDHEADER
|
Line 570 ENDHEADER
|
my @domains =&Apache::loncommon::get_domains(); |
my @domains =&Apache::loncommon::get_domains(); |
# adjust the size of the select box |
# adjust the size of the select box |
my $size = 4; |
my $size = 4; |
my $size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size); |
$size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size); |
$scrout.="\n".'<font color="#800000" face="helvetica"><b>'. |
$scrout.="\n".'<font color="#800000" face="helvetica"><b>'. |
'DOMAINS</b></font><br />'. |
'DOMAINS</b></font><br />'. |
'<select name="domains" size="'.$size.'" multiple>'."\n". |
'<select name="domains" size="'.$size.'" multiple>'."\n". |
Line 694 sub get_persistent_form_data {
|
Line 693 sub get_persistent_form_data {
|
&GDBM_READER(),0640)); |
&GDBM_READER(),0640)); |
# |
# |
# These make sure we do not get array references printed out as 'values'. |
# These make sure we do not get array references printed out as 'values'. |
my %arrays_allowed = ('form.category'=>1,'form.domains'=>1); |
my %arrays_allowed = ('form.domains'=>1); |
# |
# |
# Loop through the keys, looking for 'form.' |
# Loop through the keys, looking for 'form.' |
foreach my $name (keys(%persistent_db)) { |
foreach my $name (keys(%persistent_db)) { |
Line 1136 sub parse_advanced_search {
|
Line 1135 sub parse_advanced_search {
|
'lastrevisiondatestart_month','lastrevisiondatestart_day', |
'lastrevisiondatestart_month','lastrevisiondatestart_day', |
'lastrevisiondatestart_year','lastrevisiondateend_month', |
'lastrevisiondatestart_year','lastrevisiondateend_month', |
'lastrevisiondateend_day','lastrevisiondateend_year', |
'lastrevisiondateend_day','lastrevisiondateend_year', |
'notes','abstract','mime','language','owner', |
'notes','abstract','extension','language','owner', |
'custommetadata','customshow','category') { |
'custommetadata','customshow','category') { |
$ENV{"form.$field"}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
$ENV{"form.$field"}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
} |
} |
Line 1147 sub parse_advanced_search {
|
Line 1146 sub parse_advanced_search {
|
$ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
$ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
} |
} |
# Preprocess the category form element. |
# Preprocess the category form element. |
$ENV{'form.category'} = 'any' if (ref($ENV{'form.category'})); |
$ENV{'form.category'} = 'any' if (! defined($ENV{'form.category'}) || |
if ($ENV{'form.category'} ne 'any') { |
ref($ENV{'form.category'})); |
my @extensions = &Apache::loncommon::filecategorytypes |
# |
($ENV{'form.category'}); |
|
$ENV{'form.mime'} = join ' OR ',@extensions; |
|
} |
|
# Check to see if enough information was filled in |
# Check to see if enough information was filled in |
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','category','extension','language', |
'custommetadata') { |
'owner','custommetadata') { |
if (&filled($ENV{"form.$field"})) { |
if (&filled($ENV{"form.$field"})) { |
$fillflag++; |
$fillflag++; |
} |
} |
Line 1171 sub parse_advanced_search {
|
Line 1167 sub parse_advanced_search {
|
my $font = '<font color="#800000" face="helvetica">'; |
my $font = '<font color="#800000" face="helvetica">'; |
# Evaluate logical expression AND/OR/NOT phrase fields. |
# Evaluate logical expression AND/OR/NOT phrase fields. |
foreach my $field ('title','author','subject','notes','abstract','url', |
foreach my $field ('title','author','subject','notes','abstract','url', |
'keywords','version','owner','mime') { |
'keywords','version','owner') { |
if ($ENV{'form.'.$field}) { |
if ($ENV{'form.'.$field}) { |
my $searchphrase = $ENV{'form.'.$field}; |
my $searchphrase = $ENV{'form.'.$field}; |
$pretty_search_string .= $font."$field</font> contains <b>". |
$pretty_search_string .= $font."$field</font> contains <b>". |
Line 1190 sub parse_advanced_search {
|
Line 1186 sub parse_advanced_search {
|
push @queries,&build_SQL_query($field,$searchphrase); |
push @queries,&build_SQL_query($field,$searchphrase); |
} |
} |
} |
} |
# I dislike the hack below. |
# |
if ($ENV{'form.category'}) { |
# Make the 'mime' from 'form.category' and 'form.extension' |
$ENV{'form.mime'}=''; |
# |
|
my $searchphrase; |
|
if (exists($ENV{'form.category'}) && |
|
$ENV{'form.category'} !~ /^\s*$/ && |
|
$ENV{'form.category'} ne 'any') { |
|
my @extensions = &Apache::loncommon::filecategorytypes |
|
($ENV{'form.category'}); |
|
if (scalar(@extensions) > 0) { |
|
$searchphrase = join(' OR ',@extensions); |
|
} |
|
} |
|
if (exists($ENV{'form.extension'}) && $ENV{'form.extension'} !~ /^\s*$/) { |
|
$searchphrase .= ' OR ' if (defined($searchphrase)); |
|
my @extensions = split(/,/,$ENV{'form.extension'}); |
|
$searchphrase .= join(' OR ',@extensions); |
|
} |
|
if (defined($searchphrase)) { |
|
push @queries,&build_SQL_query('mime',$searchphrase); |
|
$pretty_search_string .=$font.'mime</font> contains <b>'. |
|
$searchphrase.'</b><br />'; |
} |
} |
|
##### |
# Evaluate option lists |
# Evaluate option lists |
if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') { |
if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') { |
push @queries,"(language like \"$ENV{'form.language'}\")"; |
push @queries,"(language like \"$ENV{'form.language'}\")"; |
Line 2233 sub display_results {
|
Line 2249 sub display_results {
|
## |
## |
foreach my $row (@Results) { |
foreach my $row (@Results) { |
if ($connection->aborted()) { |
if ($connection->aborted()) { |
untie %groupsearch_db if (tied(%groupsearch_db)); |
&cleanup(); |
&Apache::lonmysql::disconnect_from_db(); |
|
return; |
return; |
} |
} |
my %Fields = %{&parse_row(@$row)}; |
my %Fields = %{&parse_row(@$row)}; |
Line 2946 sub start_fresh_session {
|
Line 2961 sub start_fresh_session {
|
|
|
1; |
1; |
|
|
|
sub cleanup { |
|
if (tied(%groupsearch_db)) { |
|
&Apache::lonnet::logthis('Cleanup searchcat: groupsearch_db'); |
|
unless (untie(%groupsearch_db)) { |
|
&Apache::lonnet::logthis('Failed cleanup searchcat: groupsearch_db'); |
|
} |
|
} |
|
&Apache::lonmysql::disconnect_from_db(); |
|
} |
|
|
__END__ |
__END__ |
|
|
=pod |
=pod |