version 1.208, 2004/04/19 14:42:24
|
version 1.212, 2004/04/19 21:46:50
|
Line 74 use Apache::lonmeta;
|
Line 74 use Apache::lonmeta;
|
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use LONCAPA::lonmetadata(); |
use LONCAPA::lonmetadata(); |
|
use HTML::Entities(); |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 164 sub handler {
|
Line 165 sub handler {
|
'_'.&Apache::lonnet::escape($ENV{'user.name'}). |
'_'.&Apache::lonnet::escape($ENV{'user.name'}). |
'_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db'; |
'_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db'; |
## |
## |
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
if (exists($ENV{'request.course.id'}) && $ENV{'request.course.id'} ne '') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/searchcat?'. |
|
'catalogmode='.$ENV{'form.catalogmode'}. |
|
'&launch='.$ENV{'form.launch'}. |
|
'&mode='.$ENV{'form.mode'}, |
|
text=>"Course and Catalog Search", |
|
bug=>'Searching',}); |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/searchcat?'. |
|
'catalogmode='.$ENV{'form.catalogmode'}. |
|
'&launch='.$ENV{'form.launch'}. |
|
'&mode='.$ENV{'form.mode'}, |
|
text=>"Catalog Search", |
|
bug=>'Searching',}); |
|
} |
|
# |
if (! &get_persistent_form_data($persistent_db_file)) { |
if (! &get_persistent_form_data($persistent_db_file)) { |
if ($ENV{'form.phase'} =~ /(run_search|results)/) { |
if ($ENV{'form.phase'} =~ /(run_search|results)/) { |
&Apache::lonnet::logthis("lonsearchcat:Unable to recover data ". |
&Apache::lonnet::logthis("lonsearchcat:Unable to recover data ". |
Line 264 END
|
Line 284 END
|
} |
} |
$ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'})); |
$ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'})); |
$ENV{'form.show'} = 20 if (! exists($ENV{'form.show'})); |
$ENV{'form.show'} = 20 if (! exists($ENV{'form.show'})); |
|
# |
|
$ENV{'form.searchmode'} = 'basic'; |
|
if ($ENV{'form.phase'} eq 'adv_search' || |
|
$ENV{'form.phase'} eq 'disp_adv') { |
|
$ENV{'form.searchmode'} = 'advanced'; |
|
} elsif ($ENV{'form.phase'} eq 'course_search') { |
|
$ENV{'form.searchmode'} = 'course_search'; |
|
} |
|
# |
|
if ($ENV{'form.searchmode'} eq 'advanced') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/searchcat?phase=disp_adv&'. |
|
'catalogmode='.$ENV{'form.catalogmode'}. |
|
'&launch='.$ENV{'form.launch'}. |
|
'&mode='.$ENV{'form.mode'}, |
|
text=>"Advanced Search", |
|
bug=>'Searching',}); |
|
} elsif ($ENV{'form.searchmode'} eq 'course search') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/searchcat?phase=disp_adv&'. |
|
'catalogmode='.$ENV{'form.catalogmode'}. |
|
'&launch='.$ENV{'form.launch'}. |
|
'&mode='.$ENV{'form.mode'}, |
|
text=>"Course Search", |
|
bug=>'Searching',}); |
|
} |
## |
## |
## Switch on the phase |
## Switch on the phase |
## |
## |
Line 288 END
|
Line 334 END
|
&course_search($r); |
&course_search($r); |
} elsif(($ENV{'form.phase'} eq 'basic_search') || |
} elsif(($ENV{'form.phase'} eq 'basic_search') || |
($ENV{'form.phase'} eq 'adv_search')) { |
($ENV{'form.phase'} eq 'adv_search')) { |
$ENV{'form.searchmode'} = 'basic'; |
|
if ($ENV{'form.phase'} eq 'adv_search') { |
|
$ENV{'form.searchmode'} = 'advanced'; |
|
} |
|
# Set up table |
# Set up table |
if (! defined(&create_results_table())) { |
if (! defined(&create_results_table())) { |
my $errorstring=&Apache::lonmysql::get_error(); |
my $errorstring=&Apache::lonmysql::get_error(); |
|
&Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '. |
|
'needed table. lonmysql error:'. |
|
$errorstring); |
$r->print(<<END); |
$r->print(<<END); |
<html><head><title>Search Error</title></head> |
<html><head><title>Search Error</title></head> |
$bodytag |
$bodytag |
Unable to create table in which to store search results. |
Unable to create table in which to store search results. |
The search has been aborted. |
The search has been aborted. |
<br />$errorstring |
|
</body> |
</body> |
</html> |
</html> |
END |
END |
Line 487 Prints the form for the basic search. S
|
Line 531 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 $bodytag=&Apache::loncommon::bodytag('Search'). |
my $bodytag=&Apache::loncommon::bodytag('Search'). |
&Apache::loncommon::help_open_topic('Finding_Resources'). |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Finding_Resources', |
&Apache::loncommon::help_open_bug('Searching'); |
undef,undef,! $ENV{'form.launch'}); |
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'})) { |
my $CatalogSearch=&mt('Catalog Search'); |
|
my $Statement=&searchhelp(); |
my $Statement=&searchhelp(); |
$scrout.=(<<ENDDOCUMENT); |
$scrout.=(<<ENDDOCUMENT); |
<h1>$CatalogSearch</h1> |
|
<form name="loncapa_search" method="post" action="/adm/searchcat"> |
<form name="loncapa_search" method="post" action="/adm/searchcat"> |
<input type="hidden" name="phase" value="basic_search" /> |
<input type="hidden" name="phase" value="basic_search" /> |
$hidden_fields |
$hidden_fields |
Line 610 sub print_advanced_search_form{
|
Line 652 sub print_advanced_search_form{
|
$closebutton |
$closebutton |
<input type="button" value="$lt{'help'}" onClick="openhelp()" /> |
<input type="button" value="$lt{'help'}" onClick="openhelp()" /> |
END |
END |
my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'); |
my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'). |
|
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching', |
|
'Finding_Resources', |
|
undef,undef, |
|
! $ENV{'form.launch'}); |
my $searchhelp=&searchhelp(); |
my $searchhelp=&searchhelp(); |
my $scrout=&search_html_header(); |
my $scrout=&search_html_header(); |
$scrout .= <<"ENDHEADER"; |
$scrout .= <<"ENDHEADER"; |
Line 636 ENDHEADER
|
Line 682 ENDHEADER
|
'standards'=>1, |
'standards'=>1, |
'mime'=>1, |
'mime'=>1, |
); |
); |
|
# |
foreach my $field ('title','author','owner','authorspace','modifyinguser', |
foreach my $field ('title','author','owner','authorspace','modifyinguser', |
'keywords','notes','abstract','standards','mime') { |
'keywords','notes','abstract','standards','mime') { |
$scrout.='<tr><td align="right">'.&titlefield($fields{$field}).'</td><td>'. |
$scrout.='<tr><td align="right">'.&titlefield($fields{$field}).'</td><td>'. |
Line 1016 sub parse_advanced_search {
|
Line 1062 sub parse_advanced_search {
|
$fillflag++; |
$fillflag++; |
} |
} |
} |
} |
unless ($fillflag) { |
if (! $fillflag) { |
&output_blank_field_error($r,$closebutton, |
&output_blank_field_error($r,$closebutton, |
'phase=disp_adv',$hidden_fields); |
'phase=disp_adv',$hidden_fields); |
return ; |
return ; |
Line 1672 Returns: the identifier of the table on
|
Line 1718 Returns: the identifier of the table on
|
sub set_up_table_structure { |
sub set_up_table_structure { |
my ($datatypes,$fullindicies) = |
my ($datatypes,$fullindicies) = |
&LONCAPA::lonmetadata::describe_metadata_storage(); |
&LONCAPA::lonmetadata::describe_metadata_storage(); |
unshift(@$datatypes,{name => 'id', |
# Copy the table description before modifying it... |
|
@Datatypes = @{$datatypes}; |
|
unshift(@Datatypes,{name => 'id', |
type => 'MEDIUMINT', |
type => 'MEDIUMINT', |
restrictions => 'UNSIGNED NOT NULL', |
restrictions => 'UNSIGNED NOT NULL', |
primary_key => 'yes', |
primary_key => 'yes', |
auto_inc => 'yes' }); |
auto_inc => 'yes' }); |
@Datatypes = @{$datatypes}; |
|
@Fullindicies = @{$fullindicies}; |
@Fullindicies = @{$fullindicies}; |
return; |
return; |
} |
} |
Line 1875 END
|
Line 1922 END
|
END |
END |
$r->rflush(); |
$r->rflush(); |
my $time_remaining = $max_time - (time - $starttime) ; |
my $time_remaining = $max_time - (time - $starttime) ; |
|
$time_remaining = 0 if ($time_remaining <0); |
my $last_time = $time_remaining; |
my $last_time = $time_remaining; |
&update_seconds($r,$time_remaining); |
&update_seconds($r,$time_remaining); |
&update_status($r,'contacting '.$Servers_to_contact[0]); |
&update_status($r,'contacting '.$Servers_to_contact[0]); |
while (($time_remaining > 0) && |
while (($time_remaining > 0) && |
((@Servers_to_contact) || keys(%Server_status))) { |
((@Servers_to_contact) || keys(%Server_status))) { |
|
$time_remaining = $max_time - (time - $starttime) ; |
|
&update_seconds($r,$time_remaining); |
# Send out a search request if it needs to be done. |
# Send out a search request if it needs to be done. |
if (@Servers_to_contact) { |
if (@Servers_to_contact) { |
# Contact one server |
# Contact one server |
Line 1905 END
|
Line 1955 END
|
# have results from yet, looking for results. |
# have results from yet, looking for results. |
while (my ($server,$status) = each(%Server_status)) { |
while (my ($server,$status) = each(%Server_status)) { |
last if ($connection->aborted()); |
last if ($connection->aborted()); |
|
$time_remaining = $max_time - (time - $starttime) ; |
|
$time_remaining = 0 if ($time_remaining < 0); |
|
if ($last_time - $time_remaining > 0) { |
|
$last_time = $time_remaining; |
|
&update_seconds($r,$time_remaining); |
|
} |
if ($status eq 'con_lost') { |
if ($status eq 'con_lost') { |
delete ($Server_status{$server}); |
delete ($Server_status{$server}); |
next; |
next; |
Line 1947 END
|
Line 2003 END
|
# $r->print(&Apache::lonmysql::get_debug()); |
# $r->print(&Apache::lonmysql::get_debug()); |
$hitcountsum ++; |
$hitcountsum ++; |
$time_remaining = $max_time - (time - $starttime) ; |
$time_remaining = $max_time - (time - $starttime) ; |
|
$time_remaining = 0 if ($time_remaining < 0); |
if ($last_time - $time_remaining > 0) { |
if ($last_time - $time_remaining > 0) { |
&update_seconds($r,$time_remaining); |
&update_seconds($r,$time_remaining); |
$last_time = $time_remaining; |
$last_time = $time_remaining; |
Line 2142 sub display_results {
|
Line 2199 sub display_results {
|
} |
} |
my %Fields = %{&parse_row(@$row)}; |
my %Fields = %{&parse_row(@$row)}; |
my $output="<p>\n"; |
my $output="<p>\n"; |
|
if (! defined($Fields{'title'}) || $Fields{'title'} eq '') { |
|
$Fields{'title'} = 'Untitled'; |
|
} |
my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'}, |
my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'}, |
$Fields{'id'},$checkbox_num++); |
$Fields{'id'},$checkbox_num++); |
|
|
# Render the result into html |
# Render the result into html |
$output.= &$viewfunction($prefix,%Fields); |
$output.= &$viewfunction($prefix,%Fields); |
# Print them out as they come in. |
# Print them out as they come in. |
Line 2659 END
|
Line 2720 END
|
###################################################################### |
###################################################################### |
sub xml_sgml_view { |
sub xml_sgml_view { |
my ($prefix,%values) = @_; |
my ($prefix,%values) = @_; |
|
my $xml = <<END; |
|
<LonCapaResource> |
|
<url>$values{'url'}</url> |
|
<title>$values{'title'}</title> |
|
<author>$values{'author'}</author> |
|
<subject>$values{'subject'}</subject> |
|
<keywords>$values{'keywords'}</keywords> |
|
<notes>$values{'notes'}</notes> |
|
<mimeInfo> |
|
<mime>$values{'mime'}</mime> |
|
<mimetag>$values{'mimetag'}</mimetag> |
|
</mimeInfo> |
|
<languageInfo> |
|
<language>$values{'language'}</language> |
|
<languagetag>$values{'languagetag'}</languagetag> |
|
</languageInfo> |
|
<creationdate>$values{'creationdate'}</creationdate> |
|
<lastrevisiondate>$values{'lastrevisiondate'}</lastrevisiondate> |
|
<owner>$values{'owner'}</owner> |
|
<copyrightInfo> |
|
<copyright>$values{'copyright'}</copyright> |
|
<copyrighttag>$values{'copyrighttag'}</copyrighttag> |
|
</copyrightInfo> |
|
<repositoryLocation>$values{'hostname'}</repositoryLocation> |
|
<shortabstract>$values{'shortabstract'}</shortabstract> |
|
</LonCapaResource> |
|
END |
|
$xml = &HTML::Entities::encode($xml,'<>&'); |
my $result=<<END; |
my $result=<<END; |
$prefix |
$prefix |
<pre> |
<pre> |
<LonCapaResource> |
$xml |
<url>$values{'url'}</url> |
|
<title>$values{'title'}</title> |
|
<author>$values{'author'}</author> |
|
<subject>$values{'subject'}</subject> |
|
<keywords>$values{'keywords'}</keywords> |
|
<notes>$values{'notes'}</notes> |
|
<mimeInfo> |
|
<mime>$values{'mime'}</mime> |
|
<mimetag>$values{'mimetag'}</mimetag> |
|
</mimeInfo> |
|
<languageInfo> |
|
<language>$values{'language'}</language> |
|
<languagetag>$values{'languagetag'}</languagetag> |
|
</languageInfo> |
|
<creationdate>$values{'creationdate'}</creationdate> |
|
<lastrevisiondate>$values{'lastrevisiondate'}</lastrevisiondate> |
|
<owner>$values{'owner'}</owner> |
|
<copyrightInfo> |
|
<copyright>$values{'copyright'}</copyright> |
|
<copyrighttag>$values{'copyrighttag'}</copyrighttag> |
|
</copyrightInfo> |
|
<repositoryLocation>$values{'hostname'}</repositoryLocation> |
|
<shortabstract>$values{'shortabstract'}</shortabstract> |
|
</LonCapaResource> |
|
</pre> |
</pre> |
$values{'extrashow'} |
$values{'extrashow'} |
<hr align='left' width='200' noshade /> |
<hr align='left' width='200' noshade /> |