Diff for /loncom/interface/lonsearchcat.pm between versions 1.203 and 1.204

version 1.203, 2004/01/15 03:18:19 version 1.204, 2004/03/03 17:25:23
Line 73  use Apache::lonmysql(); Line 73  use Apache::lonmysql();
 use Apache::lonmeta;  use Apache::lonmeta;
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon;
 use Apache::lonlocal;  use Apache::lonlocal;
   use LONCAPA::lonmetadata();
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 460  sub untiehash { Line 461  sub untiehash {
   
 =item &print_basic_search_form()   =item &print_basic_search_form() 
   
 Returns a scalar which holds html for the basic search form.  Prints the form for the basic search.  Sorry the name is so cryptic.
   
 =cut  =cut
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   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::loncommon::help_open_topic('Finding_Resources').
Line 585  ENDDOCUMENT Line 585  ENDDOCUMENT
   
 =item &advanced_search_form()   =item &advanced_search_form() 
   
 Returns a scalar which holds html for the advanced search form.  Prints the advanced search form.
   
 =cut  =cut
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 sub print_advanced_search_form{  sub print_advanced_search_form{
     my ($r,$closebutton,$hidden_fields) = @_;      my ($r,$closebutton,$hidden_fields) = @_;
     my %lt=&Apache::lonlocal::texthash('srch' => 'Search',      my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
Line 650  ENDHEADER Line 649  ENDHEADER
     &Apache::loncommon::domain_select('domains',      &Apache::loncommon::domain_select('domains',
    $ENV{'form.domains'},1).     $ENV{'form.domains'},1).
     '</td><td>&nbsp;</td></td></tr>';      '</td><td>&nbsp;</td></td></tr>';
     my %dates=&Apache::lonlocal::texthash('creationdatestart'     => 'Creation Date After',      my %dates=&Apache::lonlocal::texthash
     'creationdateend'       => 'Creation Date Before',          ('creationdatestart'     => 'Creation Date After',
   'lastrevisiondatestart' => 'Last Revision Date After',           'creationdateend'       => 'Creation Date Before',
   'lastrevisiondateend'   => 'Last Revision Date Before');           'lastrevisiondatestart' => 'Last Revision Date After',
            'lastrevisiondateend'   => 'Last Revision Date Before');
     foreach (sort keys %dates) {      foreach (sort keys %dates) {
  $scrout.='<tr bgcolor="#FFFFBB"><td>'.&titlefield($dates{$_}).'</td><td>'.    $scrout.='<tr bgcolor="#FFFFBB">'.
               '<td>'.&titlefield($dates{$_}).'</td><td>'. 
     &Apache::lonhtmlcommon::date_setter('advsearch',$_,0,'',1).      &Apache::lonhtmlcommon::date_setter('advsearch',$_,0,'',1).
     '</td><td>&nbsp;</td></td></tr>';      '</td><td>&nbsp;</td></td>'.
               '</tr>';
     }      }
   
     $scrout.="</table>\n";      $scrout.="</table>\n";
   
     $scrout.=<<ENDDOCUMENT;      $scrout.=<<ENDDOCUMENT;
 $advanced_buttons  $advanced_buttons
 </form>  </form>
Line 671  ENDDOCUMENT Line 672  ENDDOCUMENT
     $r->print($scrout);      $r->print($scrout);
     return;      return;
 }  }
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 =pod   =pod 
   
 =item &titlefield  =item &titlefield()
   
 Inputs: title text  Inputs: title text
   
Line 686  Outputs: titletext with font wrapper Line 688  Outputs: titletext with font wrapper
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 sub titlefield {  sub titlefield {
     my $title=shift;      my $title=shift;
     return '<font face="arial" color="#800000">'.$title.'</font>';      return '<font face="arial" color="#800000">'.$title.'</font>';
 }  }
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 =pod   =pod 
   
 =item viewoptiontext  =item viewoptiontext()
   
 Inputs: codename for view option  Inputs: codename for view option
   
Line 706  Outputs: displayed text Line 708  Outputs: displayed text
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 sub viewoptiontext {  sub viewoptiontext {
     my $code=shift;      my $code=shift;
     my %desc=&Apache::lonlocal::texthash('detailed' => "Detailed Citation View",      my %desc=&Apache::lonlocal::texthash
  'xml' => 'XML/SGML',          ('detailed' => "Detailed Citation View",
  'compact' => 'Compact View',           'xml' => 'XML/SGML',
  'fielded' => 'Fielded Format',           'compact' => 'Compact View',
  'summary' => 'Summary View');           'fielded' => 'Fielded Format',
            'summary' => 'Summary View');
     return $desc{$code};      return $desc{$code};
 }  }
   
   ######################################################################
 ######################################################################  ######################################################################
   
 =pod   =pod 
   
 =item viewoptions  =item viewoptions()
   
 Inputs: none  Inputs: none
   
Line 730  Outputs: text for box with view options Line 734  Outputs: text for box with view options
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 sub viewoptions {  sub viewoptions {
     my $scrout="\n\n".'<table bgcolor="#FFFFBB"><tr><th>'.&mt('View Options').'</th><th>'.      my $scrout="\n\n".'<table bgcolor="#FFFFBB">'.
           '<tr><th>'.&mt('View Options').'</th><th>'.
  &mt('Records per Page').'</th></tr><tr><td>';   &mt('Records per Page').'</th></tr><tr><td>';
     unless ($ENV{'form.viewselect'}) { $ENV{'form.viewselect'}='detailed'; }      unless ($ENV{'form.viewselect'}) { $ENV{'form.viewselect'}='detailed'; }
     $scrout.=&Apache::lonmeta::selectbox('viewselect',      $scrout.=&Apache::lonmeta::selectbox('viewselect',
Line 749  sub viewoptions { Line 753  sub viewoptions {
 }  }
   
 ######################################################################  ######################################################################
   ######################################################################
   
 =pod   =pod 
   
 =item searchhelp  =item searchhelp()
   
 Inputs: none  Inputs: none
   
Line 762  Outputs: return little blurb on how to e Line 767  Outputs: return little blurb on how to e
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 sub searchhelp {  sub searchhelp {
     return &mt('Enter terms or phrases separated by AND, OR, or NOT');      return &mt('Enter terms or phrases separated by AND, OR, or NOT');
 }  }
Line 772  sub searchhelp { Line 776  sub searchhelp {
   
 =pod   =pod 
   
 =item &get_persistent_form_data  =item &get_persistent_form_data()
   
 Inputs: filename of database  Inputs: filename of database
   
Line 827  sub get_persistent_form_data { Line 831  sub get_persistent_form_data {
   
 =pod   =pod 
   
 =item &get_persistent_data  =item &get_persistent_data()
   
 Inputs: filename of database, ref to array of values to recover.  Inputs: filename of database, ref to array of values to recover.
   
Line 987  sub parse_advanced_search { Line 991  sub parse_advanced_search {
  }   }
     }      }
     unless ($fillflag) {      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 ;   return ;
     }      }
     # Turn the form input into a SQL-based query      # Turn the form input into a SQL-based query
Line 1038  sub parse_advanced_search { Line 1043  sub parse_advanced_search {
         $pretty_search_string .=$font.'mime</font> contains <b>'.          $pretty_search_string .=$font.'mime</font> contains <b>'.
             $searchphrase.'</b><br />';              $searchphrase.'</b><br />';
     }      }
     #####      #
     # Evaluate option lists      # Evaluate option lists
     if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') {      if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') {
  push @queries,"(language like \"$ENV{'form.language'}\")";   push @queries,"(language like \"$ENV{'form.language'}\")";
Line 1077  sub parse_advanced_search { Line 1082  sub parse_advanced_search {
         # date query information.          # date query information.
  push @queries,$datequery;   push @queries,$datequery;
     }      }
       #
     # Process form information for custom metadata querying      # Process form information for custom metadata querying
     my $customquery=undef;      my $customquery=undef;
 #    if ($ENV{'form.custommetadata'}) {      ##
 #        $pretty_search_string .=$font."Custom Metadata Search</font>: <b>".      ## The custom metadata search was removed q long time ago mostly 
 #            $ENV{'form.custommetadata'}."</b><br />\n";      ## because I was unable to figureout exactly how it worked and could
 # $customquery=&build_custommetadata_query('custommetadata',      ## not imagine people actually using it.  MH
 #      $ENV{'form.custommetadata'});      ##
 #    }      # if ($ENV{'form.custommetadata'}) {
       #    $pretty_search_string .=$font."Custom Metadata Search</font>: <b>".
       #    $ENV{'form.custommetadata'}."</b><br />\n";
       #    $customquery=&build_custommetadata_query('custommetadata',
       #                                             $ENV{'form.custommetadata'});
       # }
     my $customshow=undef;      my $customshow=undef;
 #    if ($ENV{'form.customshow'}) {      # if ($ENV{'form.customshow'}) {
 #        $pretty_search_string .=$font."Custom Metadata Display</font>: <b>".      # $pretty_search_string .=$font."Custom Metadata Display</font>: <b>".
 #            $ENV{'form.customshow'}."</b><br />\n";      #                         $ENV{'form.customshow'}."</b><br />\n";
 # $customshow=$ENV{'form.customshow'};      #    $customshow=$ENV{'form.customshow'};
 # $customshow=~s/[^\w\s]//g;      #    $customshow=~s/[^\w\s]//g;
 # my @fields=split(/\s+/,$customshow);      #    my @fields=split(/\s+/,$customshow);
 # $customshow=join(" ",@fields);      #    $customshow=join(" ",@fields);
 #    }      # }
     ## ---------------------------------------------------------------      ##
     ## Deal with restrictions to given domains      ## Deal with restrictions to given domains
     ##       ## 
     my ($libraries_to_query,$pretty_domains_string) =       my ($libraries_to_query,$pretty_domains_string) = 
Line 1124  sub parse_domain_restrictions { Line 1135  sub parse_domain_restrictions {
     } else {      } else {
         @allowed_domains = ($ENV{'form.domains'});          @allowed_domains = ($ENV{'form.domains'});
     }      }
       #
     my %domain_hash = ();      my %domain_hash = ();
     my $pretty_domains_string;      my $pretty_domains_string;
     foreach (@allowed_domains) {      foreach (@allowed_domains) {
Line 1164  Parse the basic search form and return a Line 1176  Parse the basic search form and return a
 ######################################################################  ######################################################################
 sub parse_basic_search {  sub parse_basic_search {
     my ($r,$closebutton)=@_;      my ($r,$closebutton)=@_;
       #
     # Clean up fields for safety      # Clean up fields for safety
     for my $field ('basicexp') {      for my $field ('basicexp') {
  $ENV{"form.$field"}=~s/[^\w\s\(\)\-]//g;   $ENV{"form.$field"}=~s/[^\w\s\(\)\-]//g;
Line 1176  sub parse_basic_search { Line 1189  sub parse_basic_search {
     }      }
     my ($libraries_to_query,$pretty_domains_string) =       my ($libraries_to_query,$pretty_domains_string) = 
         &parse_domain_restrictions();          &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'})) {      unless (&filled($ENV{'form.basicexp'})) {
  &output_blank_field_error($r,$closebutton,'phase=disp_basic');   &output_blank_field_error($r,$closebutton,'phase=disp_basic');
  return OK;   return OK;
Line 1192  sub parse_basic_search { Line 1206  sub parse_basic_search {
             $pretty_search_string .= " with no related words.";              $pretty_search_string .= " with no related words.";
         }          }
     }      }
       #
     # Build SQL query string based on form page      # Build SQL query string based on form page
     my $query='';      my $query='';
     my $concatarg=join(',',      my $concatarg=join(',',
Line 1204  sub parse_basic_search { Line 1219  sub parse_basic_search {
     }      }
     $pretty_search_string .= "<br />\n";      $pretty_search_string .= "<br />\n";
     my $final_query = 'SELECT * FROM metadata WHERE '.$query;      my $final_query = 'SELECT * FROM metadata WHERE '.$query;
 #    &Apache::lonnet::logthis($final_query);      # &Apache::lonnet::logthis($final_query);
     return ($final_query,$pretty_search_string,      return ($final_query,$pretty_search_string,
             $libraries_to_query);              $libraries_to_query);
 }  }
   
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 =pod   =pod 
   
 =item &related_version  =item &related_version()
   
 Modifies an input string to include related words.  Words in the string  Modifies an input string to include related words.  Words in the string
 are replaced with parenthesized lists of 'OR'd words.  For example  are replaced with parenthesized lists of 'OR'd words.  For example
Line 1412  sub build_date_queries { Line 1426  sub build_date_queries {
   
 =item &copyright_check()  =item &copyright_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  =cut
   
 ######################################################################  ######################################################################
Line 1435  sub copyright_check { Line 1454  sub copyright_check {
     return 1;      return 1;
 }  }
   
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 =pod  =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  Ensure we can get lonmysql to connect to the database and the table we
 need exists.  need exists.
Line 1497  sub ensure_db_and_table { Line 1515  sub ensure_db_and_table {
   
 =pod  =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  =cut
   
Line 1598  the following format: Line 1619  the following format:
   
 #####################################################################  #####################################################################
 #####################################################################  #####################################################################
   #
 my @Datatypes =   # These should probably be scoped but I don't have time right now...
     ( { name => 'id',   #
         type => 'MEDIUMINT',  my @Datatypes;
         restrictions => 'UNSIGNED NOT NULL',  my @Fullindicies;
         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/;  
           
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 1672  Returns: the identifier of the table on Line 1643  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 {  sub create_results_table {
       &set_up_table_structure();
     my $table = &Apache::lonmysql::create_table      my $table = &Apache::lonmysql::create_table
         ( { columns => \@Datatypes,          ( { columns => \@Datatypes,
             FULLTEXT => [{'columns' => \@Fullindicies},],              FULLTEXT => [{'columns' => \@Fullindicies},],
Line 1742  sub update_seconds { Line 1727  sub update_seconds {
   
 =pod  =pod
   
 =item &revise_button  =item &revise_button()
   
 Inputs: None  Inputs: None
   
Line 1769  sub revise_button { Line 1754  sub revise_button {
   
 =pod  =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  =cut
   
Line 1805  END Line 1793  END
     $r->rflush();      $r->rflush();
     #      #
     # Determine the servers we need to contact.      # Determine the servers we need to contact.
     #  
     my @Servers_to_contact;      my @Servers_to_contact;
     if (defined($serverlist)) {      if (defined($serverlist)) {
         if (ref($serverlist) eq 'ARRAY') {          if (ref($serverlist) eq 'ARRAY') {
Line 1833  END Line 1820  END
         return;          return;
     }      }
     if (! $table_status) {      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.".          $r->print("The table id,$table, we tried to use is invalid.".
                   "The search has been aborted.</body></html>");                    "The search has been aborted.</body></html>");
         return;          return;
     }      }
     ##      ##
     ## Prepare for the big loop.      ## Prepare for the big loop.
     ##  
     my $hitcountsum;      my $hitcountsum;
     my $server;       my $server; 
     my $status;      my $status;
Line 1884  END Line 1875  END
             sleep(1)              sleep(1)
         }          }
         #          #
         #  
         # Loop through the servers we have contacted but do not          # Loop through the servers we have contacted but do not
         # 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)) {
Line 1958  END Line 1948  END
     }      }
     &update_status($r,&mt('Search Complete').$server);      &update_status($r,&mt('Search Complete').$server);
     &update_seconds($r,0);      &update_seconds($r,0);
       #
     &Apache::lonmysql::disconnect_from_db();      &Apache::lonmysql::disconnect_from_db();
       #
     # 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.        # results to get.  
     $r->print("</body></html>");      $r->print("</body></html>");
Line 1974  END Line 1966  END
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 =pod  =pod
   
 =item &prev_next_buttons  =item &prev_next_buttons()
   
   Returns html for the previous and next buttons on the search results page.
   
 =cut  =cut
   
Line 1991  sub prev_next_buttons { Line 1986  sub prev_next_buttons {
     my $prev_min = $current_min - $show;      my $prev_min = $current_min - $show;
     $prev_min = 1 if $prev_min < 1;      $prev_min = 1 if $prev_min < 1;
     if ($prev_min < $current_min) {      if ($prev_min < $current_min) {
         $links .= qq{          $links .= 
 <a href="/adm/searchcat?$parms&start=$prev_min&show=$show">prev</a>              qq{<a href="/adm/searchcat?$parms&start=$prev_min&show=$show">}.
 };                  &mt('prev').'</a>';
     } else {      } else {
         $links .= 'prev';          $links .= &mt('prev');
     }      }
     ##      ##
     ## Pages.... Someday.      ## Pages.... Someday.
     ##      ##
     $links .= qq{ &nbsp;      $links .= 
 <a href="/adm/searchcat?$parms&start=$current_min&$show=$show">reload</a>          qq{&nbsp;
 };             <a href="/adm/searchcat?$parms&start=$current_min&$show=$show">}.
                   &mt('reload').'</a>';
     ##      ##
     ## Next      ## Next
     my $next_min = $current_min + $show;      my $next_min = $current_min + $show;
     $next_min = $current_min if ($next_min > $total);      $next_min = $current_min if ($next_min > $total);
     if ($next_min != $current_min) {      if ($next_min != $current_min) {
         $links .= qq{ &nbsp;          $links .= 
 <a href="/adm/searchcat?$parms&start=$next_min&show=$show">next</a>              qq{&nbsp;
 };                     <a href="/adm/searchcat?$parms&start=$next_min&show=$show">}.
                       &mt('next').'</a>';
     } else {      } else {
         $links .= '&nbsp;next';          $links .= '&nbsp;'.&mt('next');
     }      }
     return $links;      return $links;
 }  }
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
 =pod  =pod
   
 =item &display_results  =item &display_results()
   
   Prints the results out for selection and perusal.
   
 =cut  =cut
   
Line 2049  sub display_results { Line 2049  sub display_results {
     ##      ##
     my $action = "/adm/searchcat?phase=results";      my $action = "/adm/searchcat?phase=results";
     ##      ##
     ## Deal with groupsearch      ## Deal with groupsearch by opening the groupsearch db file.
     ##  
     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)) {
Line 2061  sub display_results { Line 2060  sub display_results {
     }      }
     ##      ##
     ## Prepare the table for querying      ## Prepare the table for querying
     ##  
     my $table = $ENV{'form.table'};      my $table = $ENV{'form.table'};
     return if (! &ensure_db_and_table($r,$table));      return if (! &ensure_db_and_table($r,$table));
     ##      ##
     ## 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></body></html>");
Line 2077  sub display_results { Line 2074  sub display_results {
     }      }
     ##      ##
     ## Determine how many results we need to get      ## Determine how many results we need to get
     ##  
     $ENV{'form.start'} = 1      if (! exists($ENV{'form.start'}));      $ENV{'form.start'} = 1      if (! exists($ENV{'form.start'}));
     $ENV{'form.show'}  = 'all'  if (! exists($ENV{'form.show'}));      $ENV{'form.show'}  = 'all'  if (! exists($ENV{'form.show'}));
     my $min = $ENV{'form.start'};      my $min = $ENV{'form.start'};
Line 2090  sub display_results { Line 2086  sub display_results {
     }      }
     ##      ##
     ## Output links (if necessary) for 'prev' and 'next' pages.      ## Output links (if necessary) for 'prev' and 'next' pages.
     ##  
     $r->print      $r->print
         ('<center>'.          ('<center>'.
          &prev_next_buttons($min,$ENV{'form.show'},$total_results,           &prev_next_buttons($min,$ENV{'form.show'},$total_results,
Line 2110  sub display_results { Line 2105  sub display_results {
     }      }
     ##      ##
     ## Get results from MySQL table      ## Get results from MySQL table
     ##  
     my @Results = &Apache::lonmysql::get_rows($table,      my @Results = &Apache::lonmysql::get_rows($table,
                                               'id>='.$min.' AND id<='.$max);                                                'id>='.$min.' AND id<='.$max);
     ##      ##
     ## Loop through the results and output them.      ## Loop through the results and output them.
     ##  
     foreach my $row (@Results) {      foreach my $row (@Results) {
         if ($connection->aborted()) {          if ($connection->aborted()) {
             &cleanup();              &cleanup();
Line 2193  END Line 2186  END
   
 =pod  =pod
   
 =item &parse_row  =item &parse_row()
   
 Parse a row returned from the database.  Parse a row returned from the database.
   
Line 2204  Parse a row returned from the database. Line 2197  Parse a row returned from the database.
 sub parse_row {  sub parse_row {
     my @Row = @_;      my @Row = @_;
     my %Fields;      my %Fields;
       if (! scalar(@Datatypes)) {
           &set_up_table_structure();
       }
     for (my $i=0;$i<=$#Row;$i++) {      for (my $i=0;$i<=$#Row;$i++) {
         $Fields{$Datatypes[$i]->{'name'}}=&Apache::lonnet::unescape($Row[$i]);          $Fields{$Datatypes[$i]->{'name'}}=&Apache::lonnet::unescape($Row[$i]);
     }      }
Line 2239  The 'title' field is set to "Untitled" i Line 2235  The 'title' field is set to "Untitled" i
 ###########################################################  ###########################################################
 sub parse_raw_result {  sub parse_raw_result {
     my ($result,$hostname) = @_;      my ($result,$hostname) = @_;
 # conclude from self to others regarding fields      # conclude from self to others regarding fields
     my %Fields=&Apache::lonmeta::metadata_col_to_hash(      my %Fields=&Apache::lonmeta::metadata_col_to_hash(
  map {   map {
  &Apache::lonnet::unescape($_);   &Apache::lonnet::unescape($_);
Line 2294  sub handle_custom_fields { Line 2290  sub handle_custom_fields {
   
 =pod  =pod
   
 =item &search_results_header  =item &search_results_header()
   
 Output the proper html headers and javascript code to deal with different   Output the proper html headers and javascript code to deal with different 
 calling modes.  calling modes.
Line 2496  ENDFRAMES Line 2492  ENDFRAMES
 =item Metadata Viewing Functions  =item Metadata Viewing Functions
   
 Output is a HTML-ified string.  Output is a HTML-ified string.
   
 Input arguments are title, author, subject, url, keywords, version,  Input arguments are title, author, subject, url, keywords, version,
 notes, short abstract, mime, language, creation date,  notes, short abstract, mime, language, creation date,
 last revision date, owner, copyright, hostname, and  last revision date, owner, copyright, hostname, and
Line 2686  END Line 2683  END
 sub filled {  sub filled {
     my ($field)=@_;      my ($field)=@_;
     if ($field=~/\S/ && $field ne 'any') {      if ($field=~/\S/ && $field ne 'any') {
  return 1;          return 1;
     }      } else {
     else {          return 0;
  return 0;  
     }      }
 }  }
   

Removed from v.1.203  
changed lines
  Added in v.1.204


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>