version 1.151, 2002/08/04 18:28:01
|
version 1.153.2.1, 2002/09/16 13:05:54
|
Line 171 sub handler {
|
Line 171 sub handler {
|
$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; |
|
## |
|
## Prevent caching of the search interface window. Hopefully this means |
|
## we will get the launch=1 passed in a little more. |
|
&Apache::loncommon::no_cache($r); |
## |
## |
## Pick up form fields passed in the links. |
## Pick up form fields passed in the links. |
## |
## |
Line 206 sub handler {
|
Line 210 sub handler {
|
'_'.&Apache::lonnet::escape($ENV{'user.name'}). |
'_'.&Apache::lonnet::escape($ENV{'user.name'}). |
'_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db'; |
'_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db'; |
## |
## |
if (! &get_persistent_form_data($r,$persistent_db_file)) { |
if (! &get_persistent_form_data($persistent_db_file)) { |
if ($ENV{'form.phase'} =~ /(run_search|results)/) { |
if ($ENV{'form.phase'} =~ /(run_search|results)/) { |
&Apache::lonnet::logthis("lonsearchcat:Unable to recover data ". |
&Apache::lonnet::logthis("lonsearchcat:Unable to recover data ". |
"from $persistent_db_file"); |
"from $persistent_db_file"); |
Line 226 END
|
Line 230 END
|
## Clear out old values from groupsearch database |
## Clear out old values from groupsearch database |
## |
## |
untie %groupsearch_db if (tied(%groupsearch_db)); |
untie %groupsearch_db if (tied(%groupsearch_db)); |
if ($ENV{'form.launch'} eq '1' && |
if (($ENV{'form.launch'} eq '1') && |
($ENV{'form.catalogmode'} eq 'groupsearch') && |
($ENV{'form.catalogmode'} eq 'groupsearch')) { |
($ENV{'form.phase'} eq 'results')) { |
|
if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
&start_fresh_session(); |
&start_fresh_session(); |
untie %groupsearch_db; |
untie %groupsearch_db; |
Line 360 END
|
Line 363 END
|
= &parse_advanced_search($r,$closebutton); |
= &parse_advanced_search($r,$closebutton); |
return OK if (! defined($query)); |
return OK if (! defined($query)); |
} |
} |
&make_persistent($r, |
&make_persistent({ query => $query, |
{ query => $query, |
|
customquery => $customquery, |
customquery => $customquery, |
customshow => $customshow, |
customshow => $customshow, |
libraries => $libraries, |
libraries => $libraries, |
Line 620 LASTREVISIONDATEEND
|
Line 622 LASTREVISIONDATEEND
|
(&Apache::loncommon::copyrightids), |
(&Apache::loncommon::copyrightids), |
); |
); |
# ------------------------------------------- Compute customized metadata field |
# ------------------------------------------- Compute customized metadata field |
$scrout.=<<CUSTOMMETADATA; |
# $scrout.=<<CUSTOMMETADATA; |
<p> |
#<p> |
<font color="#800000" face="helvetica"><b>LIMIT BY SPECIAL METADATA FIELDS:</b> |
#<font color="#800000" face="helvetica"><b>LIMIT BY SPECIAL METADATA FIELDS:</b> |
</font> |
#</font> |
For resource-specific metadata, enter in an expression in the form of |
#For resource-specific metadata, enter in an expression in the form of |
<i>key</i>=<i>value</i> separated by operators such as AND, OR or NOT.<br /> |
#<i>key</i>=<i>value</i> separated by operators such as AND, OR or NOT.<br /> |
<b>Example:</b> grandmother=75 OR grandfather=85 |
#<b>Example:</b> grandmother=75 OR grandfather=85 |
<br /> |
#<br /> |
CUSTOMMETADATA |
#CUSTOMMETADATA |
$scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'}); |
# $scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'}); |
$scrout.=<<CUSTOMSHOW; |
# $scrout.=<<CUSTOMSHOW; |
<p> |
#<p> |
<font color="#800000" face="helvetica"><b>SHOW SPECIAL METADATA FIELDS:</b> |
#<font color="#800000" face="helvetica"><b>SHOW SPECIAL METADATA FIELDS:</b> |
</font> |
#</font> |
Enter in a space-separated list of special metadata fields to show |
#Enter in a space-separated list of special metadata fields to show |
in a fielded listing for each record result. |
#in a fielded listing for each record result. |
<br /> |
#<br /> |
CUSTOMSHOW |
#CUSTOMSHOW |
$scrout.=&simpletextfield('customshow',$ENV{'form.customshow'}); |
# $scrout.=&simpletextfield('customshow',$ENV{'form.customshow'}); |
$scrout.=<<ENDDOCUMENT; |
$scrout.=<<ENDDOCUMENT; |
$advanced_buttons |
$advanced_buttons |
</form> |
</form> |
Line 671 to them.
|
Line 673 to them.
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub get_persistent_form_data { |
sub get_persistent_form_data { |
my $r = shift; |
|
my $filename = shift; |
my $filename = shift; |
return 0 if (! -e $filename); |
return 0 if (! -e $filename); |
return undef if (! tie(%persistent_db,'GDBM_File',$filename, |
return undef if (! tie(%persistent_db,'GDBM_File',$filename, |
Line 683 sub get_persistent_form_data {
|
Line 684 sub get_persistent_form_data {
|
# 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)) { |
next if ($name !~ /^form./); |
next if ($name !~ /^form./); |
|
next if (exists($ENV{$name})); |
my @values = map { |
my @values = map { |
&Apache::lonnet::unescape($_); |
&Apache::lonnet::unescape($_); |
} split(',',$persistent_db{$name}); |
} split(',',$persistent_db{$name}); |
next if (@values <1); |
next if (@values <1); |
if (exists($ENV{$name})) { |
if ($arrays_allowed{$name}) { |
if (ref($ENV{$name}) eq 'ARRAY') { |
$ENV{$name} = [@values]; |
# If it is an array, tack @values on the end of it. |
|
$ENV{$name} = [@$ENV{$name},@values]; |
|
} elsif (! ref($ENV{$name}) && $arrays_allowed{$name}) { |
|
# if arrays are allowed, turn it into one and add @values |
|
$ENV{$name} = [$ENV{$name},@values]; |
|
} # otherwise, assume the value in $ENV{$name} is better than ours. |
|
} else { |
} else { |
if ($arrays_allowed{$name}) { |
$ENV{$name} = $values[0] if ($values[0]); |
$ENV{$name} = [@values]; |
|
} else { |
|
$ENV{$name} = $values[0] if ($values[0]); |
|
} |
|
} |
} |
} |
} |
untie (%persistent_db); |
untie (%persistent_db); |
Line 741 sub get_persistent_data {
|
Line 733 sub get_persistent_data {
|
my @values = map { |
my @values = map { |
&Apache::lonnet::unescape($_); |
&Apache::lonnet::unescape($_); |
} split(',',$persistent_db{$name}); |
} split(',',$persistent_db{$name}); |
if (@values == 1) { |
if (@values <= 1) { |
push @Values,$values[0]; |
push @Values,$values[0]; |
} else { |
} else { |
push @Values,\@values; |
push @Values,\@values; |
Line 769 elements escaped and concatenated in a c
|
Line 761 elements escaped and concatenated in a c
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub make_persistent { |
sub make_persistent { |
my $r = shift; |
|
my %save = %{shift()}; |
my %save = %{shift()}; |
my $filename = shift; |
my $filename = shift; |
return undef if (! tie(%persistent_db,'GDBM_File', |
return undef if (! tie(%persistent_db,'GDBM_File', |
$filename,&GDBM_WRCREAT(),0640)); |
$filename,&GDBM_WRCREAT(),0640)); |
foreach my $name (keys(%save)) { |
foreach my $name (keys(%save)) { |
next if (! exists($save{$name})); |
|
next if (! defined($save{$name}) || $save{$name} eq ''); |
|
my @values = (ref($save{$name}) ? @{$save{$name}} : ($save{$name})); |
my @values = (ref($save{$name}) ? @{$save{$name}} : ($save{$name})); |
# We handle array references, but not recursively. |
# We handle array references, but not recursively. |
my $store = join(',', map { &Apache::lonnet::escape($_); } @values ); |
my $store = join(',', map { &Apache::lonnet::escape($_); } @values ); |
Line 811 sub make_form_data_persistent {
|
Line 800 sub make_form_data_persistent {
|
next if (!/^form/ || /submit/); |
next if (!/^form/ || /submit/); |
$save{$_} = $ENV{$_}; |
$save{$_} = $ENV{$_}; |
} |
} |
return &make_persistent($r,\%save,$filename); |
return &make_persistent(\%save,$filename); |
} |
} |
|
|
###################################################################### |
###################################################################### |
Line 1230 sub parse_advanced_search {
|
Line 1219 sub parse_advanced_search {
|
} |
} |
# Process form information for custom metadata querying |
# Process form information for custom metadata querying |
my $customquery=undef; |
my $customquery=undef; |
if ($ENV{'form.custommetadata'}) { |
# if ($ENV{'form.custommetadata'}) { |
$pretty_search_string .=$font."Custom Metadata Search</font>: <b>". |
# $pretty_search_string .=$font."Custom Metadata Search</font>: <b>". |
$ENV{'form.custommetadata'}."</b><br />\n"; |
# $ENV{'form.custommetadata'}."</b><br />\n"; |
$customquery=&build_custommetadata_query('custommetadata', |
# $customquery=&build_custommetadata_query('custommetadata', |
$ENV{'form.custommetadata'}); |
# $ENV{'form.custommetadata'}); |
} |
# } |
my $customshow=undef; |
my $customshow=undef; |
if ($ENV{'form.customshow'}) { |
# if ($ENV{'form.customshow'}) { |
$pretty_search_string .=$font."Custom Metadata Display</font>: <b>". |
# $pretty_search_string .=$font."Custom Metadata Display</font>: <b>". |
$ENV{'form.customshow'}."</b><br />\n"; |
# $ENV{'form.customshow'}."</b><br />\n"; |
$customshow=$ENV{'form.customshow'}; |
# $customshow=$ENV{'form.customshow'}; |
$customshow=~s/[^\w\s]//g; |
# $customshow=~s/[^\w\s]//g; |
my @fields=split(/\s+/,$customshow); |
# my @fields=split(/\s+/,$customshow); |
$customshow=join(" ",@fields); |
# $customshow=join(" ",@fields); |
} |
# } |
## --------------------------------------------------------------- |
## --------------------------------------------------------------- |
## Deal with restrictions to given domains |
## Deal with restrictions to given domains |
## |
## |
Line 1259 sub parse_advanced_search {
|
Line 1248 sub parse_advanced_search {
|
$domain_hash{$_}++; |
$domain_hash{$_}++; |
} |
} |
if ($domain_hash{'any'}) { |
if ($domain_hash{'any'}) { |
$pretty_domains_string = "Searching all domains."; |
$pretty_domains_string = "In all LON-CAPA domains."; |
} else { |
} else { |
if (@allowed_domains > 1) { |
if (@allowed_domains > 1) { |
$pretty_domains_string = "Searching domains:"; |
$pretty_domains_string = "In LON-CAPA domains:"; |
} else { |
} else { |
$pretty_domains_string = "Searching domain "; |
$pretty_domains_string = "In LON-CAPA domain "; |
} |
} |
foreach (sort @allowed_domains) { |
foreach (sort @allowed_domains) { |
$pretty_domains_string .= "<b>$_</b> "; |
$pretty_domains_string .= "<b>".$_."</b> "; |
} |
} |
foreach (keys(%Apache::lonnet::libserv)) { |
foreach (keys(%Apache::lonnet::libserv)) { |
if (exists($domain_hash{$Apache::lonnet::hostdom{$_}})) { |
if (exists($domain_hash{$Apache::lonnet::hostdom{$_}})) { |
Line 1687 sub print_sort_form {
|
Line 1676 sub print_sort_form {
|
</head> |
</head> |
<body> |
<body> |
<form name="statusform" action="" method="post"> |
<form name="statusform" action="" method="post"> |
|
<input type="hidden" name="Queue" value="" /> |
END |
END |
|
|
#<h2>Sort Results</h2> |
#<h2>Sort Results</h2> |
Line 1909 END
|
Line 1899 END
|
# Check to see if $pretty_string has more than one carriage return. |
# Check to see if $pretty_string has more than one carriage return. |
# Assume \n s are following <br /> s and truncate the value. |
# Assume \n s are following <br /> s and truncate the value. |
# (there is probably a better way)... |
# (there is probably a better way)... |
my @Lines = split /\n/,$pretty_string; |
my @Lines = split /<br \/>/,$pretty_string; |
if (@Lines > 1) { |
if (@Lines > 2) { |
$pretty_string = join /\n/,(@Lines[0..1],'....<br />'); |
$pretty_string = join '<br \>',(@Lines[0..2],'....<br />'); |
} |
} |
$r->print("Search: ".$pretty_string); |
$r->print("Search: ".$pretty_string); |
$r->rflush(); |
$r->rflush(); |
Line 1920 END
|
Line 1910 END
|
# |
# |
my @Servers_to_contact; |
my @Servers_to_contact; |
if (defined($serverlist)) { |
if (defined($serverlist)) { |
@Servers_to_contact = @$serverlist; |
if (ref($serverlist) eq 'ARRAY') { |
|
@Servers_to_contact = @$serverlist; |
|
} else { |
|
@Servers_to_contact = ($serverlist); |
|
} |
} else { |
} else { |
@Servers_to_contact = sort(keys(%Apache::lonnet::libserv)); |
@Servers_to_contact = sort(keys(%Apache::lonnet::libserv)); |
} |
} |
Line 2061 END
|
Line 2055 END
|
# We have run out of time or run out of servers to talk to and |
# We have run out of time or run out of servers to talk to and |
# results to get. |
# results to get. |
$r->print("</body></html>"); |
$r->print("</body></html>"); |
$r->print("<script>window.location='/adm/searchcat?phase=sort&persistent_db_id=$ENV{'form.persistent_db_id'}';</script>"); |
if ($ENV{'form.catalogmode'} ne 'groupsearch') { |
|
$r->print("<script>". |
|
"window.location='/adm/searchcat?". |
|
"phase=sort&". |
|
"persistent_db_id=$ENV{'form.persistent_db_id'}';". |
|
"</script>"); |
|
} |
return; |
return; |
} |
} |
|
|
Line 2494 sub search_results_header {
|
Line 2494 sub search_results_header {
|
parent.close(); |
parent.close(); |
} |
} |
function changeTitle(val) { |
function changeTitle(val) { |
if (opener.inf.document.forms.resinfo.elements.t) { |
if (parent.opener.inf.document.forms.resinfo.elements.t) { |
opener.inf.document.forms.resinfo.elements.t.value=val; |
parent.opener.inf.document.forms.resinfo.elements.t.value=val; |
} |
} |
} |
} |
function changeURL(val) { |
function changeURL(val) { |
if (opener.inf.document.forms.resinfo.elements.u) { |
if (parent.opener.inf.document.forms.resinfo.elements.u) { |
opener.inf.document.forms.resinfo.elements.u.value=val; |
parent.opener.inf.document.forms.resinfo.elements.u.value=val; |
} |
} |
} |
} |
</script> |
</script> |