version 1.223, 2004/05/05 17:29:06
|
version 1.227, 2004/05/10 18:59:18
|
Line 174 sub handler {
|
Line 174 sub handler {
|
'&launch='.$ENV{'form.launch'}. |
'&launch='.$ENV{'form.launch'}. |
'&mode='.$ENV{'form.mode'}, |
'&mode='.$ENV{'form.mode'}, |
text=>"Course and Catalog Search", |
text=>"Course and Catalog Search", |
|
target=>'_top', |
bug=>'Searching',}); |
bug=>'Searching',}); |
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 182 sub handler {
|
Line 183 sub handler {
|
'&launch='.$ENV{'form.launch'}. |
'&launch='.$ENV{'form.launch'}. |
'&mode='.$ENV{'form.mode'}, |
'&mode='.$ENV{'form.mode'}, |
text=>"Catalog Search", |
text=>"Catalog Search", |
|
target=>'_top', |
bug=>'Searching',}); |
bug=>'Searching',}); |
} |
} |
# |
# |
Line 559 Prints the form for the basic search. S
|
Line 561 Prints the form for the basic search. S
|
###################################################################### |
###################################################################### |
sub print_basic_search_form { |
sub print_basic_search_form { |
my ($r,$closebutton,$hidden_fields) = @_; |
my ($r,$closebutton,$hidden_fields) = @_; |
|
my $result = ($ENV{'form.catalogmode'} ne 'groupsearch'); |
my $bodytag=&Apache::loncommon::bodytag('Search'). |
my $bodytag=&Apache::loncommon::bodytag('Search'). |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Searching', |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Searching', |
undef,undef,! $ENV{'form.launch'}); |
undef,undef, |
|
$ENV{'form.catalogmode'} ne 'groupsearch'); |
my $scrout = &search_html_header().$bodytag; |
my $scrout = &search_html_header().$bodytag; |
if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) { |
# Define interface components |
# Define interface components |
Line 689 Prints the advanced search form.
|
Line 693 Prints the advanced search form.
|
sub print_advanced_search_form{ |
sub print_advanced_search_form{ |
my ($r,$closebutton,$hidden_fields) = @_; |
my ($r,$closebutton,$hidden_fields) = @_; |
my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'). |
my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'). |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching', |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Searching', |
'Searching', |
undef,undef, |
undef,undef, |
$ENV{'form.catalogmode'} ne 'groupsearch'); |
! $ENV{'form.launch'}); |
|
|
|
my %lt=&Apache::lonlocal::texthash('srch' => 'Search', |
my %lt=&Apache::lonlocal::texthash('srch' => 'Search', |
'reset' => 'Reset', |
'reset' => 'Reset', |
'help' => 'Help'); |
'help' => 'Help'); |
Line 1188 Parse advanced search form and return th
|
Line 1190 Parse advanced search form and return th
|
sub parse_advanced_search { |
sub parse_advanced_search { |
my ($r,$closebutton,$hidden_fields)=@_; |
my ($r,$closebutton,$hidden_fields)=@_; |
my @BasicFields = ('title','author','subject','keywords','url','version', |
my @BasicFields = ('title','author','subject','keywords','url','version', |
'notes','abstract','extension','owner', |
'notes','abstract','extension','owner','authorspace', |
# 'custommetadata','customshow', |
# 'custommetadata','customshow', |
'modifyinguser','standards','mime'); |
'modifyinguser','standards','mime'); |
my @StatsFields = &statfields(); |
my @StatsFields = &statfields(); |
Line 1248 sub parse_advanced_search {
|
Line 1250 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 (@BasicFields) { |
foreach my $field (@BasicFields) { |
if ($ENV{'form.'.$field}) { |
next if (!defined($ENV{'form.'.$field}) || $ENV{'form.'.$field} eq ''); |
my $searchphrase = $ENV{'form.'.$field}; |
foreach my $searchphrase(&process_phrase_input($ENV{'form.'.$field})){ |
$pretty_search_string .= $font."$field</font> contains <b>". |
$pretty_search_string .= $font."$field</font> contains <b>". |
$searchphrase."</b>"; |
$searchphrase."</b>"; |
if ($ENV{'form.'.$field.'_related'}) { |
if ($ENV{'form.'.$field.'_related'}) { |
Line 1263 sub parse_advanced_search {
|
Line 1265 sub parse_advanced_search {
|
} |
} |
} |
} |
$pretty_search_string .= "<br />\n"; |
$pretty_search_string .= "<br />\n"; |
push @queries,&build_SQL_query($field,$searchphrase); |
push @queries,&build_SQL_query($field,$searchphrase); |
} |
} |
} |
} |
# |
# |
Line 1400 sub parse_advanced_search {
|
Line 1402 sub parse_advanced_search {
|
$pretty_search_string .= $pretty_domains_string."<br />\n"; |
$pretty_search_string .= $pretty_domains_string."<br />\n"; |
# |
# |
if (@queries) { |
if (@queries) { |
$query="select * from metadata where ".join(" AND ",@queries); |
$query="SELECT * FROM metadata WHERE ".join(" AND ",@queries); |
} elsif ($customquery) { |
} elsif ($customquery) { |
$query = ''; |
$query = ''; |
} |
} |
Line 1484 sub parse_basic_search {
|
Line 1486 sub parse_basic_search {
|
&output_blank_field_error($r,$closebutton,'phase=disp_basic'); |
&output_blank_field_error($r,$closebutton,'phase=disp_basic'); |
return OK; |
return OK; |
} |
} |
my $pretty_search_string = '<b>'.$ENV{'form.basicexp'}.'</b>'; |
my $pretty_search_string=''; |
if ($ENV{'form.related'}) { |
my @Queries; |
my @New_Words; |
my $concatarg=join(',', |
($search_string,@New_Words) = &related_version($ENV{'form.basicexp'}); |
('title', 'author', 'subject', 'notes', 'abstract', |
if (@New_Words) { |
'keywords')); |
$pretty_search_string .= " with related words: <b>@New_Words</b>."; |
foreach my $search (&process_phrase_input($search_string)){ |
|
if ($ENV{'form.related'}) { |
|
$pretty_search_string .= ' and <br />' if ($pretty_search_string ne ''); |
|
$pretty_search_string .= '<b>'.$search.'</b>'; |
|
my @New_Words; |
|
($search,@New_Words) = &related_version($search); |
|
next if (! $search); |
|
if (@New_Words) { |
|
$pretty_search_string .= |
|
" with related words: <b>@New_Words</b>"; |
|
} |
} else { |
} else { |
$pretty_search_string .= " with no related words."; |
$pretty_search_string .= ' and ' if ($pretty_search_string ne ''); |
|
$pretty_search_string .= '<b>'.$search.'</b>'; |
} |
} |
|
# |
|
# Build SQL query string based on form page |
|
push(@Queries, |
|
&build_SQL_query('concat_ws(" ",'.$concatarg.')',$search)); |
} |
} |
|
my $final_query = 'SELECT * FROM metadata WHERE '.join(" AND ",@Queries); |
# |
# |
# Build SQL query string based on form page |
|
my $query=''; |
|
my $concatarg=join(',', |
|
('title', 'author', 'subject', 'notes', 'abstract', |
|
'keywords')); |
|
$concatarg='title' if $ENV{'form.titleonly'}; |
|
$query=&build_SQL_query('concat_ws(" ",'.$concatarg.')',$search_string); |
|
if (defined($pretty_domains_string) && $pretty_domains_string ne '') { |
if (defined($pretty_domains_string) && $pretty_domains_string ne '') { |
$pretty_search_string .= ' '.$pretty_domains_string; |
$pretty_search_string .= ' '.$pretty_domains_string; |
} |
} |
$pretty_search_string .= "<br />\n"; |
$pretty_search_string .= "<br />\n"; |
my $final_query = 'SELECT * FROM metadata WHERE '.$query; |
$pretty_search_string =~ s:^<br /> and ::; |
# &Apache::lonnet::logthis($final_query); |
# &Apache::lonnet::logthis($final_query); |
return ($final_query,$pretty_search_string, |
return ($final_query,$pretty_search_string, |
$libraries_to_query); |
$libraries_to_query); |
} |
} |
|
|
|
sub process_phrase_input { |
|
my ($phrase)=@_; |
|
my @Phrases; |
|
# &Apache::lonnet::logthis('phrase = :'.$phrase.':'); |
|
my $in_quotes = 0; |
|
my @Words = split(/\s+/,$phrase); |
|
foreach my $word (@Words) { |
|
$word =~ s/(\w+)\"(\w+)/$1$2/g; |
|
if ($in_quotes) { |
|
if ($word =~ s/(\")$//) { |
|
$in_quotes = 0; |
|
} |
|
if ($Phrases[-1] ne '') { |
|
$Phrases[-1] .= ' '; |
|
} |
|
$Phrases[-1] .= $word; |
|
} else { |
|
if ($word =~ s/^(\")//) { |
|
$in_quotes=1; |
|
} |
|
push(@Phrases,$word); |
|
} |
|
} |
|
# |
|
#foreach my $p (@Phrases) { |
|
# &Apache::lonnet::logthis(' subphrase = '.$p); |
|
#} |
|
# |
|
return @Phrases; |
|
} |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
|
|
Line 1530 Note: Using this twice on a string is pr
|
Line 1572 Note: Using this twice on a string is pr
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub related_version { |
sub related_version { |
my $search_string = shift; |
my ($word) = @_; |
my $result = $search_string; |
return (undef) if (lc($word) =~ /\b(or|and|not)\b/); |
my %New_Words = (); |
my @Words = &Apache::loncommon::get_related_words($word); |
while ($search_string =~ /(\w+)/cg) { |
# Only use 4 related words |
my $word = $1; |
@Words = ($#Words>4? @Words[0..4] : @Words); |
next if (lc($word) =~ /\b(or|and|not)\b/); |
my $result = join " OR ", ($word,@Words); |
my @Words = &Apache::loncommon::get_related_words($word); |
return $result,sort(@Words); |
@Words = ($#Words>4? @Words[0..4] : @Words); |
|
foreach (@Words) { $New_Words{$_}++;} |
|
my $replacement = join " OR ", ($word,@Words); |
|
$result =~ s/(\b)$word(\b)/$1($replacement)$2/g; |
|
} |
|
return $result,sort(keys(%New_Words)); |
|
} |
} |
|
|
###################################################################### |
###################################################################### |
Line 1836 a link to change the search query.
|
Line 1872 a link to change the search query.
|
###################################################################### |
###################################################################### |
sub print_sort_form { |
sub print_sort_form { |
my ($r,$pretty_query_string) = @_; |
my ($r,$pretty_query_string) = @_; |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1). |
|
&Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Searching','Searching',undef,undef, |
|
$ENV{'form.catalogmode'} ne 'groupsearch'); |
|
|
## |
## |
my %SortableFields=&Apache::lonlocal::texthash( |
my %SortableFields=&Apache::lonlocal::texthash( |
id => 'Default', |
id => 'Default', |
Line 2102 results into MySQL.
|
Line 2142 results into MySQL.
|
sub run_search { |
sub run_search { |
my ($r,$query,$customquery,$customshow,$serverlist,$pretty_string) = @_; |
my ($r,$query,$customquery,$customshow,$serverlist,$pretty_string) = @_; |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
|
$bodytag.=&Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Searching','Searching',undef,undef, |
|
$ENV{'form.catalogmode'} ne 'groupsearch'); |
my $connection = $r->connection; |
my $connection = $r->connection; |
# |
# |
# Print run_search header |
# Print run_search header |
Line 2285 END
|
Line 2328 END
|
# results to get, so let the client know the top frame needs to be |
# results to get, so let the client know the top frame needs to be |
# loaded from /adm/searchcat |
# loaded from /adm/searchcat |
$r->print("</body></html>"); |
$r->print("</body></html>"); |
if ($ENV{'form.catalogmode'} ne 'groupsearch') { |
# if ($ENV{'form.catalogmode'} ne 'groupsearch') { |
$r->print("<script>". |
$r->print("<script>". |
"window.location='/adm/searchcat?". |
"window.location='/adm/searchcat?". |
"phase=sort&". |
"phase=sort&". |
"persistent_db_id=$ENV{'form.persistent_db_id'}';". |
"persistent_db_id=$ENV{'form.persistent_db_id'}';". |
"</script>"); |
"</script>"); |
} |
# } |
return; |
return; |
} |
} |
|
|
Line 2811 ENDFRAMES
|
Line 2854 ENDFRAMES
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
|
|
|
sub has_stat_data { |
|
my ($values) = @_; |
|
if ( (defined($values->{'count'}) && $values->{'count'} ne '') || |
|
(defined($values->{'stdno'}) && $values->{'stdno'} ne '') || |
|
(defined($values->{'disc'}) && $values->{'disc'} ne '') || |
|
(defined($values->{'avetries'}) && $values->{'avetries'} ne '') || |
|
(defined($values->{'difficulty'}) && $values->{'difficulty'} ne '')) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub statfields { |
|
return ('count','stdno','disc','avetries','difficulty'); |
|
} |
|
|
|
sub has_eval_data { |
|
my ($values) = @_; |
|
if ( (defined($values->{'clear'}) && $values->{'clear'} ne '') || |
|
(defined($values->{'technical'}) && $values->{'technical'} ne '') || |
|
(defined($values->{'correct'}) && $values->{'correct'} ne '') || |
|
(defined($values->{'helpful'}) && $values->{'helpful'} ne '') || |
|
(defined($values->{'depth'}) && $values->{'depth'} ne '')) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub evalfields { |
|
return ('clear','technical','correct','helpful','depth'); |
|
} |
|
|
|
###################################################################### |
|
###################################################################### |
|
|
=pod |
=pod |
|
|
=item Metadata Viewing Functions |
=item Metadata Viewing Functions |
Line 2858 sub detailed_citation_view {
|
Line 2936 sub detailed_citation_view {
|
{ name=>'copyrighttag', |
{ name=>'copyrighttag', |
translate => '<b>Copyright/Distribution:</b> [_1]',}, |
translate => '<b>Copyright/Distribution:</b> [_1]',}, |
{ name=>'count', |
{ name=>'count', |
|
format => "%d", |
translate => '<b>Access Count:</b> [_1]',}, |
translate => '<b>Access Count:</b> [_1]',}, |
{ name=>'stdno', |
{ name=>'stdno', |
|
format => "%d", |
translate => '<b>Number of Students:</b> [_1]',}, |
translate => '<b>Number of Students:</b> [_1]',}, |
{ name=>'avetries', |
{ name=>'avetries', |
|
format => "%.2f", |
translate => '<b>Average Tries:</b> [_1]',}, |
translate => '<b>Average Tries:</b> [_1]',}, |
{ name=>'disc', |
{ name=>'disc', |
|
format => "%.2f", |
translate => '<b>Degree of Discrimination:</b> [_1]',}, |
translate => '<b>Degree of Discrimination:</b> [_1]',}, |
{ name=>'difficulty', |
{ name=>'difficulty', |
|
format => "%.2f", |
translate => '<b>Degree of Difficulty:</b> [_1]',}, |
translate => '<b>Degree of Difficulty:</b> [_1]',}, |
{ name=>'clear', |
{ name=>'clear', |
|
format => "%.2f", |
translate => '<b>Clear:</b> [_1]',}, |
translate => '<b>Clear:</b> [_1]',}, |
{ name=>'depth', |
{ name=>'depth', |
|
format => "%.2f", |
translate => '<b>Depth:</b> [_1]',}, |
translate => '<b>Depth:</b> [_1]',}, |
{ name=>'helpful', |
{ name=>'helpful', |
|
format => "%.2f", |
translate => '<b>Helpful:</b> [_1]',}, |
translate => '<b>Helpful:</b> [_1]',}, |
{ name=>'correct', |
{ name=>'correct', |
translate => '<b>Correcy:</b> [_1]',}, |
format => "%.2f", |
|
translate => '<b>Correct:</b> [_1]',}, |
{ name=>'technical', |
{ name=>'technical', |
|
format => "%.2f", |
translate => '<b>Technical:</b> [_1]',}, |
translate => '<b>Technical:</b> [_1]',}, |
|
{ name=>'comefrom_list', |
|
type => 'list', |
|
translate => 'Resources that lead up to this resource in maps',}, |
|
{ name=>'goto_list', |
|
type => 'list', |
|
translate => 'Resources that follow this resource in maps',}, |
|
{ name=>'sequsage_list', |
|
type => 'list', |
|
translate => 'Resources using or importing resource',}, |
) { |
) { |
if (exists($values{$field->{'name'}}) && |
next if (! exists($values{$field->{'name'}}) || |
$values{$field->{'name'}} ne '') { |
$values{$field->{'name'}} eq ''); |
|
if (exists($field->{'type'}) && $field->{'type'} eq 'list') { |
|
$result .= '<b>'.&mt($field->{'translate'}).'</b><ul>'; |
|
foreach my $item (split(',',$values{$field->{'name'}})){ |
|
$result .= '<li>'. |
|
'<a target="search_preview" '. |
|
'href="/res/'.$item.'">'.$item.'</a></li>'; |
|
} |
|
$result .= '</ul>'; |
|
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){ |
|
$result.= &mt($field->{'translate'}, |
|
sprintf($field->{'format'}, |
|
$values{$field->{'name'}})).'<br />'."\n"; |
|
} else { |
if ($field->{'special'} eq 'url link') { |
if ($field->{'special'} eq 'url link') { |
$result.= |
$result.= |
&mt($field->{'translate'}, |
&mt($field->{'translate'}, |
'<a href="'.$values{'url'}.'" '. |
'<a href="'.$values{'url'}.'" '. |
'target="search_preview">'. |
'target="search_preview">'. |
$values{$field->{'name'}}. |
$values{$field->{'name'}}. |
'</a>'); |
'</a>'); |
} else { |
} else { |
$result.= &mt($field->{'translate'}, |
$result.= &mt($field->{'translate'}, |
$values{$field->{'name'}}); |
$values{$field->{'name'}}); |
} |
} |
$result .= "<br />\n"; |
$result .= "<br />\n"; |
} |
} |
} |
} |
$result .= "</p>"; |
$result .= "</p>"; |
if (exists($values{'extrashow'}) && $values{'extrashow'} ne '') { |
if (exists($values{'extrashow'}) && $values{'extrashow'} ne '') { |
Line 2906 sub detailed_citation_view {
|
Line 3016 sub detailed_citation_view {
|
} |
} |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
|
|
|
sub has_stat_data { |
|
my ($values) = @_; |
|
if ( (defined($values->{'count'}) && $values->{'count'} ne '') || |
|
(defined($values->{'stdno'}) && $values->{'stdno'} ne '') || |
|
(defined($values->{'disc'}) && $values->{'disc'} ne '') || |
|
(defined($values->{'avetries'}) && $values->{'avetries'} ne '') || |
|
(defined($values->{'difficulty'}) && $values->{'difficulty'} ne '')) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub statfields { |
|
return ('count','stdno','disc','avetries','difficulty'); |
|
} |
|
|
|
sub has_eval_data { |
|
my ($values) = @_; |
|
if ( (defined($values->{'clear'}) && $values->{'clear'} ne '') || |
|
(defined($values->{'technical'}) && $values->{'technical'} ne '') || |
|
(defined($values->{'correct'}) && $values->{'correct'} ne '') || |
|
(defined($values->{'helpful'}) && $values->{'helpful'} ne '') || |
|
(defined($values->{'depth'}) && $values->{'depth'} ne '')) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub evalfields { |
|
return ('clear','technical','correct','helpful','depth'); |
|
} |
|
|
|
###################################################################### |
|
###################################################################### |
###################################################################### |
|
|
=pod |
=pod |