'.&Apache::loncommon::end_page();
$r->print($scrout);
return;
}
@@ -909,20 +992,20 @@ sub viewoptions {
if (! defined($env{'form.viewselect'})) {
$env{'form.viewselect'}='detailed';
}
- $scrout .= ''
+ $scrout .= '';
+ .'';
my $countselect = &Apache::lonmeta::selectbox('show',
- $env{'form.show'},
+ $env{'form.show'},'','',
undef,
(10,20,50,100,1000,10000));
- $scrout .= ' '
+ $scrout .= ' '.$/;
+ .''.$/;
return $scrout;
}
@@ -1015,7 +1098,7 @@ This function is the reverse of &make_pe
Retrieve persistent data from %persistent_db. Retrieved items will have their
values unescaped. If the item is 'domains; then the returned
value will be a hash pointer. Otherwise, if the item contains
-commas (before unescaping), the returned value will be an array pointer.
+commas (before unescaping), the returned value will be an array pointer.
=cut
@@ -1071,7 +1154,7 @@ Store variables away to the %persistent_
Values will be escaped. Values that are array pointers will have their
elements escaped and concatenated in a comma separated string. Values
that are hash pointers will have their keys and values escaped and
-concatenated in a comma separated string
+concatenated in a comma separated string.
=cut
@@ -1219,7 +1302,7 @@ sub parse_advanced_search {
if (! $fillflag) {
&output_blank_field_error($r,$closebutton,
'phase=disp_adv',$hidden_fields);
- return ;
+ return;
}
# Turn the form input into a SQL-based query
my $query='';
@@ -1848,6 +1931,8 @@ sub build_date_queries {
my (undef,undef,undef,$cbday,$cbmon,$cbyear) = localtime($cbefore);
# Correct for year being relative to 1900
$cayear+=1900; $cbyear+=1900;
+ # Correct month; localtime gives month 0..11 but MySQL expects 1..12
+ $camon++; $cbmon++;
my $cquery=
'(creationdate BETWEEN '.
"'".$cayear.'-'.$camon.'-'.$caday."'".
@@ -1866,6 +1951,8 @@ sub build_date_queries {
my (undef,undef,undef,$mbday,$mbmon,$mbyear) = localtime($mbefore);
# Correct for year being relative to 1900
$mayear+=1900; $mbyear+=1900;
+ # Correct month; localtime gives month 0..11 but MySQL expects 1..12
+ $mamon++; $mbmon++;
my $mquery=
'(lastrevisiondate BETWEEN '.
"'".$mayear.'-'.$mamon.'-'.$maday."'".
@@ -1908,10 +1995,11 @@ sub copyright_check {
my (undef,undef,$resdom,$resname) = split('/',
$Metadata->{'url'});
# Check for priv
- if (($Metadata->{'copyright'} eq 'priv') &&
- (($env{'user.name'} ne $resname) &&
- ($env{'user.domain'} ne $resdom))) {
- return 0;
+ if ($Metadata->{'copyright'} eq 'priv') {
+ unless (($env{'user.name'} eq $resname) &&
+ ($env{'user.domain'} eq $resdom)) {
+ return 0;
+ }
}
# Check for domain
if (($Metadata->{'copyright'} eq 'domain') &&
@@ -2014,7 +2102,7 @@ a link to change the search query.
######################################################################
######################################################################
sub print_sort_form {
- my ($r,$pretty_query_string) = @_;
+ my ($r,$pretty_query_string,$target) = @_;
##
my %SortableFields=&Apache::lonlocal::texthash(
@@ -2047,29 +2135,20 @@ sub print_sort_form {
&Apache::lonnet::logthis(&Apache::lonmysql::get_error());
return;
}
- my $js =<
-// $target};
}
-// ]]>
-
-END
-
- my $start_page = &Apache::loncommon::start_page('Results',$js);
+ my $start_page = &Apache::loncommon::start_page('Results',undef,$args);
my $breadcrumbs=
&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
- $env{'form.catalogmode'} ne 'import');
-
+ $env{'form.catalogmode'} ne 'import',
+ '','','','','','',$target);
my $result = <
+
'.&Apache::loncommon::end_page());
return;
}
@@ -2225,8 +2304,21 @@ SCRIPT
$r->rflush();
}
+sub reload_result_frame {
+ my ($r) = @_;
+ my $newloc = '/adm/searchcat?phase=results&persistent_db_id='.
+ $env{'form.persistent_db_id'};
+ $r->print(<
+SCRIPT
+
+ $r->rflush();
+}
+
{
- my $max_time = 300; # seconds for the search to complete
+ my $max_time = 60; # seconds for the search to complete
my $start_time = 0;
my $last_time = 0;
@@ -2307,7 +2399,7 @@ results into MySQL.
######################################################################
sub run_search {
my ($r,$query,$customquery,$customshow,$serverlist,
- $pretty_string,$area,$domainsref) = @_;
+ $pretty_string,$area,$domainsref,$target) = @_;
my $tabletype = 'metadata';
if ($area eq 'portfolio') {
$tabletype = 'portfolio_search';
@@ -2316,13 +2408,19 @@ sub run_search {
#
# Print run_search header
#
- my $start_page = &Apache::loncommon::start_page('Search Status',undef);
+ my $args;
+ if ($target eq '_parent') {
+ $args = {'links_target' => $target};
+ }
+ my $start_page = &Apache::loncommon::start_page('Search Status',undef,$args);
my $breadcrumbs =
&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
- $env{'form.catalogmode'} ne 'import');
+ $env{'form.catalogmode'} ne 'import',
+ '','','','','','',$target);
$r->print(<
END
# Remove leading and trailing
$pretty_string =~ s:^\s* ::i;
@@ -2359,7 +2457,7 @@ END
my $major = $1;
my $minor = $2;
if (($major < 2) || (($major == 2) && ($minor < 11))) {
- map { $older_library_servers{$_} = 1; }
+ map { $older_library_servers{$_} = 1; }
&Apache::lonnet::machine_ids($library_servers{$key});
}
}
@@ -2367,9 +2465,7 @@ END
%all_library_servers = (%library_servers,%older_library_servers);
@Servers_to_contact = sort(keys(%all_library_servers));
foreach my $server (@Servers_to_contact) {
- my %possdoms;
- map { $possdoms{$_}=1; } &Apache::lonnet::machine_domains($all_library_servers{$server});
- $domains_by_server{$server} =
+ $domains_by_server{$server} =
join(',',sort(&Apache::lonnet::machine_domains($all_library_servers{$server})));
}
}
@@ -2407,6 +2503,8 @@ END
##
## Prepare for the big loop.
my $hitcountsum;
+ my $oldhitcountsum;
+ my $displaycount;
my %matches;
my $server;
my $status;
@@ -2453,7 +2551,7 @@ END
&update_status($r,
&mt('waiting on [_1]',join(' ',keys(%Server_status))));
}
- sleep(1);
+ sleep(0.1);
}
#
# Loop through the servers we have contacted but do not
@@ -2506,8 +2604,8 @@ END
if ($area eq 'portfolio') {
next if (defined($matches{$Fields{'url'}}));
- # Skip if inaccessible
- next if (!&Apache::lonnet::portfolio_access($Fields{'url'}));
+ # Skip unless access control set to public or passphrase-protected
+ next unless (($Fields{'scope'} eq 'public') || ($Fields{'scope'} eq 'guest'));
$matches{$Fields{'url'}} = 1;
}
#
@@ -2529,7 +2627,15 @@ END
delete($Server_status{$server});
}
last if ($connection->aborted());
- &update_count_status($r,$hitcountsum);
+ if ($oldhitcountsum < $hitcountsum) {
+ &update_count_status($r,$hitcountsum);
+ if (($hitcountsum <= $env{'form.show'}) ||
+ (!$displaycount && $hitcountsum)) {
+ reload_result_frame($r);
+ $displaycount = $hitcountsum;
+ }
+ $oldhitcountsum = $hitcountsum;
+ }
}
last if ($connection->aborted());
&update_seconds($r);
@@ -2542,7 +2648,7 @@ END
# We have run out of time or run out of servers to talk to and
# results to get, so let the client know the top frame needs to be
# loaded from /adm/searchcat
- $r->print(&Apache::loncommon::end_page());
+ $r->print(''.&Apache::loncommon::end_page());
# if ($env{'form.catalogmode'} ne 'import') {
$r->print(<
SCRIPT
+ $js.=<
+SCRIPT
+
my $start_page = &Apache::loncommon::start_page(undef,$js,
{'only_body' =>1,
- 'add_wishlist' =>1});
+ 'add_wishlist' =>1,
+ 'add_modal' =>1});
my $result=<