--- loncom/interface/lonsearchcat.pm 2003/06/17 15:53:56 1.181 +++ loncom/interface/lonsearchcat.pm 2003/09/28 00:14:25 1.187 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.181 2003/06/17 15:53:56 matthew Exp $ +# $Id: lonsearchcat.pm,v 1.187 2003/09/28 00:14:25 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -82,6 +82,7 @@ use Text::Query; use GDBM_File; use Apache::loncommon(); use Apache::lonmysql(); +use Apache::lonlocal; # ---------------------------------------- variables used throughout the module @@ -186,7 +187,7 @@ sub handler { # This button is different for the RAT compared to # normal invocation. # - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; ## @@ -440,7 +441,7 @@ sub course_search { } &untiehash(); unless ($totalfound) { - $r->print('

No resources found.

'); + $r->print('

'.&mt('No resources found').'.

'); } # =================================================== Done going through course $r->print(''); @@ -557,42 +558,48 @@ ENDDOCUMENT ' '; my $relatedcheckbox = &simplecheckbox('related',$ENV{'form.related'}); 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.=<Advanced Search +>$header $relatedcheckbox use related words $domaincheckbox only search domain $domain

  +   $closebutton END - $scrout.=&selectbox(undef,'viewselect', + $scrout.=&selectbox('View','viewselect', $ENV{'form.viewselect'}, undef,undef,undef, sort(keys(%Views))); - $scrout.=&selectbox(undef,'show', + $scrout.=&selectbox('Per page','show', $ENV{'form.show'}, undef,undef,undef, (10,20,50,100)); $scrout.=< ENDDOCUMENT } 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.=(< -

Course Search

+

$lt{'header'}

$hidden_fields

-Enter terms or phrases, then press SEARCH below. +$lt{'note'}.

@@ -609,7 +616,7 @@ ENDCOURSESEARCH
$relcheckbox use related words
$crscheckbox fulltext search (time consuming)

ENDENDCOURSE } @@ -681,8 +688,8 @@ ENDHEADER undef,undef,undef, (10,20,50,100)); $scrout.=' '. - 'Per Page'; - $scrout.="Related
Words\n"; + ''.&mt('Per Page').''; + $scrout.="".&mt('Related').'
'.&mt('Words')."\n"; $scrout.=&searchphrasefield_with_related('title', 'title' , $ENV{'form.title'}); $scrout.=&searchphrasefield('author', 'author' ,$ENV{'form.author'}); @@ -852,6 +859,13 @@ sub get_persistent_form_data { # Loop through the keys, looking for 'form.' foreach my $name (keys(%persistent_db)) { next if ($name !~ /^form./); + # Kludgification begins! + if ($name eq 'form.domains' && + $ENV{'form.searchmode'} eq 'basic' && + $ENV{'form.phase'} ne 'disp_basic') { + next; + } + # End kludge (hopefully) next if (exists($ENV{$name})); my @values = map { &Apache::lonnet::unescape($_); @@ -1050,7 +1064,7 @@ field heading. ############################################### sub fieldtitle { - my $title = uc(shift()); + my $title = uc(&mt(shift())); return ''.$title. ': '; } @@ -1145,7 +1159,7 @@ END my $i = 1; foreach (qw/January February March April May June July August September October November December /){ - $month .="\n"; + $month .="\n"; $i++; } $month.="\n"; @@ -1222,6 +1236,7 @@ sub selectbox { my ($title,$name,$default,$anyvalue,$anytag,$functionref,@idlist)=@_; if (! defined($functionref)) { $functionref = sub { $_[0]}; } my $selout=''; + $title=&mt($title); if (defined($title)) { my $uctitle=uc($title); $selout="\n".'

'. @@ -1232,12 +1247,12 @@ sub selectbox { foreach (@idlist) { $selout.=''; } elsif ($_ eq $default and /^$anyvalue$/) { - $selout.=' selected >'.$anytag.''; + $selout.=' selected >'.&mt($anytag).''; } - else {$selout.='>'.&{$functionref}($_).'';} + else {$selout.='>'.&mt(&{$functionref}($_)).'';} } return $selout.''.(defined($title)?'

':' '); } @@ -1529,7 +1544,9 @@ sub parse_basic_search { $pretty_search_string .= ' '.$pretty_domains_string; } $pretty_search_string .= "
\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); } @@ -1830,8 +1847,8 @@ sub ensure_db_and_table { sub print_sort_form { my ($r,$pretty_query_string) = @_; ## - my %SortableFields = - (id => 'Default', + my %SortableFields=&Apache::lonlocal::texthash( + id => 'Default', title => 'Title', author => 'Author', subject => 'Subject', @@ -1843,7 +1860,7 @@ sub print_sort_form { copyright => 'Copyright', hostname => 'Host', creationdate => 'Creation Date', - lastrevisiondate => 'Revision Date', + lastrevisiondate => 'Revision Date' ); ## my $table = $ENV{'form.table'}; @@ -2021,6 +2038,7 @@ sub update_count_status { sub update_status { my ($r,$text) = @_; $text =~ s/\'/\\\'/g; + $text=&mt($text); $r->print ("\n"); $r->rflush(); @@ -2097,7 +2115,7 @@ END if (@Lines > 2) { $pretty_string = join '
',(@Lines[0..2],'....
'); } - $r->print("Search: ".$pretty_string); + $r->print(&mt("Search").": ".$pretty_string); $r->rflush(); # # Determine the servers we need to contact. @@ -2163,22 +2181,23 @@ END if (@Servers_to_contact) { # Contact one server my $server = shift(@Servers_to_contact); + &update_status($r,'contacting '.$server); my $reply=&Apache::lonnet::metadata_query($query,$customquery, $customshow,[$server]); ($server) = keys(%$reply); $Server_status{$server} = $reply->{$server}; - &update_status($r,'contacting '.$server); } else { # wait a sec. to give time for files to be written # This sleep statement is here instead of outside the else # block because we do not want to pause if we have servers # left to contact. + if (scalar (keys(%Server_status))) { + &update_status($r, + 'waiting on '.(join(' ',keys(%Server_status)))); + } 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 # have results from yet, looking for results. @@ -2396,7 +2415,7 @@ sub display_results { ); if ($total_results == 0) { $r->print(''. - '

There are currently no results.

'. + '

'.&mt('There are currently no results').'.

'. ""); return; } else { @@ -2427,7 +2446,7 @@ sub display_results { $r->rflush(); } if (@Results < 1) { - $r->print("There were no results matching your query"); + $r->print(&mt("There were no results matching your query")); } else { $r->print ('
'. @@ -2731,10 +2750,19 @@ SCRIPT $result.=<