includes/paths.php
changeset 698 40f9528b6348
parent 696 bd5069e1f19a
child 741 a216e412c439
--- a/includes/paths.php	Tue Aug 19 20:57:17 2008 -0400
+++ b/includes/paths.php	Tue Aug 19 20:57:57 2008 -0400
@@ -803,6 +803,16 @@
     global $db, $session, $paths, $template, $plugins; // Common objects
     require_once(ENANO_ROOT . '/includes/search.php');
     
+    $progress = false;
+    if ( class_exists('ProgressBar') )
+    {
+      // CLI only.
+      $progress = new ProgressBar('Rebuilding search index: [', ']', 'Initializing...', 'green', 'blue', 'white', 'yellow');
+      $verbose = false;
+      $debug = false;
+      $progress->start();
+    }
+    
     @set_time_limit(0);
     
     $q = $db->sql_query('DELETE FROM ' . table_prefix . 'search_index;');
@@ -868,6 +878,11 @@
               echo ", mem = $mu...";
             flush();
           }
+          else if ( is_object($progress) )
+          {
+            $progress->update_text_quiet("$k/$num_pages {$row['namespace']}:{$row['page_id']}");
+            $progress->set($k, $num_pages);
+          }
           
           // skip this page if it's not supposed to be indexed
           if ( $row['visible'] == 0 )
@@ -943,6 +958,11 @@
         echo '<br />';
       echo "\n";
     }
+    else if ( is_object($progress) )
+    {
+      $progress->update_text('Complete.');
+      $progress->end();
+    }
     return true;
   }