';
unless ($ENV{'form.viewselect'}) { $ENV{'form.viewselect'}='detailed'; }
$scrout.=&Apache::lonmeta::selectbox('viewselect',
@@ -749,10 +753,11 @@ sub viewoptions {
}
######################################################################
+######################################################################
=pod
-=item searchhelp
+=item searchhelp()
Inputs: none
@@ -762,7 +767,6 @@ Outputs: return little blurb on how to e
######################################################################
######################################################################
-
sub searchhelp {
return &mt('Enter terms or phrases separated by AND, OR, or NOT');
}
@@ -772,7 +776,7 @@ sub searchhelp {
=pod
-=item &get_persistent_form_data
+=item &get_persistent_form_data()
Inputs: filename of database
@@ -827,7 +831,7 @@ sub get_persistent_form_data {
=pod
-=item &get_persistent_data
+=item &get_persistent_data()
Inputs: filename of database, ref to array of values to recover.
@@ -878,7 +882,7 @@ Inputs: Hash of values to save, filename
Store variables away to the %persistent_db.
Values will be escaped. Values that are array pointers will have their
-elements escaped and concatenated in a comma seperated string.
+elements escaped and concatenated in a comma separated string.
=cut
@@ -910,7 +914,7 @@ Inputs: filename of persistent database.
Store most form variables away to the %persistent_db.
Values will be escaped. Values that are array pointers will have their
-elements escaped and concatenated in a comma seperated string.
+elements escaped and concatenated in a comma separated string.
=cut
@@ -987,7 +991,8 @@ sub parse_advanced_search {
}
}
unless ($fillflag) {
- &output_blank_field_error($r,$closebutton,'phase=disp_adv',$hidden_fields);
+ &output_blank_field_error($r,$closebutton,
+ 'phase=disp_adv',$hidden_fields);
return ;
}
# Turn the form input into a SQL-based query
@@ -1038,7 +1043,7 @@ sub parse_advanced_search {
$pretty_search_string .=$font.'mime contains '.
$searchphrase.' ';
}
- #####
+ #
# Evaluate option lists
if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') {
push @queries,"(language like \"$ENV{'form.language'}\")";
@@ -1077,24 +1082,30 @@ sub parse_advanced_search {
# date query information.
push @queries,$datequery;
}
+ #
# Process form information for custom metadata querying
my $customquery=undef;
-# if ($ENV{'form.custommetadata'}) {
-# $pretty_search_string .=$font."Custom Metadata Search: ".
-# $ENV{'form.custommetadata'}." \n";
-# $customquery=&build_custommetadata_query('custommetadata',
-# $ENV{'form.custommetadata'});
-# }
+ ##
+ ## The custom metadata search was removed q long time ago mostly
+ ## because I was unable to figureout exactly how it worked and could
+ ## not imagine people actually using it. MH
+ ##
+ # if ($ENV{'form.custommetadata'}) {
+ # $pretty_search_string .=$font."Custom Metadata Search: ".
+ # $ENV{'form.custommetadata'}." \n";
+ # $customquery=&build_custommetadata_query('custommetadata',
+ # $ENV{'form.custommetadata'});
+ # }
my $customshow=undef;
-# if ($ENV{'form.customshow'}) {
-# $pretty_search_string .=$font."Custom Metadata Display: ".
-# $ENV{'form.customshow'}." \n";
-# $customshow=$ENV{'form.customshow'};
-# $customshow=~s/[^\w\s]//g;
-# my @fields=split(/\s+/,$customshow);
-# $customshow=join(" ",@fields);
-# }
- ## ---------------------------------------------------------------
+ # if ($ENV{'form.customshow'}) {
+ # $pretty_search_string .=$font."Custom Metadata Display: ".
+ # $ENV{'form.customshow'}." \n";
+ # $customshow=$ENV{'form.customshow'};
+ # $customshow=~s/[^\w\s]//g;
+ # my @fields=split(/\s+/,$customshow);
+ # $customshow=join(" ",@fields);
+ # }
+ ##
## Deal with restrictions to given domains
##
my ($libraries_to_query,$pretty_domains_string) =
@@ -1124,6 +1135,7 @@ sub parse_domain_restrictions {
} else {
@allowed_domains = ($ENV{'form.domains'});
}
+ #
my %domain_hash = ();
my $pretty_domains_string;
foreach (@allowed_domains) {
@@ -1164,6 +1176,7 @@ Parse the basic search form and return a
######################################################################
sub parse_basic_search {
my ($r,$closebutton)=@_;
+ #
# Clean up fields for safety
for my $field ('basicexp') {
$ENV{"form.$field"}=~s/[^\w\s\(\)\-]//g;
@@ -1176,7 +1189,8 @@ sub parse_basic_search {
}
my ($libraries_to_query,$pretty_domains_string) =
&parse_domain_restrictions();
- # Check to see if enough is filled in
+ #
+ # Check to see if enough of a query is filled in
unless (&filled($ENV{'form.basicexp'})) {
&output_blank_field_error($r,$closebutton,'phase=disp_basic');
return OK;
@@ -1192,6 +1206,7 @@ sub parse_basic_search {
$pretty_search_string .= " with no related words.";
}
}
+ #
# Build SQL query string based on form page
my $query='';
my $concatarg=join(',',
@@ -1204,18 +1219,17 @@ sub parse_basic_search {
}
$pretty_search_string .= " \n";
my $final_query = 'SELECT * FROM metadata WHERE '.$query;
-# &Apache::lonnet::logthis($final_query);
+ # &Apache::lonnet::logthis($final_query);
return ($final_query,$pretty_search_string,
$libraries_to_query);
}
-
######################################################################
######################################################################
=pod
-=item &related_version
+=item &related_version()
Modifies an input string to include related words. Words in the string
are replaced with parenthesized lists of 'OR'd words. For example
@@ -1412,6 +1426,11 @@ sub build_date_queries {
=item ©right_check()
+Inputs: $Metadata, a hash pointer of metadata for a resource.
+
+Returns: 1 if the resource is available to the user making the query,
+ 0 otherwise.
+
=cut
######################################################################
@@ -1435,13 +1454,12 @@ sub copyright_check {
return 1;
}
-
######################################################################
######################################################################
=pod
-=item &ensure_db_and_table
+=item &ensure_db_and_table()
Ensure we can get lonmysql to connect to the database and the table we
need exists.
@@ -1497,7 +1515,10 @@ sub ensure_db_and_table {
=pod
-=item &print_sort_form
+=item &print_sort_form()
+
+The sort feature is not implemented at this time. This form just prints
+a link to change the search query.
=cut
@@ -1598,61 +1619,11 @@ the following format:
#####################################################################
#####################################################################
-
-my @Datatypes =
- ( { name => 'id',
- type => 'MEDIUMINT',
- restrictions => 'UNSIGNED NOT NULL',
- primary_key => 'yes',
- auto_inc => 'yes' },
- { name => 'title', type=>'TEXT'},
- { name => 'author', type=>'TEXT'},
- { name => 'subject', type=>'TEXT'},
- { name => 'url', type=>'TEXT', restrictions => 'NOT NULL' },
- { name => 'keywords', type=>'TEXT'},
- { name => 'version', type=>'TEXT'},
- { name => 'notes', type=>'TEXT'},
- { name => 'abstract', type=>'TEXT'},
- { name => 'mime', type=>'TEXT'},
- { name => 'language', type=>'TEXT'},
- { name => 'owner', type=>'TEXT'},
- { name => 'copyright', type=>'TEXT'},
- { name => 'dependencies', type=>'TEXT'},
- { name => 'modifyinguser', type=>'TEXT'},
- { name => 'authorspace', type=>'TEXT'},
- { name => 'lowestgradelevel', type=>'INT'},
- { name => 'highestgradelevel', type=>'INT'},
- { name => 'standards', type=>'TEXT'},
- { name => 'count', type=>'INT'},
- { name => 'course', type=>'INT'},
- { name => 'course_list', type=>'TEXT'},
- { name => 'goto', type=>'INT'},
- { name => 'goto_list', type=>'TEXT'},
- { name => 'comefrom', type=>'INT'},
- { name => 'comefrom_list', type=>'TEXT'},
- { name => 'sequsage', type=>'INT'},
- { name => 'sequsage_list', type=>'TEXT'},
- { name => 'stdno', type=>'INT'},
- { name => 'stdno_list', type=>'TEXT'},
- { name => 'avetries', type=>'FLOAT'},
- { name => 'avetries_list', type=>'TEXT'},
- { name => 'difficulty', type=>'FLOAT'},
- { name => 'difficulty_list', type=>'TEXT'},
- { name => 'clear', type=>'FLOAT'},
- { name => 'technical', type=>'FLOAT'},
- { name => 'correct', type=>'FLOAT'},
- { name => 'helpful', type=>'FLOAT'},
- { name => 'depth', type=>'FLOAT'},
- { name => 'hostname', type=> 'TEXT'},
- #--------------------------------------------------
- { name => 'creationdate', type=>'DATETIME'},
- { name => 'lastrevisiondate', type=>'DATETIME'},
- #--------------------------------------------------
- );
-
-my @Fullindicies =
- qw/title/;
-# qw/title author subject abstract mime language owner copyright/;
+#
+# These should probably be scoped but I don't have time right now...
+#
+my @Datatypes;
+my @Fullindicies;
######################################################################
######################################################################
@@ -1672,7 +1643,21 @@ Returns: the identifier of the table on
######################################################################
######################################################################
+sub set_up_table_structure {
+ my ($datatypes,$fullindicies) =
+ &LONCAPA::lonmetadata::describe_metadata_storage();
+ unshift(@$datatypes,{name => 'id',
+ type => 'MEDIUMINT',
+ restrictions => 'UNSIGNED NOT NULL',
+ primary_key => 'yes',
+ auto_inc => 'yes' });
+ @Datatypes = @{$datatypes};
+ @Fullindicies = @{$fullindicies};
+ return;
+}
+
sub create_results_table {
+ &set_up_table_structure();
my $table = &Apache::lonmysql::create_table
( { columns => \@Datatypes,
FULLTEXT => [{'columns' => \@Fullindicies},],
@@ -1742,7 +1727,7 @@ sub update_seconds {
=pod
-=item &revise_button
+=item &revise_button()
Inputs: None
@@ -1769,7 +1754,10 @@ sub revise_button {
=pod
-=item &run_search
+=item &run_search()
+
+Executes a search query by sending it the the other servers and putting the
+results into MySQL.
=cut
@@ -1805,7 +1793,6 @@ END
$r->rflush();
#
# Determine the servers we need to contact.
- #
my @Servers_to_contact;
if (defined($serverlist)) {
if (ref($serverlist) eq 'ARRAY') {
@@ -1833,13 +1820,17 @@ END
return;
}
if (! $table_status) {
+ &Apache::lonnet::logthis("lonmysql error = ".
+ &Apache::lonmysql::get_error());
+ &Apache::lonnet::logthis("lonmysql debug = ".
+ &Apache::lonmysql::get_debug());
+ &Apache::lonnet::logthis('table status = "'.$table_status.'"');
$r->print("The table id,$table, we tried to use is invalid.".
"The search has been aborted. |