--- loncom/interface/lonsearchcat.pm 2005/11/26 02:42:45 1.247
+++ loncom/interface/lonsearchcat.pm 2006/03/06 18:23:10 1.255
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.247 2005/11/26 02:42:45 www Exp $
+# $Id: lonsearchcat.pm,v 1.255 2006/03/06 18:23:10 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -77,6 +77,7 @@ use LONCAPA::lonmetadata();
use HTML::Entities();
use Parse::RecDescent;
use Apache::lonnavmaps;
+use Apache::lonindexer();
######################################################################
######################################################################
@@ -93,7 +94,9 @@ my %persistent_db; # gdbm hash which h
# The different view modes and associated functions
my %Views = ("detailed" => \&detailed_citation_view,
+ "detailedpreview" => \&detailed_citation_preview,
"summary" => \&summary_view,
+ "summarypreview" => \&summary_preview,
"fielded" => \&fielded_format_view,
"xml" => \&xml_sgml_view,
"compact" => \&compact_view);
@@ -283,12 +286,7 @@ END
## Sanity checks on form elements
##
if (!defined($env{'form.viewselect'})) {
- if (($env{'form.catalogmode'} eq 'groupsearch') ||
- ($env{'form.catalogmode'} eq 'interactive')) {
- $env{'form.viewselect'} ="Compact View";
- } else {
- $env{'form.viewselect'} ="Detailed Citation View";
- }
+ $env{'form.viewselect'} ="summary";
}
$env{'form.phase'} = 'disp_basic' if (! exists($env{'form.phase'}));
$env{'form.show'} = 20 if (! exists($env{'form.show'}));
@@ -708,6 +706,10 @@ sub print_basic_search_form {
),
$r->dir_config('lonDefDomain')
).'';
+ my $inclext= '';
my $adv_search_link =
''.
@@ -902,7 +905,10 @@ ENDHEADER
&titlefield(&mt('Domains')).'
'.
&Apache::loncommon::domain_select('domains',
$env{'form.domains'},1).
- ' | '.$/;
+ '
'.$/;
#
# Misc metadata
$scrout.=''.
@@ -1077,7 +1083,9 @@ sub viewoptiontext {
'xml' => 'XML/SGML',
'compact' => 'Compact View',
'fielded' => 'Fielded Format',
- 'summary' => 'Summary View');
+ 'summary' => 'Summary View',
+ 'summarypreview' => 'Summary Preview',
+ 'detailedpreview' => 'Detailed Citation Preview');
return $desc{$code};
}
@@ -1537,10 +1545,10 @@ sub parse_advanced_search {
##
## Deal with restrictions to given domains
##
- my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) =
- &parse_domain_restrictions();
- push(@queries,$domain_sql_restriction);
- $pretty_search_string .= $pretty_domains_string." \n";
+ my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions();
+ if ($pretty_domains_string) {
+ $pretty_search_string .= $pretty_domains_string." \n";
+ }
#
if (@queries) {
$query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')';
@@ -1563,21 +1571,17 @@ sub parse_domain_restrictions {
#
my %domain_hash = ();
my $pretty_domains_string;
- my $domain_sql_restriction;
foreach (@allowed_domains) {
$domain_hash{$_}++;
}
if ($domain_hash{'any'}) {
$pretty_domains_string = "In all LON-CAPA domains.";
- $domain_sql_restriction = undef;
} else {
if (@allowed_domains > 1) {
$pretty_domains_string = "In LON-CAPA domains:";
} else {
$pretty_domains_string = "In LON-CAPA domain ";
}
- $domain_sql_restriction =
- '(domain="'.join('" OR domain="',@allowed_domains).'")';
foreach (sort @allowed_domains) {
$pretty_domains_string .= "".$_." ";
}
@@ -1588,8 +1592,7 @@ sub parse_domain_restrictions {
}
}
return ($libraries_to_query,
- $pretty_domains_string,
- $domain_sql_restriction);
+ $pretty_domains_string);
}
######################################################################
@@ -1618,8 +1621,7 @@ sub parse_basic_search {
$env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"});
$env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
}
- my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) =
- &parse_domain_restrictions();
+ my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions();
#
# Check to see if enough of a query is filled in
my $search_string = $env{'form.basicexp'};
@@ -1642,9 +1644,6 @@ sub parse_basic_search {
return;
}
push(@Queries,$SQLQuery);
- if (defined($domain_sql_restriction) && $domain_sql_restriction ne '') {
- push(@Queries,$domain_sql_restriction);
- }
#foreach my $q (@Queries) {
# &Apache::lonnet::logthis(' '.$q);
#}
@@ -2288,7 +2287,7 @@ sub update_status {
}
{
- my $max_time = 40; # seconds for the search to complete
+ my $max_time = 300; # seconds for the search to complete
my $start_time = 0;
my $last_time = 0;
@@ -2522,8 +2521,11 @@ END
my %Fields = &parse_raw_result($result,$server);
$Fields{'hostname'} = $server;
#
+ # Skip if external and we did not want that
+ next if ((! $env{'form.inclext'}) && ($Fields{'url'}=~/^\/ext\//));
# Skip based on copyright
next if (! ©right_check(\%Fields));
+
#
# Store the result in the mysql database
my $result = &Apache::lonmysql::store_row($table,\%Fields);
@@ -2725,7 +2727,15 @@ sub display_results {
}
my %sort_fields = map {$_->{'key'},$_->{'desc'}} @fields;
$sort_fields{'select_form_order'} = \@field_order;
- $env{'form.sortorder'} = 'asc' if (! exists($env{'form.sortorder'}));
+ $env{'form.sortorder'} = 'desc' if (! exists($env{'form.sortorder'}));
+ $env{'form.sortfield'} = 'count' if (! exists($env{'form.sortfield'}));
+ if (! exists($env{'form.sortorder'})) {
+ if ($env{'form.sortfield'}=~/^(count|stdno|disc|clear|technical|correct|helpful)$/) {
+ $env{'form.sortorder'}='desc';
+ } else {
+ $env{'form.sortorder'}='asc';
+ }
+ }
my $sortform = &mt('Sort by [_1] [_2]',
&Apache::loncommon::select_form($env{'form.sortfield'},
'sortfield',
@@ -2776,7 +2786,7 @@ sub display_results {
exists($sort_fields{$env{'form.sortfield'}})) {
$sort_command = $env{'form.sortfield'}.' IS NOT NULL '.
'ORDER BY '.$env{'form.sortfield'}.' '.$order.
- ' LIMIT '.($min-1).','.($max-$min);
+ ' LIMIT '.($min-1).','.($max-$min+1);
}
my @Results = &Apache::lonmysql::get_rows($table,$sort_command);
##
@@ -3328,6 +3338,16 @@ sub detailed_citation_view {
return $result;
}
+sub detailed_citation_preview {
+ my ($prefix,%values)=@_;
+ return ''.
+ &detailed_citation_view($prefix,%values).
+ ' | '.
+ &Apache::lonindexer::showpreview($values{'url'}).
+ ' |
';
+}
+
+
######################################################################
######################################################################
@@ -3369,6 +3389,15 @@ END
return $result;
}
+sub summary_preview {
+ my ($prefix,%values)=@_;
+ return ''.
+ &summary_view($prefix,%values).
+ ' | '.
+ &Apache::lonindexer::showpreview($values{'url'}).
+ ' |
';
+}
+
######################################################################
######################################################################
@@ -3723,6 +3752,7 @@ sub cleanup {
}
&untiehash();
&Apache::lonmysql::disconnect_from_db();
+ return OK;
}
__END__
|