'.
@@ -1535,10 +1540,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).')';
@@ -1561,21 +1566,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 .= "".$_." ";
}
@@ -1586,8 +1587,7 @@ sub parse_domain_restrictions {
}
}
return ($libraries_to_query,
- $pretty_domains_string,
- $domain_sql_restriction);
+ $pretty_domains_string);
}
######################################################################
@@ -1616,8 +1616,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'};
@@ -1640,9 +1639,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);
#}
@@ -2286,7 +2282,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;
@@ -2520,8 +2516,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);
@@ -2723,7 +2722,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',
@@ -2774,7 +2781,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);
##
@@ -3220,9 +3227,11 @@ extra custom metadata to show.
sub detailed_citation_view {
my ($prefix,%values) = @_;
my $result;
+ my $jumpurl=$values{'url'};
+ $jumpurl=~s/^\/ext\//http\:\/\//;
$result .= ''.$prefix.
' '.' '.
- ''.$values{'title'}."\n";
$result .= "\n";
$result .= ''.$values{'author'}.','.
@@ -3291,7 +3300,7 @@ sub detailed_citation_view {
foreach my $item (split(',',$values{$field->{'name'}})){
$result .= ' '.
''.$item.'';
+ 'href="'.$jumpurl.'">'.$item.'';
}
$result .= '';
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
@@ -3302,7 +3311,7 @@ sub detailed_citation_view {
if ($field->{'special'} eq 'url link') {
$result.=
&mt($field->{'translate'},
- ''.
$values{$field->{'name'}}.
'');
@@ -3350,8 +3359,11 @@ sub summary_view {
if (! defined($tmp)) { $tmp = 'undefined'; }
$result .= ' '.$tmp.' ';
}
+ my $jumpurl=$values{'url'};
+ $jumpurl=~s/^\/ext\//http\:\/\//;
+
$result.=<$values{'title'}
$values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}
$values{'copyrighttag'}
@@ -3375,6 +3387,9 @@ END
######################################################################
sub compact_view {
my ($prefix,%values) = @_;
+ my $jumpurl=$values{'url'};
+ $jumpurl=~s/^\/ext\//http\:\/\//;
+
my $result =
$prefix.' ';
if (exists($env{'form.sortfield'}) &&
@@ -3383,9 +3398,9 @@ sub compact_view {
if (! defined($tmp)) { $tmp = 'undefined'; }
$result .= ' '.$tmp.' ';
}
- $result.=' '.
+ $result.=' '.
$values{'title'}.''.(' 'x2).
- ''.$values{'author'}.' ';
+ ''.$values{'author'}.' ('.$values{'domain'}.') ';
return $result;
}
@@ -3405,11 +3420,14 @@ sub fielded_format_view {
my ($prefix,%values) = @_;
my $icon=&Apache::loncommon::icon($values{'url'});
my %Translated = &Apache::lonmeta::fieldnames();
+ my $jumpurl=$values{'url'};
+ $jumpurl=~s/^\/ext\//http\:\/\//;
+
my $result=<
- URL:
- - $values{'url'}
END
foreach my $field ('title','author','domain','subject','keywords','notes',
@@ -3710,6 +3728,7 @@ sub cleanup {
}
&untiehash();
&Apache::lonmysql::disconnect_from_db();
+ return OK;
}
__END__
|