Diff for /loncom/interface/lonsearchcat.pm between versions 1.344 and 1.345

version 1.344, 2014/12/14 22:11:03 version 1.345, 2015/06/12 21:11:07
Line 78  use Apache::lonnavmaps; Line 78  use Apache::lonnavmaps;
 use Apache::lonindexer();  use Apache::lonindexer();
 use Apache::lonwishlist();  use Apache::lonwishlist();
 use LONCAPA;  use LONCAPA;
   use Time::HiRes qw(sleep);
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 143  sub handler { Line 144  sub handler {
     ##     this once, so the pause indicator is deleted      ##     this once, so the pause indicator is deleted
     ##      ##
     if (exists($env{'form.pause'})) {      if (exists($env{'form.pause'})) {
         sleep(1);          Time::HiRes::sleep(0.1);
         delete($env{'form.pause'});          delete($env{'form.pause'});
     }      }
     ##      ##
Line 2050  sub print_sort_form { Line 2051  sub print_sort_form {
         &Apache::lonnet::logthis(&Apache::lonmysql::get_error());          &Apache::lonnet::logthis(&Apache::lonmysql::get_error());
         return;          return;
     }      }
       # update results
       my $newloc = '/adm/searchcat?phase=results&persistent_db_id='.
           $env{'form.persistent_db_id'};
     my $js =<<END;      my $js =<<END;
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[      var frame = parent.resultsframe;
     function change_sort() {      var frameDoc = frame.document;
         var newloc = "/adm/searchcat?phase=results";      if (frameDoc.readyState  == 'complete')
         newloc += "&persistent_db_id=$env{'form.persistent_db_id'}";          frame.location = "$newloc";
         newloc += "&sortby=";  
         newloc += document.forms.statusform.elements.sortby.value;  
         parent.resultsframe.location= newloc;  
     }  
 // ]]>  
 </script>  </script>
 END  END
   
Line 2228  SCRIPT Line 2227  SCRIPT
     $r->rflush();      $r->rflush();
 }  }
   
   sub reload_result_frame {
       my ($r) = @_;
       my $newloc = '/adm/searchcat?phase=results&persistent_db_id='.
           $env{'form.persistent_db_id'};
       $r->print(<<SCRIPT);
   <script type="text/javascript">
       var frame = parent.resultsframe;
       var frameDoc = frame.document;
       if (frameDoc.readyState  == 'complete')
           frame.location = "$newloc";
   </script>
   SCRIPT
   
       $r->rflush();
   }
   
 {  {
     my $max_time  = 300;  # seconds for the search to complete      my $max_time  = 60;  # seconds for the search to complete
     my $start_time = 0;      my $start_time = 0;
     my $last_time = 0;      my $last_time = 0;
   
Line 2410  END Line 2425  END
     ##      ##
     ## Prepare for the big loop.      ## Prepare for the big loop.
     my $hitcountsum;      my $hitcountsum;
       my $oldhitcountsum;
     my %matches;      my %matches;
     my $server;       my $server; 
     my $status;      my $status;
Line 2456  END Line 2472  END
                 &update_status($r,                  &update_status($r,
                        &mt('waiting on [_1]',join(' ',keys(%Server_status))));                         &mt('waiting on [_1]',join(' ',keys(%Server_status))));
             }              }
             sleep(1)              Time::HiRes::sleep(0.1);
         }          }
         #          #
         # Loop through the servers we have contacted but do not          # Loop through the servers we have contacted but do not
Line 2532  END Line 2548  END
                 delete($Server_status{$server});                  delete($Server_status{$server});
             }              }
             last if ($connection->aborted());              last if ($connection->aborted());
             &update_count_status($r,$hitcountsum);              if ($oldhitcountsum < $hitcountsum) {
                   &update_count_status($r,$hitcountsum);
                   if ($hitcountsum <= $env{'form.show'}) {
                       reload_result_frame($r);
                   }
                   $oldhitcountsum = $hitcountsum;
               }
         }          }
         last if ($connection->aborted());          last if ($connection->aborted());
         &update_seconds($r);          &update_seconds($r);
Line 2626  sub display_results { Line 2648  sub display_results {
     if ($env{'form.catalogmode'} eq 'import') {      if ($env{'form.catalogmode'} eq 'import') {
         if (! tie(%groupsearch_db,'GDBM_File',$diropendb,          if (! tie(%groupsearch_db,'GDBM_File',$diropendb,
                   &GDBM_WRCREAT(),0640)) {                    &GDBM_WRCREAT(),0640)) {
               # NOTE: this can happen when a previous request to searchcat?phase=results gets interrupted
               # (%groupsearch_db is not untied)
             $r->print('<p class="LC_error">'.              $r->print('<p class="LC_error">'.
               &mt('Unable to save import results.').                &mt('Unable to save import results.').
               '</p>'.                '</p>'.
Line 2634  sub display_results { Line 2658  sub display_results {
             $r->rflush();              $r->rflush();
             return;              return;
         }           } 
           # untie %groupsearch_db if the connection gets aborted before the end
           $r->register_cleanup(sub {
               untie %groupsearch_db if (tied(%groupsearch_db));
           });
     }      }
     ##      ##
     ## Prepare the table for querying      ## Prepare the table for querying
Line 2775  sub display_results { Line 2803  sub display_results {
     );      );
   
     if ($total_results == 0) {      if ($total_results == 0) {
         $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2" />'.          $r->print('<p class="LC_info">'.&mt('There are currently no results.').'</p>'.
                   '<p class="LC_info">'.&mt('There are currently no results.').'</p>'.  
                   "</form>".                    "</form>".
   &Apache::loncommon::end_page());    &Apache::loncommon::end_page());
         return;          return;

Removed from v.1.344  
changed lines
  Added in v.1.345


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