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

version 1.204, 2004/03/03 17:25:23 version 1.213, 2004/04/21 15:48:34
Line 48  described at http://www.lon-capa.org. Line 48  described at http://www.lon-capa.org.
 lonsearchcat presents the user with an interface to search the LON-CAPA  lonsearchcat presents the user with an interface to search the LON-CAPA
 digital library.  lonsearchcat also initiates the execution of a search  digital library.  lonsearchcat also initiates the execution of a search
 by sending the search parameters to LON-CAPA servers.  The progress of   by sending the search parameters to LON-CAPA servers.  The progress of 
 search (on a server basis) is displayed to the user in a seperate window.  search (on a server basis) is displayed to the user in a separate window.
   
 =head1 Internals  =head1 Internals
   
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 149  sub handler { Line 150  sub handler {
     ## Initialize global variables      ## Initialize global variables
     ##      ##
     my $domain  = $r->dir_config('lonDefDomain');      my $domain  = $r->dir_config('lonDefDomain');
     $diropendb= "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db";      $diropendb= "/home/httpd/perl/tmp/".
           "$ENV{'user.domain'}_$ENV{'user.name'}_searchcat.db";
     #      #
     # set the name of the persistent database      # set the name of the persistent database
     #          $ENV{'form.persistent_db_id'} can only have digits in it.      #          $ENV{'form.persistent_db_id'} can only have digits in it.
Line 164  sub handler { Line 166  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 285  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 335  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 454  sub untiehash { Line 499  sub untiehash {
   
 } # End of course search scoping  } # End of course search scoping
   
   sub search_html_header {
       my $Str = <<ENDHEADER;
   <html>
   <head>
   <title>The LearningOnline Network with CAPA</title>
   <script type="text/javascript">
       function openhelp(val) {
    openhelpwin=open('/adm/help/searchcat.html','helpscreen',
        'scrollbars=1,width=600,height=300');
    openhelpwin.focus();
       }
   </script>
   </head>
   ENDHEADER
       return $Str;
   }
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
Line 470  Prints the form for the basic search.  S Line 532  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=<<"ENDDOCUMENT";      my $scrout = &search_html_header().$bodytag;
 <html>      if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {
 <head>          # Define interface components
 <title>The LearningOnline Network with CAPA</title>          my $userelatedwords=
 <script type="text/javascript">              &mt('[_1] use related words',
     function openhelp(val) {                  &Apache::lonhtmlcommon::checkbox
  openhelpwin=open('/adm/help/searchcat.html','helpscreen',                  ('related',$ENV{'form.related'}));
      'scrollbars=1,width=600,height=300');          my $onlysearchdomain=
  openhelpwin.focus();              &mt('[_1] only search domain [_2]',
     }                  &Apache::lonhtmlcommon::checkbox
 </script>                  ('domains',$ENV{'form.domains'}),
 </head>                  $r->dir_config('lonDefDomain'));
 $bodytag          my $adv_search_link = 
 ENDDOCUMENT              '<a href="/adm/searchcat?'.
 if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {              'phase=disp_adv&'.
     my $CatalogSearch=&mt('Catalog Search');              'catalogmode='.$ENV{'form.catalogmode'}.
     my $Statement=&searchhelp();              '&launch='.$ENV{'form.launch'}.
     $scrout.=(<<ENDDOCUMENT);              '&mode='.$ENV{'form.mode'}.
 <h1>$CatalogSearch</h1>              '">'.&mt('Advanced Search').'</a>';
 <form name="loncapa_search" method="post" action="/adm/searchcat">          #
 <input type="hidden" name="phase" value="basic_search" />          $scrout.='<form name="loncapa_search" method="post" '.
 $hidden_fields              'action="/adm/searchcat">'.
 <p>              '<input type="hidden" name="phase" value="basic_search" />'.
 $Statement.              $hidden_fields;
 </p>          #
 <p>          $scrout .= '<center>'.$/;
 <table>          if ($ENV{'request.course.id'}) {
 <tr><td>              $scrout .= '<h1>'.&mt('LON-CAPA Catalog Search').'</h1>';
 ENDDOCUMENT          } else {
     $scrout.='&nbsp;'.&Apache::lonhtmlcommon::textbox('basicexp',              # No need to tell them they are searching
                                             $ENV{'form.basicexp'},40).              $scrout.= ('<br />'x2);
         '&nbsp;';          }
     my $relatedcheckbox = &Apache::lonhtmlcommon::checkbox('related',          $scrout.='<table>'.
  $ENV{'form.related'});              '<tr><td align="center" valign="top">'.
     my $domain = $r->dir_config('lonDefDomain');              &Apache::lonhtmlcommon::textbox('basicexp',
     my $domaincheckbox = &Apache::lonhtmlcommon::checkbox('domains',                                              $ENV{'form.basicexp'},50).'<br />'.
  $ENV{'form.domains'});              '<font size="-1">'.&searchhelp().'</font>'.'</td>'.
     my $srch=&mt('Search');              '<td><font size="-1">'.
     my $header=&mt('Advanced Search');              '<nobr>'.('&nbsp;'x3).$adv_search_link.'</nobr>'.'<br />'.
     my $userelatedwords=&mt('use related words');              '<nobr>'.('&nbsp;'x1).$userelatedwords.'</nobr>'.'<br />'.
     my $onlysearchdomain=&mt('only search domain');              '<nobr>'.('&nbsp;'x1).$onlysearchdomain.'</nobr>'.'<br />'.
     my $view=&viewoptions();              '</font></td>'.
     $scrout.=<<END;              '</tr>'.$/;
 </td><td><a          #
 href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}"  #        $scrout .= '<tr><td align="center">'.
 >$header</a></td></tr>  #            '<font size="-1">'.
 <tr><td>$relatedcheckbox $userelatedwords</td>  #            $userelatedwords.('&nbsp;'x3).
     <td>$domaincheckbox $onlysearchdomain <b>$domain</b></td></tr>  #            $onlysearchdomain.('&nbsp;'x2).$adv_search_link.
 </table>  #            '</font>'.
 </p>  #            '</td></tr>'.$/;
 $view          $scrout .= '<tr><td align="center" colspan="2">'.
 <p>              '<font size="-1">'.
 &nbsp;<input type="submit" name="basicsubmit" value='$srch' />&nbsp;              '<input type="submit" name="basicsubmit" '.
 $closebutton              'value="'.&mt('Search').'" />'.
 END              ('&nbsp;'x2).$closebutton.('&nbsp;'x2).&viewoptions().
     $scrout.=<<ENDDOCUMENT;              '</font>'.
 </p>              '</td></tr>'.$/;
 </form>          $scrout .= '</table>'.$/.'</center>'.'</form>';
 ENDDOCUMENT  
     }      }
     if ($ENV{'request.course.id'}) {      if ($ENV{'request.course.id'}) {
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
    'srch' => 'Search',  
                                            'header' => 'Course Search',                                             'header' => 'Course Search',
  'note' => 'Enter terms or phrases, then press "Search" below',   'note' => 'Enter terms or phrases, then press "Search" below',
  'use' => 'use related words',   'use' => 'use related words',
  'full' =>'fulltext search (time consuming)'   'full' =>'fulltext search (time consuming)'
    );     );
         $scrout.=(<<ENDCOURSESEARCH);          $scrout.=(<<ENDCOURSESEARCH);
   <form name="loncapa_search" method="post" action="/adm/searchcat">
   <center>
 <hr />  <hr />
 <h1>$lt{'header'}</h1>      <h1>$lt{'header'}</h1>    
 <form name="course_search" method="post" action="/adm/searchcat">  
 <input type="hidden" name="phase" value="course_search" />  <input type="hidden" name="phase" value="course_search" />
 $hidden_fields  $hidden_fields
 <p>  <p>
Line 569  ENDCOURSESEARCH Line 630  ENDCOURSESEARCH
 </table><p>  </table><p>
 &nbsp;<input type="submit" name="coursesubmit" value='$lt{'srch'}' />  &nbsp;<input type="submit" name="coursesubmit" value='$lt{'srch'}' />
 </p>  </p>
   </center>
   </form>
 ENDENDCOURSE  ENDENDCOURSE
     }      }
     $scrout.=(<<ENDDOCUMENT);      $scrout.=(<<ENDDOCUMENT);
Line 602  sub print_advanced_search_form{ Line 665  sub print_advanced_search_form{
 <input type="reset" name="reset" value='$lt{"reset"}' />  <input type="reset" name="reset" value='$lt{"reset"}' />
 $closebutton  $closebutton
 <input type="button" value="$lt{'help'}" onClick="openhelp()" />  <input type="button" value="$lt{'help'}" onClick="openhelp()" />
 </p>  
 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=<<"ENDHEADER";      my $scrout=&search_html_header();
 <html>      $scrout .= <<"ENDHEADER";
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 <script type="text/javascript">  
     function openhelp(val) {  
  openhelpwin=open('/adm/help/searchcat.html','helpscreen',  
      'scrollbars=1,width=600,height=300');  
  openhelpwin.focus();  
     }  
 </script>  
 </head>  
 $bodytag  $bodytag
 $searchhelp  
 <form method="post" action="/adm/searchcat" name="advsearch">  <form method="post" action="/adm/searchcat" name="advsearch">
 $advanced_buttons  $advanced_buttons
 $hidden_fields  
 <input type="hidden" name="phase" value="adv_search" />  
 ENDHEADER  ENDHEADER
     $scrout.=&viewoptions();      $scrout.=('&nbsp;'x2).&viewoptions().'</p>'.$hidden_fields. 
           '<input type="hidden" name="phase" value="adv_search" />';
     my %fields=&Apache::lonmeta::fieldnames();      my %fields=&Apache::lonmeta::fieldnames();
       #
     $scrout.='<table>';      $scrout.= '<p>'.$searchhelp.'</p>'.
     $scrout.="<tr><th>".&mt('Field').'</th><th>'.&mt('Value').'</th><th>'          "<table>\n";
  .&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";      my %related_word_search = 
     foreach ('title','author','owner','authorspace','modifyinguser',          ('title'=>1,
      'keywords','notes','abstract','standards',           'author'=>0,
      'lowestgradelevel','highestgradelevel','mime') {           'owner'=>0,
  $scrout.='<tr bgcolor="#FFFFBB"><td>'.&titlefield($fields{$_}).'</td><td>'.           'authorspace'=>0,
     &Apache::lonmeta::prettyinput($_,$ENV{'form.'.$_},$_,'advsearch',           'modifyinguser'=>0,
   1,'</td><td>',$ENV{'form.'.$_.'_related'}).           'keywords'=>1,
     '</td></tr>';           'notes'=>1,
            'abstract'=>1,
            'standards'=>1,
            'mime'=>1,
            );
       #
       foreach my $field ('title','author','owner','authorspace','modifyinguser',
        'keywords','notes','abstract','standards','mime') {
    $scrout.='<tr><td align="right">'.&titlefield($fields{$field}).'</td><td>'.
       &Apache::lonmeta::prettyinput($field,
                                             $ENV{'form.'.$field},
                                             $field,
                                             'advsearch',
     $related_word_search{$field},
                                             '</td><td align="left">',
                                             $ENV{'form.'.$field.'_related'},
                                             50);
           if ($related_word_search{$field}) {
               $scrout .= 'related words';
           } else {
               $scrout .= '</td><td>&nbsp;';
           }
           $scrout .= '</td></tr>'.$/;
     }      }
     $scrout.='<tr bgcolor="#FFFFBB"><td>'.      foreach my $field ('lowestgradelevel','highestgradelevel') {
  &titlefield(&mt('MIME Type Category')).'</td><td>'.    $scrout.='<tr>'.
               '<td align="right">'.&titlefield($fields{$field}).'</td>'.
               '<td colspan="2">'.
       &Apache::lonmeta::prettyinput($field,
                                             $ENV{'form.'.$field},
                                             $field,
                                             'advsearch',
     0).
                                             '</td></tr>'.$/;
       }
       $scrout.='<tr><td align="right">'.
    &titlefield(&mt('MIME Type Category')).'</td><td colspan="2">'. 
     &Apache::loncommon::filecategoryselect('category',      &Apache::loncommon::filecategoryselect('category',
    $ENV{'form.category'}).     $ENV{'form.category'}).
     '</td><td>&nbsp;</td></td></tr>';      '</td></tr>'.$/;
     $scrout.='<tr bgcolor="#FFFFBB"><td>'.      $scrout.='<tr><td align="right" valign="top">'.
  &titlefield(&mt('Limit Search to Domains')).'</td><td>'.    &titlefield(&mt('Domains')).'</td><td colspan="2">'. 
     &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></tr>'.$/;
       $scrout .= "</table>\n<br />\n<table>\n";
     my %dates=&Apache::lonlocal::texthash      my %dates=&Apache::lonlocal::texthash
         ('creationdatestart'     => 'Creation Date After',          ('creationdatestart'     => 'Creation Date After',
          'creationdateend'       => 'Creation Date Before',           'creationdateend'       => 'Creation Date Before',
          'lastrevisiondatestart' => 'Last Revision Date After',           'lastrevisiondatestart' => 'Last Revision Date After',
          'lastrevisiondateend'   => 'Last Revision Date Before');           'lastrevisiondateend'   => 'Last Revision Date Before');
     foreach (sort keys %dates) {      foreach my $field (sort keys %dates) {
  $scrout.='<tr bgcolor="#FFFFBB">'.   $scrout.='<tr>'.
             '<td>'.&titlefield($dates{$_}).'</td><td>'.               '<td align="right">'.&titlefield($dates{$field}).'</td><td>'. 
     &Apache::lonhtmlcommon::date_setter('advsearch',$_,0,'',1).      &Apache::lonhtmlcommon::date_setter('advsearch',$field,0,'',1).
     '</td><td>&nbsp;</td></td>'.      '</td></tr>'.$/;
             '</tr>';  
     }      }
   
     $scrout.="</table>\n";      $scrout.="</table>\n";
     $scrout.=<<ENDDOCUMENT;      $scrout.=<<ENDDOCUMENT;
 $advanced_buttons  $advanced_buttons
Line 690  Outputs: titletext with font wrapper Line 776  Outputs: titletext with font wrapper
 ######################################################################  ######################################################################
 sub titlefield {  sub titlefield {
     my $title=shift;      my $title=shift;
     return '<font face="arial" color="#800000">'.$title.'</font>';      return $title;
 }  }
   
 ######################################################################  ######################################################################
Line 735  Outputs: text for box with view options Line 821  Outputs: text for box with view options
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
 sub viewoptions {  sub viewoptions {
     my $scrout="\n\n".'<table bgcolor="#FFFFBB">'.      my $scrout="\n".'<nobr>';
         '<tr><th>'.&mt('View Options').'</th><th>'.      if (! defined($ENV{'form.viewselect'})) { 
  &mt('Records per Page').'</th></tr><tr><td>';          $ENV{'form.viewselect'}='detailed'; 
     unless ($ENV{'form.viewselect'}) { $ENV{'form.viewselect'}='detailed'; }      }
     $scrout.=&Apache::lonmeta::selectbox('viewselect',      $scrout.=&Apache::lonmeta::selectbox('viewselect',
  $ENV{'form.viewselect'},   $ENV{'form.viewselect'},
  \&viewoptiontext,   \&viewoptiontext,
  sort(keys(%Views)));   sort(keys(%Views)));
     $scrout.='</td><td>';      $scrout.= '&nbsp;&nbsp;';
     $scrout.=&Apache::lonmeta::selectbox('show',      $scrout.=&Apache::lonmeta::selectbox('show',
  $ENV{'form.show'},   $ENV{'form.show'},
  undef,   undef,
  (10,20,50,100,1000,10000));   (10,20,50,100,1000,10000));
     $scrout.="</td></tr></table>\n\n";      $scrout .= ('&nbsp;'x2).&mt('Records per Page').'</nobr>'.$/;
     return $scrout;      return $scrout;
 }  }
   
Line 882  Inputs: Hash of values to save, filename Line 968  Inputs: Hash of values to save, filename
   
 Store variables away to the %persistent_db.  Store variables away to the %persistent_db.
 Values will be escaped.  Values that are array pointers will have their  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  =cut
   
Line 914  Inputs: filename of persistent database. Line 1000  Inputs: filename of persistent database.
   
 Store most form variables away to the %persistent_db.  Store most form variables away to the %persistent_db.
 Values will be escaped.  Values that are array pointers will have their  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  =cut
   
Line 990  sub parse_advanced_search { Line 1076  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 1646  Returns: the identifier of the table on Line 1732  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 1849  END Line 1936  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 1879  END Line 1969  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 1921  END Line 2017  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 2116  sub display_results { Line 2213  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 2236  The 'title' field is set to "Untitled" i Line 2337  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=&LONCAPA::lonmetadata::metadata_col_to_hash
  map {          (map {
  &Apache::lonnet::unescape($_);              &Apache::lonnet::unescape($_);
  } (split(/\,/,$result))          } (split(/\,/,$result)) );
       );  
     return %Fields;      return %Fields;
 }  }
   
Line 2634  END Line 2734  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>
 &lt;LonCapaResource&gt;  $xml
 &lt;url&gt;$values{'url'}&lt;/url&gt;  
 &lt;title&gt;$values{'title'}&lt;/title&gt;  
 &lt;author&gt;$values{'author'}&lt;/author&gt;  
 &lt;subject&gt;$values{'subject'}&lt;/subject&gt;  
 &lt;keywords&gt;$values{'keywords'}&lt;/keywords&gt;  
 &lt;notes&gt;$values{'notes'}&lt;/notes&gt;  
 &lt;mimeInfo&gt;  
 &lt;mime&gt;$values{'mime'}&lt;/mime&gt;  
 &lt;mimetag&gt;$values{'mimetag'}&lt;/mimetag&gt;  
 &lt;/mimeInfo&gt;  
 &lt;languageInfo&gt;  
 &lt;language&gt;$values{'language'}&lt;/language&gt;  
 &lt;languagetag&gt;$values{'languagetag'}&lt;/languagetag&gt;  
 &lt;/languageInfo&gt;  
 &lt;creationdate&gt;$values{'creationdate'}&lt;/creationdate&gt;  
 &lt;lastrevisiondate&gt;$values{'lastrevisiondate'}&lt;/lastrevisiondate&gt;  
 &lt;owner&gt;$values{'owner'}&lt;/owner&gt;  
 &lt;copyrightInfo&gt;  
 &lt;copyright&gt;$values{'copyright'}&lt;/copyright&gt;  
 &lt;copyrighttag&gt;$values{'copyrighttag'}&lt;/copyrighttag&gt;  
 &lt;/copyrightInfo&gt;  
 &lt;repositoryLocation&gt;$values{'hostname'}&lt;/repositoryLocation&gt;  
 &lt;shortabstract&gt;$values{'shortabstract'}&lt;/shortabstract&gt;  
 &lt;/LonCapaResource&gt;  
 </pre>  </pre>
 $values{'extrashow'}  $values{'extrashow'}
 <hr align='left' width='200' noshade />  <hr align='left' width='200' noshade />

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


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