version 1.248, 2005/11/29 20:25:44
|
version 1.263, 2006/05/01 19:37:34
|
Line 77 use LONCAPA::lonmetadata();
|
Line 77 use LONCAPA::lonmetadata();
|
use HTML::Entities(); |
use HTML::Entities(); |
use Parse::RecDescent; |
use Parse::RecDescent; |
use Apache::lonnavmaps; |
use Apache::lonnavmaps; |
|
use Apache::lonindexer(); |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 93 my %persistent_db; # gdbm hash which h
|
Line 94 my %persistent_db; # gdbm hash which h
|
# The different view modes and associated functions |
# The different view modes and associated functions |
|
|
my %Views = ("detailed" => \&detailed_citation_view, |
my %Views = ("detailed" => \&detailed_citation_view, |
|
"detailedpreview" => \&detailed_citation_preview, |
"summary" => \&summary_view, |
"summary" => \&summary_view, |
|
"summarypreview" => \&summary_preview, |
"fielded" => \&fielded_format_view, |
"fielded" => \&fielded_format_view, |
"xml" => \&xml_sgml_view, |
"xml" => \&xml_sgml_view, |
"compact" => \&compact_view); |
"compact" => \&compact_view); |
Line 113 sub handler {
|
Line 116 sub handler {
|
my $diropendb; # The full path to the (temporary) search database file. |
my $diropendb; # The full path to the (temporary) search database file. |
# This is set and used in &handler() and is also used in |
# This is set and used in &handler() and is also used in |
# &output_results(). |
# &output_results(). |
my $bodytag; # LON-CAPA standard body tag, gotten from |
|
# &Apache::lonnet::bodytag. |
|
# No title, no table, just a <body> tag. |
|
|
|
my $loaderror=&Apache::lonnet::overloaderror($r); |
my $loaderror=&Apache::lonnet::overloaderror($r); |
if ($loaderror) { return $loaderror; } |
if ($loaderror) { return $loaderror; } |
Line 162 sub handler {
|
Line 162 sub handler {
|
($env{'form.launch'} eq '1')) { |
($env{'form.launch'} eq '1')) { |
$env{'form.persistent_db_id'} = time; |
$env{'form.persistent_db_id'} = time; |
} |
} |
$bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
|
my $persistent_db_file = "/home/httpd/perl/tmp/". |
my $persistent_db_file = "/home/httpd/perl/tmp/". |
&Apache::lonnet::escape($domain). |
&Apache::lonnet::escape($domain). |
'_'.&Apache::lonnet::escape($env{'user.name'}). |
'_'.&Apache::lonnet::escape($env{'user.name'}). |
Line 195 sub handler {
|
Line 195 sub handler {
|
&Apache::lonnet::logthis('lonsearchcat:'. |
&Apache::lonnet::logthis('lonsearchcat:'. |
'Unable to recover data from '. |
'Unable to recover data from '. |
$persistent_db_file); |
$persistent_db_file); |
my $html=&Apache::lonxml::xmlbegin(); |
my $msg = |
$r->print(<<END); |
'We were unable to retrieve data describing your search. '. |
$html |
'This is a serious error and has been logged. '. |
<head> |
'Please alert your LON-CAPA administrator.'; |
<title>LON-CAPA Search Error</title></head> |
&Apache::loncommon::simple_error_page($r,'Search Error', |
$bodytag |
$msg); |
We were unable to retrieve data describing your search. This is a serious |
return OK; |
error and has been logged. Please alert your LON-CAPA administrator. |
|
</body> |
|
</html> |
|
END |
|
return OK; |
|
} |
} |
} |
} |
} else { |
} else { |
Line 226 END
|
Line 221 END
|
} else { |
} else { |
# This is a stupid error to give to the user. |
# This is a stupid error to give to the user. |
# It really tells them nothing. |
# It really tells them nothing. |
my $html=&Apache::lonxml::xmlbegin(); |
my $msg = 'Unable to tie hash to db file.'; |
$r->print($html.'<head></head>'.$bodytag. |
&Apache::loncommon::simple_error_page($r,'Search Error', |
'Unable to tie hash to db file</body></html>'); |
$msg); |
return OK; |
return OK; |
} |
} |
} |
} |
Line 366 END
|
Line 361 END
|
&Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '. |
&Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '. |
'needed table. lonmysql error:'. |
'needed table. lonmysql error:'. |
$errorstring); |
$errorstring); |
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<END); |
my $msg = |
$html |
'Unable to create table in which to store search results. '. |
<head> |
'The search has been aborted.'; |
<title>Search Error</title></head> |
&Apache::loncommon::simple_error_page($r,'Search Error', |
$bodytag |
$msg); |
Unable to create table in which to store search results. |
return OK; |
The search has been aborted. |
|
</body> |
|
</html> |
|
END |
|
return OK; |
|
} |
} |
delete($env{'form.launch'}); |
delete($env{'form.launch'}); |
if (! &make_form_data_persistent($r,$persistent_db_file)) { |
if (! &make_form_data_persistent($r,$persistent_db_file)) { |
my $html=&Apache::lonxml::xmlbegin(); |
my $msg= |
$r->print(<<END); |
'Unable to properly store search information. '. |
$html |
'The search has been aborted.'; |
<head> |
&Apache::loncommon::simple_error_page($r,'Search Error', |
<title>Search Error</title></head> |
$msg); |
$bodytag |
return OK; |
Unable to properly store search information. The search has been aborted. |
} |
</body> |
|
</html> |
|
END |
|
return OK; |
|
} |
|
## |
## |
## Print out the frames interface |
## Print out the frames interface |
## |
## |
Line 464 sub make_symb {
|
Line 449 sub make_symb {
|
|
|
sub course_search { |
sub course_search { |
my $r=shift; |
my $r=shift; |
my $bodytag=&Apache::loncommon::bodytag('Course Search'); |
|
my $pretty_search_string = '<b>'.$env{'form.courseexp'}.'</b>'; |
my $pretty_search_string = '<b>'.$env{'form.courseexp'}.'</b>'; |
my $search_string = $env{'form.courseexp'}; |
my $search_string = $env{'form.courseexp'}; |
my @New_Words; |
my @New_Words; |
Line 481 sub course_search {
|
Line 465 sub course_search {
|
my $discuss=$env{'form.crsdiscuss'}; |
my $discuss=$env{'form.crsdiscuss'}; |
my @allwords=($search_string,@New_Words); |
my @allwords=($search_string,@New_Words); |
$totalfound=0; |
$totalfound=0; |
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(&Apache::loncommon::start_page('Course Search'). |
$r->print($html.'<head><title>LON-CAPA Course Search</title></head>'. |
'<hr /><center><font size="+2" face="arial">'. |
$bodytag.'<hr /><center><font size="+2" face="arial">'.$pretty_search_string.'</font></center><hr /><b>'.&mt('Course content').':</b><br />'); |
$pretty_search_string.'</font></center>'. |
|
'<hr /><b>'.&mt('Course content').':</b><br />'); |
$r->rflush(); |
$r->rflush(); |
# ======================================================= Go through the course |
# ======================================================= Go through the course |
my $c=$r->connection; |
my $c=$r->connection; |
Line 581 sub course_search {
|
Line 566 sub course_search {
|
} |
} |
|
|
# =================================================== Done going through course |
# =================================================== Done going through course |
$r->print('</body></html>'); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
# =============================== This pulls up a resource and its dependencies |
# =============================== This pulls up a resource and its dependencies |
Line 657 sub untiehash {
|
Line 642 sub untiehash {
|
|
|
} # End of course search scoping |
} # End of course search scoping |
|
|
sub search_html_header { |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
my $Str = <<ENDHEADER; |
|
$html |
|
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
</head> |
|
ENDHEADER |
|
return $Str; |
|
} |
|
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 684 Prints the form for the basic search. S
|
Line 659 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 $result = ($env{'form.catalogmode'} ne 'groupsearch'); |
my $bodytag=&Apache::loncommon::bodytag('Search'). |
my $bread_crumb = |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic', |
&Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic', |
undef,undef, |
$env{'form.catalogmode'} ne 'groupsearch'); |
$env{'form.catalogmode'} ne 'groupsearch'); |
my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb; |
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 |
my $userelatedwords= '<label>'. |
my $userelatedwords= '<label>'. |
Line 799 ENDCOURSESEARCH
|
Line 773 ENDCOURSESEARCH
|
</form> |
</form> |
ENDENDCOURSE |
ENDENDCOURSE |
} |
} |
$scrout.=(<<ENDDOCUMENT); |
$scrout .= &Apache::loncommon::end_page(); |
</body> |
|
</html> |
|
ENDDOCUMENT |
|
$r->print($scrout); |
$r->print($scrout); |
return; |
return; |
} |
} |
Line 821 Prints the advanced search form.
|
Line 792 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 $bread_crumb = |
&Apache::lonhtmlcommon::breadcrumbs(undef,'Searching', |
&Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Advanced', |
'Search_Advanced', |
$env{'form.catalogmode'} ne 'groupsearch'); |
undef,undef, |
|
$env{'form.catalogmode'} ne 'groupsearch'); |
|
my %lt=&Apache::lonlocal::texthash('srch' => 'Search', |
my %lt=&Apache::lonlocal::texthash('srch' => 'Search', |
'reset' => 'Reset', |
'reset' => 'Reset', |
'help' => 'Help'); |
'help' => 'Help'); |
Line 834 sub print_advanced_search_form{
|
Line 803 sub print_advanced_search_form{
|
<input type="reset" name="reset" value='$lt{"reset"}' /> |
<input type="reset" name="reset" value='$lt{"reset"}' /> |
$closebutton |
$closebutton |
END |
END |
my $scrout=&search_html_header(); |
my $scrout= &Apache::loncommon::start_page('Advanced Catalog Search'); |
$scrout .= <<"ENDHEADER"; |
$scrout .= <<"ENDHEADER"; |
$bodytag |
$bread_crumb |
<form method="post" action="/adm/searchcat" name="advsearch"> |
<form method="post" action="/adm/searchcat" name="advsearch"> |
<p> |
<p> |
$advanced_buttons |
$advanced_buttons |
Line 1031 ENDHEADER
|
Line 1000 ENDHEADER
|
$scrout.=<<ENDDOCUMENT; |
$scrout.=<<ENDDOCUMENT; |
$advanced_buttons |
$advanced_buttons |
</form> |
</form> |
</body> |
|
</html> |
|
ENDDOCUMENT |
ENDDOCUMENT |
|
$scrout .= &Apache::loncommon::end_page(); |
$r->print($scrout); |
$r->print($scrout); |
return; |
return; |
} |
} |
Line 1080 sub viewoptiontext {
|
Line 1048 sub viewoptiontext {
|
'xml' => 'XML/SGML', |
'xml' => 'XML/SGML', |
'compact' => 'Compact View', |
'compact' => 'Compact View', |
'fielded' => 'Fielded Format', |
'fielded' => 'Fielded Format', |
'summary' => 'Summary View'); |
'summary' => 'Summary View', |
|
'summarypreview' => 'Summary Preview', |
|
'detailedpreview' => 'Detailed Citation Preview'); |
return $desc{$code}; |
return $desc{$code}; |
} |
} |
|
|
Line 1540 sub parse_advanced_search {
|
Line 1510 sub parse_advanced_search {
|
## |
## |
## Deal with restrictions to given domains |
## Deal with restrictions to given domains |
## |
## |
my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) = |
my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions(); |
&parse_domain_restrictions(); |
if ($pretty_domains_string) { |
push(@queries,$domain_sql_restriction); |
$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).')'; |
Line 1566 sub parse_domain_restrictions {
|
Line 1536 sub parse_domain_restrictions {
|
# |
# |
my %domain_hash = (); |
my %domain_hash = (); |
my $pretty_domains_string; |
my $pretty_domains_string; |
my $domain_sql_restriction; |
|
foreach (@allowed_domains) { |
foreach (@allowed_domains) { |
$domain_hash{$_}++; |
$domain_hash{$_}++; |
} |
} |
if ($domain_hash{'any'}) { |
if ($domain_hash{'any'}) { |
$pretty_domains_string = "In all LON-CAPA domains."; |
$pretty_domains_string = "In all LON-CAPA domains."; |
$domain_sql_restriction = undef; |
|
} else { |
} else { |
if (@allowed_domains > 1) { |
if (@allowed_domains > 1) { |
$pretty_domains_string = "In LON-CAPA domains:"; |
$pretty_domains_string = "In LON-CAPA domains:"; |
} else { |
} else { |
$pretty_domains_string = "In LON-CAPA domain "; |
$pretty_domains_string = "In LON-CAPA domain "; |
} |
} |
$domain_sql_restriction = |
|
'(domain="'.join('" OR domain="',@allowed_domains).'")'; |
|
foreach (sort @allowed_domains) { |
foreach (sort @allowed_domains) { |
$pretty_domains_string .= "<b>".$_."</b> "; |
$pretty_domains_string .= "<b>".$_."</b> "; |
} |
} |
Line 1591 sub parse_domain_restrictions {
|
Line 1557 sub parse_domain_restrictions {
|
} |
} |
} |
} |
return ($libraries_to_query, |
return ($libraries_to_query, |
$pretty_domains_string, |
$pretty_domains_string); |
$domain_sql_restriction); |
|
} |
} |
|
|
###################################################################### |
###################################################################### |
Line 1621 sub parse_basic_search {
|
Line 1586 sub parse_basic_search {
|
$env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"}); |
$env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"}); |
$env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
$env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
} |
} |
my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) = |
my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions(); |
&parse_domain_restrictions(); |
|
# |
# |
# Check to see if enough of a query is filled in |
# Check to see if enough of a query is filled in |
my $search_string = $env{'form.basicexp'}; |
my $search_string = $env{'form.basicexp'}; |
Line 1645 sub parse_basic_search {
|
Line 1609 sub parse_basic_search {
|
return; |
return; |
} |
} |
push(@Queries,$SQLQuery); |
push(@Queries,$SQLQuery); |
if (defined($domain_sql_restriction) && $domain_sql_restriction ne '') { |
|
push(@Queries,$domain_sql_restriction); |
|
} |
|
#foreach my $q (@Queries) { |
#foreach my $q (@Queries) { |
# &Apache::lonnet::logthis(' '.$q); |
# &Apache::lonnet::logthis(' '.$q); |
#} |
#} |
Line 2050 sub ensure_db_and_table {
|
Line 2011 sub ensure_db_and_table {
|
if (! defined($table) || $table eq '' || $table =~ /\D/ ) { |
if (! defined($table) || $table eq '' || $table =~ /\D/ ) { |
$r->print("Unable to retrieve search results. ". |
$r->print("Unable to retrieve search results. ". |
"Unable to determine the table results were stored in. ". |
"Unable to determine the table results were stored in. ". |
"</body></html>"); |
&Apache::loncommon::end_page()); |
return undef; |
return undef; |
} |
} |
## |
## |
Line 2059 sub ensure_db_and_table {
|
Line 2020 sub ensure_db_and_table {
|
my $connection_result = &Apache::lonmysql::connect_to_db(); |
my $connection_result = &Apache::lonmysql::connect_to_db(); |
if (!defined($connection_result)) { |
if (!defined($connection_result)) { |
$r->print("Unable to connect to the MySQL database where your results". |
$r->print("Unable to connect to the MySQL database where your results". |
" are stored. </body></html>"); |
" are stored.". |
|
&Apache::loncommon::end_page()); |
&Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to". |
&Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to". |
" connect to database."); |
" connect to database."); |
&Apache::lonnet::logthis(&Apache::lonmysql::get_error()); |
&Apache::lonnet::logthis(&Apache::lonmysql::get_error()); |
Line 2067 sub ensure_db_and_table {
|
Line 2029 sub ensure_db_and_table {
|
} |
} |
my $table_check = &Apache::lonmysql::check_table($table); |
my $table_check = &Apache::lonmysql::check_table($table); |
if (! defined($table_check)) { |
if (! defined($table_check)) { |
$r->print("A MySQL error has occurred.</form></body></html>"); |
$r->print("A MySQL error has occurred.</form>". |
|
&Apache::loncommon::end_page()); |
&Apache::lonnet::logthis("lonmysql was unable to determine the status". |
&Apache::lonnet::logthis("lonmysql was unable to determine the status". |
" of table ".$table); |
" of table ".$table); |
return undef; |
return undef; |
Line 2096 a link to change the search query.
|
Line 2059 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). |
|
&Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Searching','Searching',undef,undef, |
|
$env{'form.catalogmode'} ne 'groupsearch'); |
|
|
|
## |
## |
my %SortableFields=&Apache::lonlocal::texthash( |
my %SortableFields=&Apache::lonlocal::texthash( |
Line 2125 sub print_sort_form {
|
Line 2084 sub print_sort_form {
|
## |
## |
my $total_results = &Apache::lonmysql::number_of_rows($table); |
my $total_results = &Apache::lonmysql::number_of_rows($table); |
if (! defined($total_results)) { |
if (! defined($total_results)) { |
$r->print("A MySQL error has occurred.</form></body></html>"); |
$r->print("A MySQL error has occurred.</form>". |
|
&Apache::loncommon::end_page()); |
&Apache::lonnet::logthis("lonmysql was unable to determine the number". |
&Apache::lonnet::logthis("lonmysql was unable to determine the number". |
" of rows in table ".$table); |
" of rows in table ".$table); |
&Apache::lonnet::logthis(&Apache::lonmysql::get_error()); |
&Apache::lonnet::logthis(&Apache::lonmysql::get_error()); |
return; |
return; |
} |
} |
my $result; |
my $js =<<END; |
my $html=&Apache::lonxml::xmlbegin(); |
<script type="text/javascript"> |
$result.=<<END; |
|
$html |
|
<head> |
|
<script> |
|
function change_sort() { |
function change_sort() { |
var newloc = "/adm/searchcat?phase=results"; |
var newloc = "/adm/searchcat?phase=results"; |
newloc += "&persistent_db_id=$env{'form.persistent_db_id'}"; |
newloc += "&persistent_db_id=$env{'form.persistent_db_id'}"; |
Line 2145 $html
|
Line 2101 $html
|
parent.resultsframe.location= newloc; |
parent.resultsframe.location= newloc; |
} |
} |
</script> |
</script> |
<title>Results</title> |
END |
</head> |
|
$bodytag |
my $start_page = &Apache::loncommon::start_page('Results',$js, |
<form name="statusform" action="" method="post"> |
{'only_body' => 1}); |
|
my $breadcrumbs= |
|
&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', |
|
$env{'form.catalogmode'} ne 'groupsearch'); |
|
|
|
my $result = <<END; |
|
$start_page |
|
$breadcrumbs |
|
<form name="statusform" action="" method="POST"> |
<input type="hidden" name="Queue" value="" /> |
<input type="hidden" name="Queue" value="" /> |
END |
END |
|
|
Line 2171 There are $total_results matches to your
|
Line 2135 There are $total_results matches to your
|
Search:$pretty_query_string |
Search:$pretty_query_string |
</p> |
</p> |
</form> |
</form> |
</body> |
|
</html> |
|
END |
END |
$r->print($result); |
$r->print($result.&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
|
|
Line 2291 sub update_status {
|
Line 2253 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 $start_time = 0; |
my $last_time = 0; |
my $last_time = 0; |
|
|
Line 2366 results into MySQL.
|
Line 2328 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); |
|
$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 |
# |
# |
my $html=&Apache::lonxml::xmlbegin(); |
my $start_page = &Apache::loncommon::start_page('Search Status',undef, |
|
{'only_body' => 1}); |
|
my $breadcrumbs = |
|
&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', |
|
$env{'form.catalogmode'} ne 'groupsearch'); |
$r->print(<<END); |
$r->print(<<END); |
$html |
$start_page |
<head> |
$breadcrumbs |
<title>Search Status</title></head> |
|
$bodytag |
|
<form name="statusform" action="" method="post"> |
<form name="statusform" action="" method="post"> |
<input type="hidden" name="Queue" value="" /> |
<input type="hidden" name="Queue" value="" /> |
END |
END |
Line 2414 END
|
Line 2375 END
|
my $table =$env{'form.table'}; |
my $table =$env{'form.table'}; |
if (! defined($table) || $table eq '' || $table =~ /\D/ ) { |
if (! defined($table) || $table eq '' || $table =~ /\D/ ) { |
$r->print("Unable to determine table id to store search results in.". |
$r->print("Unable to determine table id to store search results in.". |
"The search has been aborted.</body></html>"); |
"The search has been aborted.". |
|
&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
my $table_status = &Apache::lonmysql::check_table($table); |
my $table_status = &Apache::lonmysql::check_table($table); |
if (! defined($table_status)) { |
if (! defined($table_status)) { |
$r->print("Unable to determine status of table.</body></html>"); |
$r->print("Unable to determine status of table.". |
|
&Apache::loncommon::end_page()); |
&Apache::lonnet::logthis("Bogus table id of $table for ". |
&Apache::lonnet::logthis("Bogus table id of $table for ". |
"$env{'user.name'} @ $env{'user.domain'}"); |
"$env{'user.name'} @ $env{'user.domain'}"); |
&Apache::lonnet::logthis("lonmysql error = ". |
&Apache::lonnet::logthis("lonmysql error = ". |
Line 2433 END
|
Line 2396 END
|
&Apache::lonmysql::get_debug()); |
&Apache::lonmysql::get_debug()); |
&Apache::lonnet::logthis('table status = "'.$table_status.'"'); |
&Apache::lonnet::logthis('table status = "'.$table_status.'"'); |
$r->print("The table id,$table, we tried to use is invalid.". |
$r->print("The table id,$table, we tried to use is invalid.". |
"The search has been aborted.</body></html>"); |
"The search has been aborted.". |
|
&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
## |
## |
Line 2562 END
|
Line 2526 END
|
# We have run out of time or run out of servers to talk to and |
# 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 |
# 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(&Apache::loncommon::end_page()); |
# 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?". |
Line 2641 sub display_results {
|
Line 2605 sub display_results {
|
if ($env{'form.catalogmode'} eq 'groupsearch') { |
if ($env{'form.catalogmode'} eq 'groupsearch') { |
if (! tie(%groupsearch_db,'GDBM_File',$diropendb, |
if (! tie(%groupsearch_db,'GDBM_File',$diropendb, |
&GDBM_WRCREAT(),0640)) { |
&GDBM_WRCREAT(),0640)) { |
$r->print('Unable to store import results.</form></body></html>'); |
$r->print('Unable to store import results.</form>'. |
|
&Apache::loncommon::end_page()); |
$r->rflush(); |
$r->rflush(); |
return; |
return; |
} |
} |
Line 2654 sub display_results {
|
Line 2619 sub display_results {
|
## Get the number of results |
## Get the number of results |
my $total_results = &Apache::lonmysql::number_of_rows($table); |
my $total_results = &Apache::lonmysql::number_of_rows($table); |
if (! defined($total_results)) { |
if (! defined($total_results)) { |
$r->print("A MySQL error has occurred.</form></body></html>"); |
$r->print("A MySQL error has occurred.</form>". |
|
&Apache::loncommon::end_page()); |
&Apache::lonnet::logthis("lonmysql was unable to determine the number". |
&Apache::lonnet::logthis("lonmysql was unable to determine the number". |
" of rows in table ".$table); |
" of rows in table ".$table); |
&Apache::lonnet::logthis(&Apache::lonmysql::get_error()); |
&Apache::lonnet::logthis(&Apache::lonmysql::get_error()); |
Line 2761 sub display_results {
|
Line 2727 sub display_results {
|
&viewoptions().'</td></tr></table>' |
&viewoptions().'</td></tr></table>' |
); |
); |
if ($total_results == 0) { |
if ($total_results == 0) { |
$r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2">'. |
$r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2" />'. |
'<h3>'.&mt('There are currently no results').'.</h3>'. |
'<h3>'.&mt('There are currently no results').'.</h3>'. |
"</form></body></html>"); |
"</form>". |
|
&Apache::loncommon::end_page()); |
return; |
return; |
} else { |
} else { |
$r->print('<center>'. |
$r->print('<center>'. |
Line 2790 sub display_results {
|
Line 2757 sub display_results {
|
exists($sort_fields{$env{'form.sortfield'}})) { |
exists($sort_fields{$env{'form.sortfield'}})) { |
$sort_command = $env{'form.sortfield'}.' IS NOT NULL '. |
$sort_command = $env{'form.sortfield'}.' IS NOT NULL '. |
'ORDER BY '.$env{'form.sortfield'}.' '.$order. |
'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); |
my @Results = &Apache::lonmysql::get_rows($table,$sort_command); |
## |
## |
Line 2826 sub display_results {
|
Line 2793 sub display_results {
|
."</center>\n" |
."</center>\n" |
); |
); |
} |
} |
$r->print("</form></body></html>"); |
$r->print("</form>".&Apache::loncommon::end_page()); |
$r->rflush(); |
$r->rflush(); |
untie %groupsearch_db if (tied(%groupsearch_db)); |
untie %groupsearch_db if (tied(%groupsearch_db)); |
return; |
return; |
Line 3023 the name of the input field to put the t
|
Line 2990 the name of the input field to put the t
|
###################################################################### |
###################################################################### |
sub search_results_header { |
sub search_results_header { |
my ($importbutton,$closebutton) = @_; |
my ($importbutton,$closebutton) = @_; |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
|
my $result = ''; |
my $js; |
# output beginning of search page |
# output beginning of search page |
# conditional output of script functions dependent on the mode in |
# conditional output of script functions dependent on the mode in |
# which the search was invoked |
# which the search was invoked |
if ($env{'form.catalogmode'} eq 'interactive'){ |
if ($env{'form.catalogmode'} eq 'interactive'){ |
if (! exists($env{'form.mode'}) || $env{'form.mode'} ne 'edit') { |
if (! exists($env{'form.mode'}) || $env{'form.mode'} ne 'edit') { |
$result.=<<SCRIPT; |
$js.=<<SCRIPT; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function select_data(title,url) { |
function select_data(title,url) { |
changeTitle(title); |
changeTitle(title); |
Line 3069 function changeTitle(val) {
|
Line 3036 function changeTitle(val) {
|
END |
END |
} |
} |
|
|
$result.=<<SCRIPT; |
$js.=<<SCRIPT; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function select_data(title,url) { |
function select_data(title,url) { |
changeURL(url); |
changeURL(url); |
Line 3089 function changeURL(val) {
|
Line 3056 function changeURL(val) {
|
SCRIPT |
SCRIPT |
} |
} |
} |
} |
$result.=<<SCRIPT if $env{'form.catalogmode'} eq 'groupsearch'; |
$js.=<<SCRIPT if $env{'form.catalogmode'} eq 'groupsearch'; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function queue(checkbox_num,val) { |
function queue(checkbox_num,val) { |
if (document.forms.results.returnvalues.length != "undefined" && |
if (document.forms.results.returnvalues.length != "undefined" && |
Line 3114 SCRIPT
|
Line 3081 SCRIPT
|
} |
} |
</script> |
</script> |
SCRIPT |
SCRIPT |
$result.=<<END; |
|
</head> |
my $start_page = &Apache::loncommon::start_page(undef,$js, |
$bodytag |
{'only_body' =>1}); |
|
my $result=<<END; |
|
$start_page |
<form name="results" method="post" action="/adm/searchcat" > |
<form name="results" method="post" action="/adm/searchcat" > |
<input type="hidden" name="Queue" value="" /> |
<input type="hidden" name="Queue" value="" /> |
$importbutton |
$importbutton |
Line 3127 END
|
Line 3096 END
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub search_status_header { |
sub search_status_header { |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
my $start_page = &Apache::loncommon::start_page('Search Status',undef, |
my $html=&Apache::lonxml::xmlbegin(); |
{'only_body' => 1}); |
return <<ENDSTATUS; |
return <<ENDSTATUS; |
$html |
$start_page |
<head> |
|
<title>Search Status</title></head> |
|
$bodytag |
|
<h3>Search Status</h3> |
<h3>Search Status</h3> |
Sending search request to LON-CAPA servers.<br /> |
Sending search request to LON-CAPA servers.<br /> |
ENDSTATUS |
ENDSTATUS |
Line 3155 sub print_frames_interface {
|
Line 3121 sub print_frames_interface {
|
"&persistent_db_id=".$env{'form.persistent_db_id'}; |
"&persistent_db_id=".$env{'form.persistent_db_id'}; |
my $run_search_link = $basic_link."&phase=run_search"; |
my $run_search_link = $basic_link."&phase=run_search"; |
my $results_link = &results_link(); |
my $results_link = &results_link(); |
my $html=&Apache::lonxml::xmlbegin(); |
my $js = <<JS; |
my $result = <<"ENDFRAMES"; |
<script type="text/javascript"> |
$html |
|
<head> |
|
<script> |
|
var targetwin = opener; |
var targetwin = opener; |
var queue = ''; |
var queue = ''; |
</script> |
</script> |
<title>LON-CAPA Digital Library Search Results</title> |
JS |
</head> |
|
<frameset rows="150,*"> |
my $start_page = |
|
&Apache::loncommon::start_page('LON-CAPA Digital Library Search Results', |
|
$js, |
|
{'frameset' => 1, |
|
'add_entries' => { |
|
'rows' => "150,*",},}); |
|
my $end_page = |
|
&Apache::loncommon::end_page({'frameset' => 1}); |
|
|
|
my $result = <<"ENDFRAMES"; |
|
$start_page |
<frame name="statusframe" src="$run_search_link"> |
<frame name="statusframe" src="$run_search_link"> |
<frame name="resultsframe" src="$results_link"> |
<frame name="resultsframe" src="$results_link"> |
</frameset> |
$end_page |
</html> |
|
ENDFRAMES |
ENDFRAMES |
|
|
$r->print($result); |
$r->print($result); |
Line 3342 sub detailed_citation_view {
|
Line 3314 sub detailed_citation_view {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub detailed_citation_preview { |
|
my ($prefix,%values)=@_; |
|
return '<table><tr><td>'. |
|
&detailed_citation_view($prefix,%values). |
|
'</td><td>'. |
|
&Apache::lonindexer::showpreview($values{'url'}). |
|
'</td></tr></table><hr />'; |
|
} |
|
|
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
|
|
Line 3383 END
|
Line 3365 END
|
return $result; |
return $result; |
} |
} |
|
|
|
sub summary_preview { |
|
my ($prefix,%values)=@_; |
|
return '<table><tr><td>'. |
|
&summary_view($prefix,%values). |
|
'</td><td>'. |
|
&Apache::lonindexer::showpreview($values{'url'}). |
|
'</td></tr></table><hr />'; |
|
} |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
|
|
Line 3577 sub output_unparsed_phrase_error {
|
Line 3568 sub output_unparsed_phrase_error {
|
} else { |
} else { |
$errorstring = &mt('Unable to understand the search phrase <b>[_1]</b>:<i>[_2]</i>.',$field,$env{'form.'.$field}); |
$errorstring = &mt('Unable to understand the search phrase <b>[_1]</b>:<i>[_2]</i>.',$field,$env{'form.'.$field}); |
} |
} |
my $bodytag = &Apache::loncommon::bodytag('Search'); |
|
my $heading = &mt('Unparsed Field'); |
my $heading = &mt('Unparsed Field'); |
my $revise = &mt('Revise search request'); |
my $revise = &mt('Revise search request'); |
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
my $html=&Apache::lonxml::xmlbegin(); |
my $start_page = &Apache::loncommon::start_page('Search'); |
|
my $end_page = &Apache::loncommon::end_page(); |
$r->print(<<ENDPAGE); |
$r->print(<<ENDPAGE); |
$html |
$start_page |
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
</head> |
|
$bodytag |
|
<form method="post" action="/adm/searchcat"> |
<form method="post" action="/adm/searchcat"> |
$hidden_fields |
$hidden_fields |
$closebutton |
$closebutton |
Line 3599 $errorstring
|
Line 3586 $errorstring
|
<p> |
<p> |
<a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a> |
<a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a> |
</p> |
</p> |
</body> |
$end_page |
</html> |
|
ENDPAGE |
ENDPAGE |
} |
} |
|
|
Line 3626 $parms is extra information to include i
|
Line 3612 $parms is extra information to include i
|
###################################################################### |
###################################################################### |
sub output_blank_field_error { |
sub output_blank_field_error { |
my ($r,$closebutton,$parms,$hidden_fields)=@_; |
my ($r,$closebutton,$parms,$hidden_fields)=@_; |
my $bodytag=&Apache::loncommon::bodytag('Search'); |
|
my $errormsg = &mt('You did not fill in enough information for the search to be started. You need to fill in relevant fields on the search page in order for a query to be processed.'); |
my $errormsg = &mt('You did not fill in enough information for the search to be started. You need to fill in relevant fields on the search page in order for a query to be processed.'); |
my $revise = &mt('Revise Search Request'); |
my $revise = &mt('Revise Search Request'); |
my $heading = &mt('Unactionable Search Queary'); |
my $heading = &mt('Unactionable Search Queary'); |
my $html=&Apache::lonxml::xmlbegin(); |
my $start_page = &Apache::loncommon::start_page('Search'); |
|
my $end_page = &Apache::loncommon::end_page(); |
$r->print(<<ENDPAGE); |
$r->print(<<ENDPAGE); |
$html |
$start_page |
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
</head> |
|
$bodytag |
|
<form method="post" action="/adm/searchcat"> |
<form method="post" action="/adm/searchcat"> |
$hidden_fields |
$hidden_fields |
$closebutton |
$closebutton |
Line 3648 $errormsg
|
Line 3630 $errormsg
|
<p> |
<p> |
<a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a> |
<a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a> |
</p> |
</p> |
</body> |
$end_page |
</html> |
|
ENDPAGE |
ENDPAGE |
return; |
return; |
} |
} |
Line 3676 Inputs:
|
Line 3657 Inputs:
|
sub output_date_error { |
sub output_date_error { |
my ($r,$message,$closebutton,$hidden_fields)=@_; |
my ($r,$message,$closebutton,$hidden_fields)=@_; |
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); |
my $start_page = &Apache::loncommon::start_page('Search'); |
my $html=&Apache::lonxml::xmlbegin(); |
my $end_page = &Apache::loncommon::end_page(); |
$r->print(<<RESULTS); |
$r->print(<<RESULTS); |
$html |
$start_page |
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
</head> |
|
$bodytag |
|
<img align='right' src='/adm/lonIcons/lonlogos.gif' /> |
|
<h1>Search Catalog</h1> |
|
<form method="post" action="/adm/searchcat"> |
<form method="post" action="/adm/searchcat"> |
$hidden_fields |
$hidden_fields |
<input type='button' value='Revise search request' |
<input type='button' value='Revise search request' |
Line 3696 $closebutton
|
Line 3671 $closebutton
|
<p> |
<p> |
$message |
$message |
</p> |
</p> |
</body> |
$end_page |
</html> |
|
RESULTS |
RESULTS |
} |
} |
|
|
Line 3737 sub cleanup {
|
Line 3711 sub cleanup {
|
} |
} |
&untiehash(); |
&untiehash(); |
&Apache::lonmysql::disconnect_from_db(); |
&Apache::lonmysql::disconnect_from_db(); |
|
return OK; |
} |
} |
|
|
__END__ |
__END__ |