version 1.182, 2003/06/17 16:01:30
|
version 1.188, 2003/09/29 15:28:40
|
Line 82 use Text::Query;
|
Line 82 use Text::Query;
|
use GDBM_File; |
use GDBM_File; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonmysql(); |
use Apache::lonmysql(); |
|
use Apache::lonlocal; |
|
|
# ---------------------------------------- variables used throughout the module |
# ---------------------------------------- variables used throughout the module |
|
|
Line 186 sub handler {
|
Line 187 sub handler {
|
# This button is different for the RAT compared to |
# This button is different for the RAT compared to |
# normal invocation. |
# normal invocation. |
# |
# |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
## |
## |
Line 440 sub course_search {
|
Line 441 sub course_search {
|
} |
} |
&untiehash(); |
&untiehash(); |
unless ($totalfound) { |
unless ($totalfound) { |
$r->print('<p>No resources found.</p>'); |
$r->print('<p>'.&mt('No resources found').'.</p>'); |
} |
} |
# =================================================== Done going through course |
# =================================================== Done going through course |
$r->print('</body></html>'); |
$r->print('</body></html>'); |
Line 557 ENDDOCUMENT
|
Line 558 ENDDOCUMENT
|
' '; |
' '; |
my $relatedcheckbox = &simplecheckbox('related',$ENV{'form.related'}); |
my $relatedcheckbox = &simplecheckbox('related',$ENV{'form.related'}); |
my $domain = $r->dir_config('lonDefDomain'); |
my $domain = $r->dir_config('lonDefDomain'); |
my $domaincheckbox = &simplecheckbox('domains',$domain,'checked'); |
my $domaincheckbox = &simplecheckbox('domains',$domain); |
|
my $srch=&mt('Search'); |
|
my $header=&mt('Advanced Search'); |
$scrout.=<<END; |
$scrout.=<<END; |
</td><td><a |
</td><td><a |
href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}" |
href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}" |
>Advanced Search</a></td></tr> |
>$header</a></td></tr> |
<tr><td>$relatedcheckbox use related words</td> |
<tr><td>$relatedcheckbox use related words</td> |
<td>$domaincheckbox only search domain <b>$domain</b></td></tr> |
<td>$domaincheckbox only search domain <b>$domain</b></td></tr> |
</table> |
</table> |
</p> |
</p> |
<p> |
<p> |
<input type="submit" name="basicsubmit" value='SEARCH' /> |
<input type="submit" name="basicsubmit" value='$srch' /> |
$closebutton |
$closebutton |
END |
END |
$scrout.=&selectbox(undef,'viewselect', |
$scrout.=&selectbox('View','viewselect', |
$ENV{'form.viewselect'}, |
$ENV{'form.viewselect'}, |
undef,undef,undef, |
undef,undef,undef, |
sort(keys(%Views))); |
sort(keys(%Views))); |
$scrout.=&selectbox(undef,'show', |
$scrout.=&selectbox('Per Page','show', |
$ENV{'form.show'}, |
$ENV{'form.show'}, |
undef,undef,undef, |
undef,undef,undef, |
(10,20,50,100)); |
(10,20,50,100)); |
$scrout.=<<ENDDOCUMENT; |
$scrout.=<<ENDDOCUMENT; |
per page. |
|
</p> |
</p> |
</form> |
</form> |
ENDDOCUMENT |
ENDDOCUMENT |
} |
} |
if ($ENV{'request.course.id'}) { |
if ($ENV{'request.course.id'}) { |
|
my %lt=&Apache::lonlocal::texthash( |
|
'srch' => 'Search', |
|
'header' => 'Course Search', |
|
'note' => 'Enter terms or phrases, then press "Search" below', |
|
); |
$scrout.=(<<ENDCOURSESEARCH); |
$scrout.=(<<ENDCOURSESEARCH); |
<hr /> |
<hr /> |
<h1>Course Search</h1> |
<h1>$lt{'header'}</h1> |
<form method="post" action="/adm/searchcat"> |
<form method="post" action="/adm/searchcat"> |
<input type="hidden" name="phase" value="course_search" /> |
<input type="hidden" name="phase" value="course_search" /> |
$hidden_fields |
$hidden_fields |
<p> |
<p> |
Enter terms or phrases, then press SEARCH below. |
$lt{'note'}. |
</p> |
</p> |
<p> |
<p> |
<table> |
<table> |
Line 609 ENDCOURSESEARCH
|
Line 616 ENDCOURSESEARCH
|
<tr><td>$relcheckbox use related words</td><td></td></tr> |
<tr><td>$relcheckbox use related words</td><td></td></tr> |
<tr><td>$crscheckbox fulltext search (time consuming)</td><td></td></tr> |
<tr><td>$crscheckbox fulltext search (time consuming)</td><td></td></tr> |
</table><p> |
</table><p> |
<input type="submit" name="coursesubmit" value='SEARCH' /> |
<input type="submit" name="coursesubmit" value='$lt{'srch'}' /> |
</p> |
</p> |
ENDENDCOURSE |
ENDENDCOURSE |
} |
} |
Line 681 ENDHEADER
|
Line 688 ENDHEADER
|
undef,undef,undef, |
undef,undef,undef, |
(10,20,50,100)); |
(10,20,50,100)); |
$scrout.=' '. |
$scrout.=' '. |
'<font color="#800000" face="helvetica">Per Page</font>'; |
'<font color="#800000" face="helvetica">'.&mt('Per Page').'</font>'; |
$scrout.="</td><td>Related<br />Words</td></tr>\n"; |
$scrout.="</td><td>".&mt('Related').'<br />'.&mt('Words')."</td></tr>\n"; |
$scrout.=&searchphrasefield_with_related('title', 'title' , |
$scrout.=&searchphrasefield_with_related('title', 'title' , |
$ENV{'form.title'}); |
$ENV{'form.title'}); |
$scrout.=&searchphrasefield('author', 'author' ,$ENV{'form.author'}); |
$scrout.=&searchphrasefield('author', 'author' ,$ENV{'form.author'}); |
Line 1057 field heading.
|
Line 1064 field heading.
|
############################################### |
############################################### |
|
|
sub fieldtitle { |
sub fieldtitle { |
my $title = uc(shift()); |
my $title = uc(&mt(shift())); |
return '<font color="#800000" face="helvetica"><b>'.$title. |
return '<font color="#800000" face="helvetica"><b>'.$title. |
': </b></font>'; |
': </b></font>'; |
} |
} |
Line 1152 END
|
Line 1159 END
|
my $i = 1; |
my $i = 1; |
foreach (qw/January February March April May June |
foreach (qw/January February March April May June |
July August September October November December /){ |
July August September October November December /){ |
$month .="<option value=\"$i\">$_</option>\n"; |
$month .="<option value=\"$i\">".&mt($_)."</option>\n"; |
$i++; |
$i++; |
} |
} |
$month.="</select>\n"; |
$month.="</select>\n"; |
Line 1229 sub selectbox {
|
Line 1236 sub selectbox {
|
my ($title,$name,$default,$anyvalue,$anytag,$functionref,@idlist)=@_; |
my ($title,$name,$default,$anyvalue,$anytag,$functionref,@idlist)=@_; |
if (! defined($functionref)) { $functionref = sub { $_[0]}; } |
if (! defined($functionref)) { $functionref = sub { $_[0]}; } |
my $selout=''; |
my $selout=''; |
|
$title=&mt($title); |
if (defined($title)) { |
if (defined($title)) { |
my $uctitle=uc($title); |
my $uctitle=uc($title); |
$selout="\n".'<p><font color="#800000" face="helvetica">'. |
$selout="\n".'<p><font color="#800000" face="helvetica">'. |
Line 1239 sub selectbox {
|
Line 1247 sub selectbox {
|
foreach (@idlist) { |
foreach (@idlist) { |
$selout.='<option value="'.$_.'"'; |
$selout.='<option value="'.$_.'"'; |
if ($_ eq $default and !/^any$/) { |
if ($_ eq $default and !/^any$/) { |
$selout.=' selected >'.&{$functionref}($_).'</option>'; |
$selout.=' selected >'.&mt(&{$functionref}($_)).'</option>'; |
} |
} |
elsif ($_ eq $default and /^$anyvalue$/) { |
elsif ($_ eq $default and /^$anyvalue$/) { |
$selout.=' selected >'.$anytag.'</option>'; |
$selout.=' selected >'.&mt($anytag).'</option>'; |
} |
} |
else {$selout.='>'.&{$functionref}($_).'</option>';} |
else {$selout.='>'.&mt(&{$functionref}($_)).'</option>';} |
} |
} |
return $selout.'</select>'.(defined($title)?'</p>':' '); |
return $selout.'</select>'.(defined($title)?'</p>':' '); |
} |
} |
Line 1536 sub parse_basic_search {
|
Line 1544 sub parse_basic_search {
|
$pretty_search_string .= ' '.$pretty_domains_string; |
$pretty_search_string .= ' '.$pretty_domains_string; |
} |
} |
$pretty_search_string .= "<br />\n"; |
$pretty_search_string .= "<br />\n"; |
return ('SELECT * FROM metadata WHERE '.$query,$pretty_search_string, |
my $final_query = 'SELECT * FROM metadata WHERE '.$query; |
|
# &Apache::lonnet::logthis($final_query); |
|
return ($final_query,$pretty_search_string, |
$libraries_to_query); |
$libraries_to_query); |
} |
} |
|
|
Line 1837 sub ensure_db_and_table {
|
Line 1847 sub ensure_db_and_table {
|
sub print_sort_form { |
sub print_sort_form { |
my ($r,$pretty_query_string) = @_; |
my ($r,$pretty_query_string) = @_; |
## |
## |
my %SortableFields = |
my %SortableFields=&Apache::lonlocal::texthash( |
(id => 'Default', |
id => 'Default', |
title => 'Title', |
title => 'Title', |
author => 'Author', |
author => 'Author', |
subject => 'Subject', |
subject => 'Subject', |
Line 1850 sub print_sort_form {
|
Line 1860 sub print_sort_form {
|
copyright => 'Copyright', |
copyright => 'Copyright', |
hostname => 'Host', |
hostname => 'Host', |
creationdate => 'Creation Date', |
creationdate => 'Creation Date', |
lastrevisiondate => 'Revision Date', |
lastrevisiondate => 'Revision Date' |
); |
); |
## |
## |
my $table = $ENV{'form.table'}; |
my $table = $ENV{'form.table'}; |
Line 2028 sub update_count_status {
|
Line 2038 sub update_count_status {
|
sub update_status { |
sub update_status { |
my ($r,$text) = @_; |
my ($r,$text) = @_; |
$text =~ s/\'/\\\'/g; |
$text =~ s/\'/\\\'/g; |
|
$text=&mt($text); |
$r->print |
$r->print |
("<script>document.statusform.status.value = ' $text'</script>\n"); |
("<script>document.statusform.status.value = ' $text'</script>\n"); |
$r->rflush(); |
$r->rflush(); |
Line 2104 END
|
Line 2115 END
|
if (@Lines > 2) { |
if (@Lines > 2) { |
$pretty_string = join '<br \>',(@Lines[0..2],'....<br />'); |
$pretty_string = join '<br \>',(@Lines[0..2],'....<br />'); |
} |
} |
$r->print("Search: ".$pretty_string); |
$r->print(&mt("Search").": ".$pretty_string); |
$r->rflush(); |
$r->rflush(); |
# |
# |
# Determine the servers we need to contact. |
# Determine the servers we need to contact. |
Line 2170 END
|
Line 2181 END
|
if (@Servers_to_contact) { |
if (@Servers_to_contact) { |
# Contact one server |
# Contact one server |
my $server = shift(@Servers_to_contact); |
my $server = shift(@Servers_to_contact); |
|
&update_status($r,'contacting '.$server); |
my $reply=&Apache::lonnet::metadata_query($query,$customquery, |
my $reply=&Apache::lonnet::metadata_query($query,$customquery, |
$customshow,[$server]); |
$customshow,[$server]); |
($server) = keys(%$reply); |
($server) = keys(%$reply); |
$Server_status{$server} = $reply->{$server}; |
$Server_status{$server} = $reply->{$server}; |
&update_status($r,'contacting '.$server); |
|
} else { |
} else { |
# wait a sec. to give time for files to be written |
# wait a sec. to give time for files to be written |
# This sleep statement is here instead of outside the else |
# This sleep statement is here instead of outside the else |
# block because we do not want to pause if we have servers |
# block because we do not want to pause if we have servers |
# left to contact. |
# left to contact. |
|
if (scalar (keys(%Server_status))) { |
|
&update_status($r, |
|
'waiting on '.(join(' ',keys(%Server_status)))); |
|
} |
sleep(1); |
sleep(1); |
} |
} |
# |
# |
if (scalar (keys(%Server_status))) { |
|
&update_status($r,'waiting on '.(join(' ',keys(%Server_status)))); |
|
} |
|
# |
# |
# Loop through the servers we have contacted but do not |
# Loop through the servers we have contacted but do not |
# have results from yet, looking for results. |
# have results from yet, looking for results. |
Line 2403 sub display_results {
|
Line 2415 sub display_results {
|
); |
); |
if ($total_results == 0) { |
if ($total_results == 0) { |
$r->print('<meta HTTP-EQUIV="Refresh" CONTENT="1">'. |
$r->print('<meta HTTP-EQUIV="Refresh" CONTENT="1">'. |
'<h3>There are currently no results.</h3>'. |
'<h3>'.&mt('There are currently no results').'.</h3>'. |
"</form></body></html>"); |
"</form></body></html>"); |
return; |
return; |
} else { |
} else { |
Line 2434 sub display_results {
|
Line 2446 sub display_results {
|
$r->rflush(); |
$r->rflush(); |
} |
} |
if (@Results < 1) { |
if (@Results < 1) { |
$r->print("There were no results matching your query"); |
$r->print(&mt("There were no results matching your query")); |
} else { |
} else { |
$r->print |
$r->print |
('<center>'. |
('<center>'. |
Line 2738 SCRIPT
|
Line 2750 SCRIPT
|
$result.=<<SCRIPT if $ENV{'form.catalogmode'} eq 'groupsearch'; |
$result.=<<SCRIPT if $ENV{'form.catalogmode'} eq 'groupsearch'; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function queue(checkbox_num,val) { |
function queue(checkbox_num,val) { |
if (document.forms.results.returnvalues[checkbox_num].checked) { |
if (document.forms.results.returnvalues.length != "undefined" && |
parent.statusframe.document.forms.statusform.elements.Queue.value +='1a'+val+'b'; |
typeof(document.forms.results.returnvalues.length) == "number") { |
|
if (document.forms.results.returnvalues[checkbox_num].checked) { |
|
parent.statusframe.document.forms.statusform.elements.Queue.value +='1a'+val+'b'; |
|
} else { |
|
parent.statusframe.document.forms.statusform.elements.Queue.value +='0a'+val+'b'; |
|
} |
} else { |
} else { |
parent.statusframe.document.forms.statusform.elements.Queue.value +='0a'+val+'b'; |
if (document.forms.results.returnvalues.checked) { |
|
parent.statusframe.document.forms.statusform.elements.Queue.value +='1a'+val+'b'; |
|
} else { |
|
parent.statusframe.document.forms.statusform.elements.Queue.value +='0a'+val+'b'; |
|
} |
} |
} |
} |
} |
function select_group() { |
function select_group() { |